diff --git a/src/components/Header.astro b/src/components/Header.astro index 1ca21cc..4649a4e 100644 --- a/src/components/Header.astro +++ b/src/components/Header.astro @@ -14,7 +14,6 @@ const normalizedPath = ? currentPath.slice(0, -1) : currentPath; -// 定义导航链接 // 在服务器端预先查找激活项 let activeItem = null; @@ -49,17 +48,8 @@ if (!activeSubItem) { } } -// 样式变量 - 用于设置高亮背景的默认属性 -let primaryHighlightStyle = activeItem || activeGroupId ? "opacity: 1;" : "opacity: 0;"; -let secondaryHighlightStyle = activeSubItem ? "opacity: 1;" : "opacity: 0;"; - -// 导航选择器样式设置 -const activeClass = "font-medium"; -const itemClass = "px-4 py-2 text-sm font-medium"; -const primaryHighlightClass = "bg-primary-100 dark:bg-primary-800/30 rounded-xl shadow-md backdrop-blur-sm"; -const secondaryHighlightClass = "bg-primary-300/80 dark:bg-primary-700/60 rounded-xl shadow-md backdrop-blur-sm"; -const transitionDuration = 300; -const navSelectorClassName = "mr-4"; +// 计算活动状态 +const hasActiveNavItem = activeItem || activeGroupId || activeSubItem ? true : false; ---
+ class={`absolute z-10 bg-primary-300/80 dark:bg-primary-700/60 rounded-xl shadow-md backdrop-blur-sm transition-all duration-300 ${activeSubItem ? 'opacity-100' : 'opacity-0'}`}>
@@ -109,7 +97,9 @@ const navSelectorClassName = "mr-4"; @@ -121,7 +111,9 @@ const navSelectorClassName = "mr-4";