fix(site): nav 透明仅限 www 首页——其余页面保持白底不透明,路由切换立即校正

This commit is contained in:
TermiNexus committed 2026-08-13 10:40:46 +08:00
1 parent 84251cd531
commit 45654b1ef7
1 file changed
+12 -7
+12 -7
View File
@@ -408,14 +408,11 @@ function hideResultsSoon(): void {
}, 200)
}
/** 滚动时 header 透明/白底切换(对齐 nav.js) */
/** 滚动时 header 透明/白底切换(对齐 nav.js)
* 仅 www 首页(HomeView)在页面顶部时透明,其余页面保持白底不透明 */
function handleScroll(): void {
const isMegaOpen = activeMega.value !== null
if (isMegaOpen && window.scrollY <= 200) {
navTheme.value = 'light'
return
}
navTheme.value = window.scrollY <= 5 ? 'light' : 'dark'
const isHome = router.currentRoute.value.name === 'Home'
navTheme.value = isHome && window.scrollY <= 5 ? 'light' : 'dark'
}
/** 头像加载(对齐 main.js) */
@@ -447,6 +444,14 @@ watch(
handleScroll()
}
)
// 路由切换后立即校正 nav 透明态(离开首页 → 恢复白底不透明)
watch(
() => router.currentRoute.value.fullPath,
() => {
handleScroll()
}
)
</script>
<style scoped>