From 679f03a904bb4bff0f0a14b594119eb3256e8fce Mon Sep 17 00:00:00 2001 From: lsy Date: Mon, 19 May 2025 23:45:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=AF=BC=E8=88=AA=E6=A0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Header.astro | 63 +++++++++++++++++++++++-------------- 1 file changed, 40 insertions(+), 23 deletions(-) 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'}`}>