Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
zw785129 authored Nov 26, 2024
1 parent 38da6d5 commit 5a36a5f
Showing 1 changed file with 35 additions and 18 deletions.
53 changes: 35 additions & 18 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2057,7 +2057,7 @@ <h3 id="modalTitle" data-translate="modal_wechat_title"></h3>
});
</script>

<!-- 在 </body> 标签前添加轮播图控制脚本 -->

<script>
let slideIndex = 1;
let slideInterval;
Expand Down Expand Up @@ -2157,29 +2157,46 @@ <h3 id="modalTitle" data-translate="modal_wechat_title"></h3>
menu.classList.toggle('show');
}

// 点击菜单项后自动关闭菜单
document.querySelectorAll('.nav-menu a').forEach(item => {
item.addEventListener('click', () => {
document.addEventListener('DOMContentLoaded', function() {
// 监听语言切换事件
document.addEventListener('languageChanged', function(e) {
// 语言切换后关闭导航菜单
const menu = document.querySelector('.nav-menu');
menu.classList.remove('show');
});
});

// 点击页面其他地方关闭菜单
document.addEventListener('click', (e) => {
if (!e.target.closest('.nav-menu') && !e.target.closest('.menu-toggle')) {
const menu = document.querySelector('.nav-menu');
menu.classList.remove('show');
}
});
// 为所有导航链接添加点击事件
document.querySelectorAll('.nav-menu a').forEach(link => {
link.addEventListener('click', () => {
const menu = document.querySelector('.nav-menu');
menu.classList.remove('show');
});
});

// 修改语言选择的处理
document.addEventListener('DOMContentLoaded', function() {
// 监听语言切换事件
document.addEventListener('languageChanged', function() {
// 语言切换后关闭菜单
// 点击页面其他地方关闭菜单
document.addEventListener('click', (e) => {
const menu = document.querySelector('.nav-menu');
menu.classList.remove('show');
const menuToggle = document.querySelector('.menu-toggle');
const languageSelector = document.querySelector('.language-selector');

// 如果点击的不是菜单、菜单按钮或语言选择器内的元素
if (!menu.contains(e.target) &&
!menuToggle.contains(e.target) &&
!languageSelector.contains(e.target)) {
menu.classList.remove('show');
}
});

// 为语言选择器添加点击事件
const languageOptions = document.querySelectorAll('.language-option');
languageOptions.forEach(option => {
option.addEventListener('click', function() {
// 在语言切换后主动关闭导航菜单
setTimeout(() => {
const menu = document.querySelector('.nav-menu');
menu.classList.remove('show');
}, 100);
});
});
});
</script>
Expand Down

0 comments on commit 5a36a5f

Please sign in to comment.