refactor: pc header数据改两列显示
All checks were successful
Gitea Actions Official-website / deploy-dev (push) Successful in 4s
All checks were successful
Gitea Actions Official-website / deploy-dev (push) Successful in 4s
This commit is contained in:
@@ -120,7 +120,13 @@ abstract class Common extends BaseController
|
|||||||
}
|
}
|
||||||
$children = $this->toTreeAndChunk($categorys, $item['id'], $lv);
|
$children = $this->toTreeAndChunk($categorys, $item['id'], $lv);
|
||||||
if (!empty($children)) {
|
if (!empty($children)) {
|
||||||
$item['children'] = $item['level'] == 1 ? array_chunk($children, 2) : $children;
|
if ($lv == 1) {
|
||||||
|
$item['children'] = array_chunk($children, 2);
|
||||||
|
} else if ($lv == 2) {
|
||||||
|
$item['children'] = array_chunk($children, 3);
|
||||||
|
} else {
|
||||||
|
$item['children'] = $children;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$ret[] = $item;
|
$ret[] = $item;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,7 +77,6 @@
|
|||||||
</div>
|
</div>
|
||||||
{else /}
|
{else /}
|
||||||
<div class="header-nav-title">{$nav.name}</div>
|
<div class="header-nav-title">{$nav.name}</div>
|
||||||
<!-- style="display: block;" -->
|
|
||||||
<div class="header-dropdown">
|
<div class="header-dropdown">
|
||||||
<div class="header-dropdown-content1">
|
<div class="header-dropdown-content1">
|
||||||
{volist name="nav.children" id="child"}
|
{volist name="nav.children" id="child"}
|
||||||
@@ -137,7 +136,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="header-lang-wrapper" >
|
<div class="header-lang-wrapper" >
|
||||||
<span class="header-nav-btn">
|
<span class="header-nav-btn">
|
||||||
<img src="__IMAGES__/l1.png" alt="" style="width: 20px;height:20px">
|
<img src="__IMAGES__/l1.png" alt="" style="width: 20px;height:20px">
|
||||||
</span>
|
</span>
|
||||||
@@ -199,23 +198,23 @@
|
|||||||
const imgContainer = card.querySelector('.header-buy-product-img');
|
const imgContainer = card.querySelector('.header-buy-product-img');
|
||||||
const defaultImg = imgContainer?.querySelector('.header-default-img');
|
const defaultImg = imgContainer?.querySelector('.header-default-img');
|
||||||
const hoverImg = imgContainer?.querySelector('.header-hover-img');
|
const hoverImg = imgContainer?.querySelector('.header-hover-img');
|
||||||
|
|
||||||
// 检查悬浮图是否存在(因为HTML中用了if判断,所以可能有也可能没有这个元素)
|
// 检查悬浮图是否存在(因为HTML中用了if判断,所以可能有也可能没有这个元素)
|
||||||
const hasHoverImg = hoverImg !== null;
|
const hasHoverImg = hoverImg !== null;
|
||||||
|
|
||||||
// 如果没有悬浮图,不需要任何交互,直接返回
|
// 如果没有悬浮图,不需要任何交互,直接返回
|
||||||
if (!hasHoverImg) return;
|
if (!hasHoverImg) return;
|
||||||
|
|
||||||
// 初始状态确保普通图显示,悬浮图隐藏
|
// 初始状态确保普通图显示,悬浮图隐藏
|
||||||
defaultImg.style.opacity = '1';
|
defaultImg.style.opacity = '1';
|
||||||
hoverImg.style.opacity = '0';
|
hoverImg.style.opacity = '0';
|
||||||
|
|
||||||
// 鼠标移入事件:显示悬浮图,隐藏普通图
|
// 鼠标移入事件:显示悬浮图,隐藏普通图
|
||||||
card.addEventListener('mouseenter', () => {
|
card.addEventListener('mouseenter', () => {
|
||||||
defaultImg.style.opacity = '0';
|
defaultImg.style.opacity = '0';
|
||||||
hoverImg.style.opacity = '1';
|
hoverImg.style.opacity = '1';
|
||||||
});
|
});
|
||||||
|
|
||||||
// 鼠标移出事件:恢复普通图,隐藏悬浮图
|
// 鼠标移出事件:恢复普通图,隐藏悬浮图
|
||||||
card.addEventListener('mouseleave', () => {
|
card.addEventListener('mouseleave', () => {
|
||||||
defaultImg.style.opacity = '1';
|
defaultImg.style.opacity = '1';
|
||||||
@@ -231,12 +230,12 @@
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
const tabs = document.querySelectorAll('.header-tab-item');
|
const tabs = document.querySelectorAll('.header-tab-item');
|
||||||
const contents = document.querySelectorAll('.header-tab-content');
|
const contents = document.querySelectorAll('.header-tab-content');
|
||||||
|
|
||||||
// 重置到第一个tab
|
// 重置到第一个tab
|
||||||
if (tabs.length > 0 && tabs[0]) {
|
if (tabs.length > 0 && tabs[0]) {
|
||||||
tabs.forEach(tab => tab.classList.remove('active'));
|
tabs.forEach(tab => tab.classList.remove('active'));
|
||||||
contents.forEach(content => content.classList.remove('active'));
|
contents.forEach(content => content.classList.remove('active'));
|
||||||
|
|
||||||
tabs[0].classList.add('active');
|
tabs[0].classList.add('active');
|
||||||
const firstContentId = tabs[0].getAttribute('data-tab');
|
const firstContentId = tabs[0].getAttribute('data-tab');
|
||||||
const firstContent = document.getElementById(firstContentId);
|
const firstContent = document.getElementById(firstContentId);
|
||||||
@@ -268,10 +267,6 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let searchHistory = JSON.parse(localStorage.getItem('searchHistory') || '[]');
|
let searchHistory = JSON.parse(localStorage.getItem('searchHistory') || '[]');
|
||||||
|
|
||||||
function renderHistory ()
|
function renderHistory ()
|
||||||
@@ -357,7 +352,7 @@
|
|||||||
{
|
{
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
langDropdown.classList.remove('show');
|
langDropdown.classList.remove('show');
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
//搜索关闭
|
//搜索关闭
|
||||||
@@ -367,7 +362,7 @@
|
|||||||
|
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
searchDropdown.classList.remove('show');
|
searchDropdown.classList.remove('show');
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// 鼠标移入导航项时,关闭购买下拉框
|
// 鼠标移入导航项时,关闭购买下拉框
|
||||||
@@ -377,11 +372,11 @@
|
|||||||
|
|
||||||
item.addEventListener('mouseenter', () =>
|
item.addEventListener('mouseenter', () =>
|
||||||
{
|
{
|
||||||
|
|
||||||
buyDropdown.classList.remove('show');
|
buyDropdown.classList.remove('show');
|
||||||
langDropdown.classList.remove('show');
|
langDropdown.classList.remove('show');
|
||||||
searchDropdown.classList.remove('show');
|
searchDropdown.classList.remove('show');
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -463,13 +458,10 @@
|
|||||||
|
|
||||||
renderHistory();
|
renderHistory();
|
||||||
|
|
||||||
|
|
||||||
// ========== 蒙版层功能(支持所有弹窗,包括导航悬停下拉) ==========
|
// ========== 蒙版层功能(支持所有弹窗,包括导航悬停下拉) ==========
|
||||||
const mhk = document.getElementById('mhk');
|
const mhk = document.getElementById('mhk');
|
||||||
const body = document.body;
|
const body = document.body;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 获取滚动条宽度(防止打开弹窗时页面抖动)
|
// 获取滚动条宽度(防止打开弹窗时页面抖动)
|
||||||
function getScrollbarWidth() {
|
function getScrollbarWidth() {
|
||||||
const scrollDiv = document.createElement('div');
|
const scrollDiv = document.createElement('div');
|
||||||
@@ -484,7 +476,7 @@ function getScrollbarWidth() {
|
|||||||
const scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth;
|
const scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth;
|
||||||
console.log(scrollbarWidth,'=scrollbarWidth=')
|
console.log(scrollbarWidth,'=scrollbarWidth=')
|
||||||
document.body.removeChild(scrollDiv);
|
document.body.removeChild(scrollDiv);
|
||||||
|
|
||||||
return scrollbarWidth;
|
return scrollbarWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -504,11 +496,11 @@ function closeOverlay() {
|
|||||||
const isBuyOpen = buyDropdown && buyDropdown.classList.contains('show');
|
const isBuyOpen = buyDropdown && buyDropdown.classList.contains('show');
|
||||||
const isSearchOpen = searchDropdown && searchDropdown.classList.contains('show');
|
const isSearchOpen = searchDropdown && searchDropdown.classList.contains('show');
|
||||||
const isLangOpen = langDropdown && langDropdown.classList.contains('show');
|
const isLangOpen = langDropdown && langDropdown.classList.contains('show');
|
||||||
|
|
||||||
// 检查导航下拉菜单是否打开(通过检查是否有 active 或显示状态)
|
// 检查导航下拉菜单是否打开(通过检查是否有 active 或显示状态)
|
||||||
const productDropdown = document.querySelector('.header-nav-item:first-child .header-dropdown');
|
const productDropdown = document.querySelector('.header-nav-item:first-child .header-dropdown');
|
||||||
const isProductDropdownOpen = productDropdown && window.getComputedStyle(productDropdown).display !== 'none';
|
const isProductDropdownOpen = productDropdown && window.getComputedStyle(productDropdown).display !== 'none';
|
||||||
|
|
||||||
// 检查其他导航下拉菜单
|
// 检查其他导航下拉菜单
|
||||||
let isOtherNavOpen = false;
|
let isOtherNavOpen = false;
|
||||||
const otherNavItems = document.querySelectorAll('.header-nav-item:not(:first-child)');
|
const otherNavItems = document.querySelectorAll('.header-nav-item:not(:first-child)');
|
||||||
@@ -518,7 +510,7 @@ function closeOverlay() {
|
|||||||
isOtherNavOpen = true;
|
isOtherNavOpen = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// 只有当所有弹窗和导航下拉菜单都关闭时,才关闭蒙版层
|
// 只有当所有弹窗和导航下拉菜单都关闭时,才关闭蒙版层
|
||||||
if (!isBuyOpen && !isSearchOpen && !isLangOpen && !isProductDropdownOpen && !isOtherNavOpen) {
|
if (!isBuyOpen && !isSearchOpen && !isLangOpen && !isProductDropdownOpen && !isOtherNavOpen) {
|
||||||
mhk.style.display = 'none';
|
mhk.style.display = 'none';
|
||||||
@@ -531,7 +523,7 @@ function closeOverlay() {
|
|||||||
// 强制关闭所有弹窗和蒙版
|
// 强制关闭所有弹窗和蒙版
|
||||||
function closeAllDropdownsAndOverlay() {
|
function closeAllDropdownsAndOverlay() {
|
||||||
let anyOpen = false;
|
let anyOpen = false;
|
||||||
|
|
||||||
if (buyDropdown && buyDropdown.classList.contains('show')) {
|
if (buyDropdown && buyDropdown.classList.contains('show')) {
|
||||||
buyDropdown.classList.remove('show');
|
buyDropdown.classList.remove('show');
|
||||||
anyOpen = true;
|
anyOpen = true;
|
||||||
@@ -544,7 +536,7 @@ function closeAllDropdownsAndOverlay() {
|
|||||||
langDropdown.classList.remove('show');
|
langDropdown.classList.remove('show');
|
||||||
anyOpen = true;
|
anyOpen = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 关闭产品列表导航的下拉菜单(通过移除hover触发的显示)
|
// 关闭产品列表导航的下拉菜单(通过移除hover触发的显示)
|
||||||
const productNavItem = document.querySelector('.header-nav-item:first-child');
|
const productNavItem = document.querySelector('.header-nav-item:first-child');
|
||||||
if (productNavItem) {
|
if (productNavItem) {
|
||||||
@@ -554,7 +546,7 @@ function closeAllDropdownsAndOverlay() {
|
|||||||
anyOpen = true;
|
anyOpen = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 关闭其他导航的下拉菜单
|
// 关闭其他导航的下拉菜单
|
||||||
const otherNavItems = document.querySelectorAll('.header-nav-item:not(:first-child)');
|
const otherNavItems = document.querySelectorAll('.header-nav-item:not(:first-child)');
|
||||||
otherNavItems.forEach(item => {
|
otherNavItems.forEach(item => {
|
||||||
@@ -564,7 +556,7 @@ function closeAllDropdownsAndOverlay() {
|
|||||||
anyOpen = true;
|
anyOpen = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (anyOpen) {
|
if (anyOpen) {
|
||||||
closeOverlay();
|
closeOverlay();
|
||||||
} else {
|
} else {
|
||||||
@@ -578,7 +570,7 @@ function closeAllDropdownsAndOverlay() {
|
|||||||
const productNavItem = document.querySelector('.header-nav-item:first-child');
|
const productNavItem = document.querySelector('.header-nav-item:first-child');
|
||||||
if (productNavItem) {
|
if (productNavItem) {
|
||||||
const productDropdown = productNavItem.querySelector('.header-dropdown');
|
const productDropdown = productNavItem.querySelector('.header-dropdown');
|
||||||
|
|
||||||
// 监听鼠标进入产品列表导航
|
// 监听鼠标进入产品列表导航
|
||||||
productNavItem.addEventListener('mouseenter', () => {
|
productNavItem.addEventListener('mouseenter', () => {
|
||||||
// 当导航下拉菜单显示时,关闭其他点击弹窗
|
// 当导航下拉菜单显示时,关闭其他点击弹窗
|
||||||
@@ -594,7 +586,7 @@ if (productNavItem) {
|
|||||||
// 打开蒙版层
|
// 打开蒙版层
|
||||||
openOverlay();
|
openOverlay();
|
||||||
});
|
});
|
||||||
|
|
||||||
// 监听鼠标离开产品列表导航(延迟关闭,给用户移动到下拉菜单的时间)
|
// 监听鼠标离开产品列表导航(延迟关闭,给用户移动到下拉菜单的时间)
|
||||||
productNavItem.addEventListener('mouseleave', () => {
|
productNavItem.addEventListener('mouseleave', () => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@@ -610,7 +602,7 @@ if (productNavItem) {
|
|||||||
}
|
}
|
||||||
}, 100);
|
}, 100);
|
||||||
});
|
});
|
||||||
|
|
||||||
// 监听下拉菜单的鼠标离开事件
|
// 监听下拉菜单的鼠标离开事件
|
||||||
if (productDropdown) {
|
if (productDropdown) {
|
||||||
productDropdown.addEventListener('mouseleave', () => {
|
productDropdown.addEventListener('mouseleave', () => {
|
||||||
@@ -630,7 +622,7 @@ otherNavItems.forEach(item => {
|
|||||||
const hasDropdown = item.querySelector('.header-dropdown');
|
const hasDropdown = item.querySelector('.header-dropdown');
|
||||||
if (hasDropdown) {
|
if (hasDropdown) {
|
||||||
const dropdown = hasDropdown;
|
const dropdown = hasDropdown;
|
||||||
|
|
||||||
// 监听鼠标进入导航项
|
// 监听鼠标进入导航项
|
||||||
item.addEventListener('mouseenter', () => {
|
item.addEventListener('mouseenter', () => {
|
||||||
// 关闭其他点击弹窗
|
// 关闭其他点击弹窗
|
||||||
@@ -646,7 +638,7 @@ otherNavItems.forEach(item => {
|
|||||||
// 打开蒙版层
|
// 打开蒙版层
|
||||||
openOverlay();
|
openOverlay();
|
||||||
});
|
});
|
||||||
|
|
||||||
// 监听鼠标离开导航项
|
// 监听鼠标离开导航项
|
||||||
item.addEventListener('mouseleave', () => {
|
item.addEventListener('mouseleave', () => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@@ -661,7 +653,7 @@ otherNavItems.forEach(item => {
|
|||||||
}
|
}
|
||||||
}, 100);
|
}, 100);
|
||||||
});
|
});
|
||||||
|
|
||||||
// 监听下拉菜单的鼠标离开
|
// 监听下拉菜单的鼠标离开
|
||||||
if (dropdown) {
|
if (dropdown) {
|
||||||
dropdown.addEventListener('mouseleave', () => {
|
dropdown.addEventListener('mouseleave', () => {
|
||||||
@@ -683,11 +675,11 @@ const buyWrapperNew = document.querySelector('.header-buy-wrapper');
|
|||||||
if (buyWrapperNew && buyDropdown) {
|
if (buyWrapperNew && buyDropdown) {
|
||||||
const newBuyWrapper = buyWrapperNew.cloneNode(true);
|
const newBuyWrapper = buyWrapperNew.cloneNode(true);
|
||||||
buyWrapperNew.parentNode.replaceChild(newBuyWrapper, buyWrapperNew);
|
buyWrapperNew.parentNode.replaceChild(newBuyWrapper, buyWrapperNew);
|
||||||
|
|
||||||
newBuyWrapper.addEventListener('click', (e) => {
|
newBuyWrapper.addEventListener('click', (e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
const isOpen = buyDropdown.classList.contains('show');
|
const isOpen = buyDropdown.classList.contains('show');
|
||||||
|
|
||||||
if (isOpen) {
|
if (isOpen) {
|
||||||
buyDropdown.classList.remove('show');
|
buyDropdown.classList.remove('show');
|
||||||
closeOverlay();
|
closeOverlay();
|
||||||
@@ -701,7 +693,7 @@ if (buyWrapperNew && buyDropdown) {
|
|||||||
}
|
}
|
||||||
// 关闭导航下拉菜单
|
// 关闭导航下拉菜单
|
||||||
closeAllNavDropdowns();
|
closeAllNavDropdowns();
|
||||||
|
|
||||||
buyDropdown.classList.add('show');
|
buyDropdown.classList.add('show');
|
||||||
openOverlay();
|
openOverlay();
|
||||||
}
|
}
|
||||||
@@ -713,11 +705,11 @@ const searchBtnNew = document.querySelector('.header-search-wrapper .header-nav-
|
|||||||
if (searchBtnNew && searchDropdown) {
|
if (searchBtnNew && searchDropdown) {
|
||||||
const newSearchBtn = searchBtnNew.cloneNode(true);
|
const newSearchBtn = searchBtnNew.cloneNode(true);
|
||||||
searchBtnNew.parentNode.replaceChild(newSearchBtn, searchBtnNew);
|
searchBtnNew.parentNode.replaceChild(newSearchBtn, searchBtnNew);
|
||||||
|
|
||||||
newSearchBtn.addEventListener('click', (e) => {
|
newSearchBtn.addEventListener('click', (e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
const isOpen = searchDropdown.classList.contains('show');
|
const isOpen = searchDropdown.classList.contains('show');
|
||||||
|
|
||||||
if (isOpen) {
|
if (isOpen) {
|
||||||
searchDropdown.classList.remove('show');
|
searchDropdown.classList.remove('show');
|
||||||
closeOverlay();
|
closeOverlay();
|
||||||
@@ -731,7 +723,7 @@ if (searchBtnNew && searchDropdown) {
|
|||||||
}
|
}
|
||||||
// 关闭导航下拉菜单
|
// 关闭导航下拉菜单
|
||||||
closeAllNavDropdowns();
|
closeAllNavDropdowns();
|
||||||
|
|
||||||
searchDropdown.classList.add('show');
|
searchDropdown.classList.add('show');
|
||||||
openOverlay();
|
openOverlay();
|
||||||
if (typeof renderHistory === 'function') {
|
if (typeof renderHistory === 'function') {
|
||||||
@@ -746,11 +738,11 @@ const langBtnNew = document.querySelector('.header-lang-wrapper .header-nav-btn'
|
|||||||
if (langBtnNew && langDropdown) {
|
if (langBtnNew && langDropdown) {
|
||||||
const newLangBtn = langBtnNew.cloneNode(true);
|
const newLangBtn = langBtnNew.cloneNode(true);
|
||||||
langBtnNew.parentNode.replaceChild(newLangBtn, langBtnNew);
|
langBtnNew.parentNode.replaceChild(newLangBtn, langBtnNew);
|
||||||
|
|
||||||
newLangBtn.addEventListener('click', (e) => {
|
newLangBtn.addEventListener('click', (e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
const isOpen = langDropdown.classList.contains('show');
|
const isOpen = langDropdown.classList.contains('show');
|
||||||
|
|
||||||
if (isOpen) {
|
if (isOpen) {
|
||||||
langDropdown.classList.remove('show');
|
langDropdown.classList.remove('show');
|
||||||
closeOverlay();
|
closeOverlay();
|
||||||
@@ -764,7 +756,7 @@ if (langBtnNew && langDropdown) {
|
|||||||
}
|
}
|
||||||
// 关闭导航下拉菜单
|
// 关闭导航下拉菜单
|
||||||
closeAllNavDropdowns();
|
closeAllNavDropdowns();
|
||||||
|
|
||||||
langDropdown.classList.add('show');
|
langDropdown.classList.add('show');
|
||||||
openOverlay();
|
openOverlay();
|
||||||
}
|
}
|
||||||
@@ -781,7 +773,7 @@ function closeAllNavDropdowns() {
|
|||||||
productDropdown.style.display = '';
|
productDropdown.style.display = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 关闭其他导航下拉菜单
|
// 关闭其他导航下拉菜单
|
||||||
const otherNavItems = document.querySelectorAll('.header-nav-item:not(:first-child)');
|
const otherNavItems = document.querySelectorAll('.header-nav-item:not(:first-child)');
|
||||||
otherNavItems.forEach(item => {
|
otherNavItems.forEach(item => {
|
||||||
@@ -799,7 +791,7 @@ const langCloseBtnNew = document.querySelector('.header-lang-dropdown-delete-ico
|
|||||||
if (langCloseBtnNew && langDropdown) {
|
if (langCloseBtnNew && langDropdown) {
|
||||||
const newLangCloseBtn = langCloseBtnNew.cloneNode(true);
|
const newLangCloseBtn = langCloseBtnNew.cloneNode(true);
|
||||||
langCloseBtnNew.parentNode.replaceChild(newLangCloseBtn, langCloseBtnNew);
|
langCloseBtnNew.parentNode.replaceChild(newLangCloseBtn, langCloseBtnNew);
|
||||||
|
|
||||||
newLangCloseBtn.addEventListener('click', (e) => {
|
newLangCloseBtn.addEventListener('click', (e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
langDropdown.classList.remove('show');
|
langDropdown.classList.remove('show');
|
||||||
@@ -812,7 +804,7 @@ const searchCloseBtnNew = document.querySelector('.header-search-dropdown-delete
|
|||||||
if (searchCloseBtnNew && searchDropdown) {
|
if (searchCloseBtnNew && searchDropdown) {
|
||||||
const newSearchCloseBtn = searchCloseBtnNew.cloneNode(true);
|
const newSearchCloseBtn = searchCloseBtnNew.cloneNode(true);
|
||||||
searchCloseBtnNew.parentNode.replaceChild(newSearchCloseBtn, searchCloseBtnNew);
|
searchCloseBtnNew.parentNode.replaceChild(newSearchCloseBtn, searchCloseBtnNew);
|
||||||
|
|
||||||
newSearchCloseBtn.addEventListener('click', (e) => {
|
newSearchCloseBtn.addEventListener('click', (e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
searchDropdown.classList.remove('show');
|
searchDropdown.classList.remove('show');
|
||||||
@@ -829,7 +821,7 @@ document.addEventListener('click', (e) => {
|
|||||||
closeOverlay();
|
closeOverlay();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查是否点击在搜索区域外
|
// 检查是否点击在搜索区域外
|
||||||
if (!e.target.closest('.header-search-wrapper') && !e.target.closest('#searchDropdown')) {
|
if (!e.target.closest('.header-search-wrapper') && !e.target.closest('#searchDropdown')) {
|
||||||
if (searchDropdown && searchDropdown.classList.contains('show')) {
|
if (searchDropdown && searchDropdown.classList.contains('show')) {
|
||||||
@@ -837,7 +829,7 @@ document.addEventListener('click', (e) => {
|
|||||||
closeOverlay();
|
closeOverlay();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查是否点击在语言区域外
|
// 检查是否点击在语言区域外
|
||||||
if (!e.target.closest('.header-lang-wrapper') && !e.target.closest('#langDropdown')) {
|
if (!e.target.closest('.header-lang-wrapper') && !e.target.closest('#langDropdown')) {
|
||||||
if (langDropdown && langDropdown.classList.contains('show')) {
|
if (langDropdown && langDropdown.classList.contains('show')) {
|
||||||
@@ -845,7 +837,7 @@ document.addEventListener('click', (e) => {
|
|||||||
closeOverlay();
|
closeOverlay();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查是否点击在导航区域外(如果点击在导航外部,关闭导航下拉菜单)
|
// 检查是否点击在导航区域外(如果点击在导航外部,关闭导航下拉菜单)
|
||||||
if (!e.target.closest('.header-nav-item')) {
|
if (!e.target.closest('.header-nav-item')) {
|
||||||
closeAllNavDropdowns();
|
closeAllNavDropdowns();
|
||||||
@@ -865,7 +857,7 @@ if (mhk) {
|
|||||||
// ========== 监听弹窗状态变化 ==========
|
// ========== 监听弹窗状态变化 ==========
|
||||||
function setupDropdownObserver(dropdown, name) {
|
function setupDropdownObserver(dropdown, name) {
|
||||||
if (!dropdown) return;
|
if (!dropdown) return;
|
||||||
|
|
||||||
const observer = new MutationObserver((mutations) => {
|
const observer = new MutationObserver((mutations) => {
|
||||||
mutations.forEach((mutation) => {
|
mutations.forEach((mutation) => {
|
||||||
if (mutation.attributeName === 'class') {
|
if (mutation.attributeName === 'class') {
|
||||||
|
|||||||
Reference in New Issue
Block a user