Bladeren bron

refactor(components): 修正 Header组件选中项逻辑

-将 selectedKey 默认值从 "home" 改为空字符串
-这个改动解决了当路径不在 pathToKey 映射中时,默认选中 "home" 的问题- 现在当路径不匹配时,不会默认选中任何项,提高了菜单显示的准确性
nahida 8 maanden geleden
bovenliggende
commit
343993dd73
1 gewijzigde bestanden met toevoegingen van 5 en 5 verwijderingen
  1. 5 5
      src/components/headerBlock.tsx

+ 5 - 5
src/components/headerBlock.tsx

@@ -1,12 +1,12 @@
 "use client"
 
 import type React from "react"
-import { useState } from "react"
-import { Drawer } from "antd"
+import {useState} from "react"
+import {Drawer} from "antd"
 import Image from "next/image"
 import Link from "next/link"
-import { usePathname } from "next/navigation"
-import { MenuIcon, X } from "lucide-react"
+import {usePathname} from "next/navigation"
+import {MenuIcon, X} from "lucide-react"
 
 const Navigation: React.FC = () => {
   const pathname = usePathname()
@@ -20,7 +20,7 @@ const Navigation: React.FC = () => {
     "/support": "support",
     "/about": "about",
   }
-  const selectedKey = pathToKey[pathname] || "home"
+  const selectedKey = pathToKey[pathname] || ""
 
   const menuItems = [
     { key: "home", label: "首页", href: "/" },