R110/A2,A3 补齐手机和PC路由分流

这个提交包含在:
2026-05-08 02:25:14 +08:00
父节点 3354608e20
当前提交 ee59ecfc45
共修改 9 个文件,包含 298 行新增和 17 行删除
+85
查看文件
@@ -36,3 +36,88 @@ export function shouldPreferMobileWorkplace() {
export function resolveDefaultWorkspacePath() {
return shouldPreferMobileWorkplace() ? "/mobile" : "/portal";
}
function encodeSegment(value: string) {
return encodeURIComponent(value);
}
export function resolveMobileEquivalentPath(pathname: string, search = "") {
const normalizedPath = pathname.replace(/\/+$/, "") || "/";
if (normalizedPath === "/" || normalizedPath === "/portal" || normalizedPath === "/dashboard") {
return "/mobile";
}
if (normalizedPath === "/notifications") {
return "/mobile/notifications";
}
if (normalizedPath === "/settings/profile") {
return "/mobile/profile";
}
if (normalizedPath === "/reimbursements" || normalizedPath === "/reimbursements/dashboard") {
return "/mobile/reimbursements";
}
const reimbursementPrintMatch = normalizedPath.match(/^\/reimbursements\/([^/]+)\/print$/);
if (reimbursementPrintMatch?.[1]) {
return `/mobile/reimbursements/${encodeSegment(reimbursementPrintMatch[1])}`;
}
const reimbursementDetailMatch = normalizedPath.match(/^\/reimbursements\/([^/]+)$/);
if (reimbursementDetailMatch?.[1]) {
return `/mobile/reimbursements/${encodeSegment(reimbursementDetailMatch[1])}`;
}
if (normalizedPath === "/leave-requests") {
return "/mobile/leave";
}
if (normalizedPath === "/invoice-pool") {
return "/mobile/capture";
}
const workflowTaskMatch = normalizedPath.match(/^\/workflow\/tasks\/([^/]+)$/);
if (workflowTaskMatch?.[1]) {
return `/mobile/approvals?${new URLSearchParams({ taskId: workflowTaskMatch[1] }).toString()}`;
}
if (normalizedPath === "/workflow/tasks") {
return "/mobile/approvals";
}
if (normalizedPath === "/assets" || normalizedPath === "/inventory-checks") {
return "/mobile/assets/scan";
}
if (
normalizedPath.startsWith("/system") ||
normalizedPath.startsWith("/people") ||
normalizedPath.startsWith("/organization") ||
normalizedPath.startsWith("/payroll") ||
normalizedPath.startsWith("/performance")
) {
return "/mobile/me";
}
if (
normalizedPath.startsWith("/projects") ||
normalizedPath.startsWith("/contracts-registry") ||
normalizedPath.startsWith("/purchase-requests") ||
normalizedPath.startsWith("/travel-requests") ||
normalizedPath.startsWith("/payment-batches") ||
normalizedPath.startsWith("/ap-operations") ||
normalizedPath.startsWith("/weekly-reports") ||
normalizedPath.startsWith("/todos") ||
normalizedPath.startsWith("/team") ||
normalizedPath.startsWith("/attendance") ||
normalizedPath.startsWith("/budgets") ||
normalizedPath.startsWith("/announcements") ||
normalizedPath.startsWith("/delegations")
) {
return "/mobile";
}
return search ? `${pathname}${search}` : pathname;
}