import { NavLink } from "react-router-dom"; import { useAuth } from "../../auth/AuthContext"; import { hasAnyPermission } from "../../auth/permissions"; import { cn } from "../../lib/utils"; export type NavItem = { to: string; label: string; anyOf?: string[]; }; export const NAV_ITEMS: NavItem[] = [ { to: "/dashboard", label: "仪表盘" }, { to: "/reimbursements", label: "我的报销", anyOf: ["expense.view_own", "expense.view_all"], }, { to: "/workflow/tasks", label: "待我处理", anyOf: ["expense.approve"], }, { to: "/invoice-pool", label: "票据中心", anyOf: ["invoice.upload", "invoice.view_own", "invoice.manage"], }, { to: "/audit-logs", label: "审计工作台", anyOf: ["system.audit.view"], }, { to: "/delegations", label: "委派管理", anyOf: ["expense.proxy_manage"], }, { to: "/system/users", label: "用户管理", anyOf: ["system.users"], }, { to: "/settings/profile", label: "个人设置" }, ]; export function NavLinks({ onNavigate }: { onNavigate?: () => void }) { const { permissions } = useAuth(); const visibleItems = NAV_ITEMS.filter((item) => { if (!item.anyOf) { return true; } return hasAnyPermission(permissions, item.anyOf); }); return ( ); }