navigation.ts 4.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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" | "workOrderOverview" | "workOrders" | "workOrderMine" | "workOrderQueue" | "workOrderDelivery" | "workOrderSettings" | "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. /* 2026-11-17 菜单组重构:「工单与开停」→「工单与任务」,拆成总览/台账/待分派/交付与回执/工单配置五个入口;
  30. * 「定时任务」摘为独立菜单(section 为空=不给分组头),⛔ 再塞回工单组。
  31. * 2026-11-17 追加:「我的待办」也进运营侧菜单(业主:运营与运维主账号同样要有),
  32. * 排在总览之后——它与总览是同一件事的两个视角(全区域 vs 我名下)。 */
  33. { id: "workOrderOverview", title: "工单总览", path: "/work-orders/overview", section: "工单与任务" },
  34. { id: "workOrderMine", title: "我的待办", path: "/work-orders/mine", section: "工单与任务" },
  35. { id: "workOrders", title: "全部工单", path: "/work-orders", section: "工单与任务" },
  36. { id: "workOrderQueue", title: "待分派", path: "/work-orders/queue", section: "工单与任务" },
  37. { id: "workOrderDelivery", title: "交付与回执", path: "/work-orders/delivery", section: "工单与任务" },
  38. { id: "workOrderSettings", title: "工单配置", path: "/work-order-settings", section: "工单与任务" },
  39. { id: "dailyTasks", title: "定时任务", path: "/daily-tasks", section: "" },
  40. { id: "auditLogs", title: "审计日志", path: "/audit-logs", section: "" },
  41. ];
  42. export function getNavigationForRole(role: LoginRole): NavigationItem[] {
  43. return navigationItems.filter(
  44. (item) => !item.capability || canShowAction(role, item.capability),
  45. );
  46. }
  47. export function canShowNavigationPath(role: LoginRole, path: string): boolean {
  48. return getNavigationForRole(role).some((item) => item.path === path);
  49. }