navigation.ts 3.0 KB

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