文件
hyb-oa/client/src/features/navigation/schema.ts
T

76 行
4.1 KiB
TypeScript

import {
isKnownManagementPath,
resolveManagementRoute,
} from "./managementRoutes";
export const MAIN_NAV_ORDER = ["/portal", "/workflow/tasks", "/reimbursements", "/purchase-requests", "/contracts-registry", "/projects", "/assets", "/payment-batches", "/ap-operations", "/invoice-pool", "/team", "/leave-requests"];
export const ADMIN_NAV_ORDER = ["/system/settings"];
export const BACKUP_NAV_ORDER = ["/weekly-reports", "/announcements", "/budgets", "/attendance", "/wecom-approval-archive", "/travel-requests", "/inventory-checks", "/dashboard"];
const PAGE_TITLES: Array<{ path: string; title: string; group: string }> = [
{ path: "/portal", title: "工作台", group: "工作台" },
{ path: "/announcements", title: "公告", group: "业务" },
{ path: "/team", title: "团队", group: "业务" },
{ path: "/attendance", title: "考勤", group: "业务" },
{ path: "/wecom-approval-archive", title: "企微审批历史", group: "业务" },
{ path: "/projects", title: "项目", group: "业务" },
{ path: "/contracts-registry", title: "合同", group: "业务" },
{ path: "/purchase-requests/", title: "采购详情", group: "业务" },
{ path: "/purchase-requests", title: "采购", group: "业务" },
{ path: "/travel-requests", title: "差旅申请", group: "更多" },
{ path: "/budgets", title: "预算管理", group: "财务" },
{ path: "/payment-batches", title: "付款", group: "财务" },
{ path: "/ap-operations", title: "应付账款", group: "财务" },
{ path: "/invoice-pool", title: "票据", group: "财务" },
{ path: "/inventory-checks", title: "盘点任务", group: "财务" },
{ path: "/weekly-reports", title: "周报", group: "业务" },
{ path: "/todos", title: "我的事项", group: "工作" },
{ path: "/reimbursements/", title: "报销详情", group: "工作" },
{ path: "/reimbursements", title: "报销", group: "工作" },
{ path: "/leave-requests", title: "请假记录", group: "业务" },
{ path: "/assets/new", title: "新增资产", group: "业务" },
{ path: "/assets/", title: "资产详情", group: "业务" },
{ path: "/assets", title: "资产", group: "业务" },
{ path: "/workflow/tasks/", title: "审批详情", group: "工作" },
{ path: "/workflow/tasks", title: "待我审批", group: "工作" },
{ path: "/notifications", title: "通知", group: "工作" },
{ path: "/mobile/assets/scan", title: "移动资产扫描", group: "移动工作台" },
{ path: "/mobile/approvals", title: "移动审批", group: "移动工作台" },
{ path: "/mobile/notifications", title: "移动通知", group: "移动工作台" },
{ path: "/mobile/wecom-approval-archive", title: "移动企微审批历史", group: "移动工作台" },
{ path: "/mobile/capture", title: "移动 PDF 发票上传", group: "移动工作台" },
{ path: "/mobile/leave", title: "移动请假", group: "移动工作台" },
{ path: "/mobile/me", title: "移动我的", group: "移动工作台" },
{ path: "/mobile/purchase-requests/", title: "移动采购详情", group: "移动工作台" },
{ path: "/mobile/purchase-requests", title: "移动采购", group: "移动工作台" },
{ path: "/mobile/reimbursements", title: "移动报销", group: "移动工作台" },
{ path: "/mobile", title: "移动首页", group: "移动工作台" },
{ path: "/system/settings", title: "管理", group: "管理" },
{ path: "/settings/profile", title: "个人设置", group: "账号设置" },
{ path: "/dashboard", title: "数据看板", group: "更多" },
];
export function resolvePageMeta(pathname: string, permissions: string[] = []) {
const managementRoute = resolveManagementRoute(pathname, permissions);
if (managementRoute) {
return { title: managementRoute.title, group: "管理" };
}
if (isKnownManagementPath(pathname)) {
return { title: "管理", group: "管理" };
}
const matched = [...PAGE_TITLES].sort((left, right) => right.path.length - left.path.length)
.find((item) => pathname === item.path || pathname.startsWith(item.path));
if (matched) {
return matched;
}
if (pathname === "/") {
return { title: "工作台", group: "工作台" };
}
return { title: pathname, group: "工作台" };
}