import { useAuth } from "@web/src/providers/auth-provider"; import { Menu } from "antd"; import { useMemo } from "react"; import { useNavigate, useLocation } from "react-router-dom"; export const NavigationMenu = () => { const navigate = useNavigate(); const { isAuthenticated } = useAuth(); const { pathname } = useLocation(); const menuItems = useMemo(() => { const baseItems = [ { key: "home", path: "/", label: "首页" }, { key: "path", path: "/path", label: "思维导图" }, { key: "courses", path: "/courses", label: "所有课程" }, ]; if (!isAuthenticated) { return baseItems; } else { return [ ...baseItems, { key: "my-duty", path: "/my-duty", label: "我的授课" }, { key: "my-learning", path: "/my-learning", label: "我的课程" }, { key: "my-path", path: "/my-path", label: "我的路径" }, ]; } }, [isAuthenticated]); const selectedKey = menuItems.find((item) => item.path === pathname)?.key || ""; return (
); };