This commit is contained in:
ditiqi 2025-02-28 15:17:57 +08:00
commit d32c04661f
1 changed files with 5 additions and 2 deletions

View File

@ -28,8 +28,11 @@ export const NavigationMenu = () => {
}
}, [isAuthenticated]);
const selectedKey =
menuItems.find((item) => item.path === pathname)?.key || "";
const selectedKey = useMemo(() => {
const normalizePath = (path: string): string => path.replace(/\/$/, "");
return pathname === '/' ? "home" : menuItems.find((item) => normalizePath(pathname) === item.path)?.key || "";
}, [pathname]);
return (
<Menu
mode="horizontal"