From 9a2f06fa55b0afb7c6416fc767b79f5cd1e55ec9 Mon Sep 17 00:00:00 2001 From: b2894lxlx <517289602@qq.com> Date: Wed, 27 Nov 2024 22:02:51 +0800 Subject: [PATCH] fix bug --- .nuxt/manifest/latest.json | 2 +- .nuxt/nuxt.d.ts | 2 +- components/AppHeader.vue | 104 +++++++++++------------------- pages/components/AboutUs.vue | 3 +- pages/components/CompanyStyle.vue | 2 +- pages/components/Djzt.vue | 2 +- pages/components/NewsCenter.vue | 8 +-- 7 files changed, 47 insertions(+), 76 deletions(-) diff --git a/.nuxt/manifest/latest.json b/.nuxt/manifest/latest.json index f7d5fe4..483508d 100644 --- a/.nuxt/manifest/latest.json +++ b/.nuxt/manifest/latest.json @@ -1 +1 @@ -{"id":"dev","timestamp":1732706138674} \ No newline at end of file +{"id":"dev","timestamp":1732707471655} \ No newline at end of file diff --git a/.nuxt/nuxt.d.ts b/.nuxt/nuxt.d.ts index d0b782e..63795b7 100644 --- a/.nuxt/nuxt.d.ts +++ b/.nuxt/nuxt.d.ts @@ -1,8 +1,8 @@ // Generated by nuxi +/// /// /// /// -/// /// /// /// diff --git a/components/AppHeader.vue b/components/AppHeader.vue index b5c8f11..82a6aa2 100644 --- a/components/AppHeader.vue +++ b/components/AppHeader.vue @@ -41,15 +41,15 @@
-
-

+
+

{{ item.title }}

-
-
+
+
-

{{ item.title }}

+ +

{{ item.title }}

@@ -93,7 +92,7 @@ @@ -117,7 +116,7 @@ 会员中心 退出 - + @@ -160,66 +159,16 @@ const sysDomain = useSysDomain(); const setNav = () => { navigations.value = navigations.value.map(item => { item.showChild = false - item.childHeight = 0; + item.childHeight = item.children ? parseInt((item.children?.length * 31).toString()) : 0; return item }) + nextTick(() => { + const childMenuList = document.getElementsByClassName('.child-menu') + console.log('childMenuList', childMenuList) + }) } setNav() -const time = 10 -let interval: NodeJS.Timeout -const mouseenter = async (index: number) => { - let showIndex = -1; - for (let i = 0; i < navigations.value.length; i++) { - console.log(navigations.value[i].showChild) - if (navigations.value[i].showChild) { - showIndex = i - break - } - } - if (showIndex === index) return - const item = navigations.value[index]; - const childHeight = item.children ? parseInt((item.children?.length * 31).toString()) : 0; - await hideAll() - item.showChild = true - if (item.childHeight === undefined) item.childHeight = 0 - interval = setInterval(() => { - if (item.childHeight !== undefined && item.childHeight >= childHeight && interval) clearInterval(interval) - if (item.childHeight !== undefined && item.children !== undefined && (item.childHeight < childHeight)) { - item.childHeight += parseInt(((childHeight / item.children?.length) / 5).toString()) - } else { - // item.childHeight = childHeight - if (interval) clearInterval(interval) - } - console.log(item.childHeight, childHeight) - // console.log(item.childHeight) - }, time) -} - -const mouseleave = () => { - if (interval) clearInterval(interval) -} - -const hideAll = () => { - return new Promise(resolve => { - navigations.value = navigations.value.map(item => { - if (item.childHeight === undefined) item.childHeight = 0 - if (item.showChild) { - const childHeight = item.children ? parseInt((item.children?.length * 31).toString()) : 0; - const interval = setInterval(() => { - if (item.childHeight !== undefined && item.children !== undefined && (item.childHeight > 0)) { - item.childHeight -= parseInt(((childHeight / item.children?.length) / 5).toString()) - } else { - item.showChild = false - clearInterval(interval) - } - }, time) - } - return item - }) - resolve(true) - }) -} // 顶部栏初始数 const visibleNumber = ref(6); @@ -299,4 +248,25 @@ body { .is-active:hover { border-bottom: none !important; } + +.top-menu:hover .child-menu { + display: block; + animation: revealMask 0.5s forwards; +} + +.child-menu { + display: none; + max-height: 0; /* 初始最大高度为0 */ + overflow: hidden; /* 隐藏超出部分 */ + transition: max-height 0.5s ease; /* 平滑过渡 */ +} + +@keyframes revealMask { + from { + max-height: 0; + } + to { + max-height: 600px; /* 设置一个足够大的值,确保内容完全显示 */ + } +} diff --git a/pages/components/AboutUs.vue b/pages/components/AboutUs.vue index f3e5e2c..1d78b31 100644 --- a/pages/components/AboutUs.vue +++ b/pages/components/AboutUs.vue @@ -60,7 +60,8 @@ const showAboutUs = ref(false) watch( () => props.scrollTop, () => { - if (props.scrollTop > 700) showAboutUs.value = true + console.log(props.scrollTop) + if (props.scrollTop > 100) showAboutUs.value = true }, {immediate: true} ); diff --git a/pages/components/CompanyStyle.vue b/pages/components/CompanyStyle.vue index f18a65c..88df4ac 100644 --- a/pages/components/CompanyStyle.vue +++ b/pages/components/CompanyStyle.vue @@ -82,7 +82,7 @@ watch( () => [props.groupId, props.scrollTop], () => { reload(); - if (props.scrollTop >= 1580) show.value = true + if (props.scrollTop >= 700) show.value = true }, {immediate: true} diff --git a/pages/components/Djzt.vue b/pages/components/Djzt.vue index e440ed7..c02d550 100644 --- a/pages/components/Djzt.vue +++ b/pages/components/Djzt.vue @@ -82,7 +82,7 @@ watch( () => [props.groupId, props.scrollTop], () => { reload(); - if (props.scrollTop >= 2240) show.value = true + if (props.scrollTop >= 1300) show.value = true }, {immediate: true} diff --git a/pages/components/NewsCenter.vue b/pages/components/NewsCenter.vue index ec548d7..2cb478b 100644 --- a/pages/components/NewsCenter.vue +++ b/pages/components/NewsCenter.vue @@ -26,7 +26,7 @@
-
+
@@ -56,7 +56,7 @@

-
+
@@ -157,13 +157,13 @@ const reload = async () => { } } -const showNews = ref(false) +const showNews = ref(true) watch( () => [props.parentId, props.scrollTop], ([parentId, scrollTop]) => { getCategory(); - if (props.scrollTop > 70) showNews.value = true + // if (props.scrollTop > 70) showNews.value = true }, {immediate: true} );