From 5d979f05105a5e3bb12a25852f3427732c19f7ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=87=E9=98=B3?= Date: Fri, 29 Aug 2025 19:23:41 +0800 Subject: [PATCH] =?UTF-8?q?feat(Header):=20=E4=BC=98=E5=8C=96=E5=AF=BC?= =?UTF-8?q?=E8=88=AA=E6=A0=8F=E5=88=86=E7=B1=BB=E5=92=8C=E5=AF=BC=E8=88=AA?= =?UTF-8?q?=E9=A1=B9=E7=9A=84=E6=B8=B2=E6=9F=93=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 重构导航栏渲染逻辑,将分类和导航项分开处理,并优化子菜单的显示条件 修改Cate接口的type字段为联合类型,明确区分分类和导航类型 调整logo图片样式,防止图片被压缩 --- src/components/Header/index.tsx | 60 ++++++++++++++++++--------------- src/types/app/cate.d.ts | 2 +- 2 files changed, 33 insertions(+), 29 deletions(-) diff --git a/src/components/Header/index.tsx b/src/components/Header/index.tsx index 93859c3..bd508bb 100755 --- a/src/components/Header/index.tsx +++ b/src/components/Header/index.tsx @@ -98,7 +98,7 @@ const Header = () => { {/* logo */} - {isDark ? Logo : Logo} + {isDark ? Logo : Logo} - ) - )} + )} -
  • - - 🧩 探索 - - - - + {/* 渲染导航 */} + {one.type === 'nav' && ( +
  • + + {one.icon} {one.name} - -
      - {cateList?.map( - (item) => - item.type === 'nav' && ( -
    • - - {item.icon} {item.name} - -
    • - ) - )} -
    -
    -
  • + {/* 如果有子分类就显示下拉三角 */} + + + + + + + + + + )} + + ))} {/* 主题切换开关 */} diff --git a/src/types/app/cate.d.ts b/src/types/app/cate.d.ts index cd6fa65..02f8ca4 100755 --- a/src/types/app/cate.d.ts +++ b/src/types/app/cate.d.ts @@ -5,7 +5,7 @@ export interface Cate { url: string, icon: string, level: number, - type: string, + type: 'cate' | 'nav', order: number, children: Cate[] }