import { canShowAction, type Capability } from "./capabilities.ts"; import type { LoginRole } from "./roles"; export type NavigationItem = { id: "home" | "regions" | "operators" | "partners" | "operationsTeams" | "maintenanceTeams" | "packages" | "contracts" | "customers" | "importBatches" | "orders" | "shareRules" | "costs" | "settlementBatches" | "settlementBills" | "correctionNotes" | "reconcileSettings" | "workOrders" | "dailyTasks" | "auditLogs"; title: string; path: string; section: string; capability?: Capability; }; /** 只列已实现页面;后续模块落地时再添加导航,不展示空链接。 */ export const navigationItems: readonly NavigationItem[] = [ { id: "home", title: "概览", path: "/", section: "" }, { id: "regions", title: "区域管理", path: "/organization/regions", section: "组织与区域" }, { id: "operators", title: "运营商", path: "/organization/operators", section: "组织与区域" }, { id: "partners", title: "合伙人", path: "/organization/partners", section: "组织与区域" }, { id: "operationsTeams", title: "运营团队", path: "/organization/operations-teams", section: "组织与区域" }, { id: "maintenanceTeams", title: "运维团队", path: "/organization/maintenance-teams", section: "组织与区域" }, { id: "packages", title: "套餐配置", path: "/packages", section: "客户与订阅", capability: "package.manage" }, { id: "contracts", title: "合同管理", path: "/contracts", section: "客户与订阅" }, { id: "customers", title: "客户管理", path: "/customers", section: "客户与订阅" }, { id: "importBatches", title: "批量导入", path: "/import-batches", section: "客户与订阅" }, { id: "orders", title: "全部订阅", path: "/orders", section: "客户与订阅" }, { id: "shareRules", title: "分成管理", path: "/share-rules", section: "分成与对账" }, { id: "costs", title: "成本管理", path: "/costs", section: "分成与对账" }, { id: "settlementBatches", title: "对账清单", path: "/settlement-batches", section: "分成与对账" }, { id: "settlementBills", title: "账单明细", path: "/settlement-bills", section: "分成与对账" }, { id: "correctionNotes", title: "出账更正记录", path: "/correction-notes", section: "分成与对账" }, { id: "reconcileSettings", title: "出账配置", path: "/reconciliation-settings", section: "分成与对账" }, { id: "workOrders", title: "工单管理", path: "/work-orders", section: "工单与开停" }, { id: "dailyTasks", title: "定时任务", path: "/daily-tasks", section: "工单与开停" }, { id: "auditLogs", title: "审计日志", path: "/audit-logs", section: "" }, ]; export function getNavigationForRole(role: LoginRole): NavigationItem[] { return navigationItems.filter( (item) => !item.capability || canShowAction(role, item.capability), ); } export function canShowNavigationPath(role: LoginRole, path: string): boolean { return getNavigationForRole(role).some((item) => item.path === path); }