From e3c9f2c25949a8a3e79d57cceca8b7ee9fd6ddb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=87=E9=98=B3?= Date: Sat, 30 Aug 2025 17:49:37 +0800 Subject: [PATCH] =?UTF-8?q?refactor(Header):=20=E4=BC=98=E5=8C=96=E5=AF=BC?= =?UTF-8?q?=E8=88=AA=E7=BB=84=E4=BB=B6=E4=BB=A3=E7=A0=81=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将 patchName 声明提前到组件顶部 - 为导航列表项添加 key 属性 - 统一子导航项的变量命名 - 修复导航链接的 href 属性 --- src/components/Header/index.tsx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/components/Header/index.tsx b/src/components/Header/index.tsx index bd508bb..ca2bc51 100755 --- a/src/components/Header/index.tsx +++ b/src/components/Header/index.tsx @@ -20,6 +20,8 @@ import { useConfigStore } from '@/stores'; import { Other, Theme, Web } from '@/types/app/config'; const Header = () => { + const patchName = usePathname(); + // 是否暗黑模式 const { isDark, setIsDark, setWeb, theme, setTheme, setOther } = useConfigStore(); @@ -41,7 +43,6 @@ const Header = () => { setOther(other); }; - const patchName = usePathname(); // 这些路径段不需要改变导航样式 const isPathSty = ['/my', '/wall', '/record', '/equipment', '/tags', '/resume', '/album', '/fishpond'].some((path) => patchName.includes(path)); // 是否改变导航样式 @@ -137,10 +138,9 @@ const Header = () => { {/* 渲染导航 */} {one.type === 'nav' && ( -
  • - +
  • + {one.icon} {one.name} - {/* 如果有子分类就显示下拉三角 */} @@ -149,10 +149,10 @@ const Header = () => {
      - {one.children?.map((item) => ( -
    • - - {item.icon} {item.name} + {one.children?.map((two) => ( +
    • + + {two.icon} {two.name}
    • ))}