feat(P21PWA2-1,P21PWA2-2,P21PWA2-3): 深链路由守卫/离线审批队列/SW缓存策略升级

这个提交包含在:
2026-03-12 12:34:56 +08:00
父节点 102d3dcc2b
当前提交 9112383d23
共修改 10 个文件,包含 975 行新增和 163 行删除
+12 -8
查看文件
@@ -2,6 +2,7 @@ import type { PropsWithChildren } from "react";
import { Navigate, useLocation } from "react-router-dom";
import { useAuth } from "../auth/AuthContext";
import { hasAnyPermission } from "../auth/permissions";
import { isOfflineSnapshotAllowedPath } from "../pwa";
function FullPageLoading() {
return (
@@ -18,19 +19,22 @@ function toLoginRedirect(pathname: string, search: string, hash: string) {
export function RequireAuth({ children }: PropsWithChildren) {
const location = useLocation();
const { accessToken, me, ready, mustChangePassword } = useAuth();
const { accessToken, me, ready, mustChangePassword, offlineAccessMode } = useAuth();
if (!ready) {
return <FullPageLoading />;
}
if (!accessToken || !me) {
return (
<Navigate
to={toLoginRedirect(location.pathname, location.search, location.hash)}
replace
/>
);
if (!me) {
return <Navigate to={toLoginRedirect(location.pathname, location.search, location.hash)} replace />;
}
if (!accessToken) {
if (offlineAccessMode && isOfflineSnapshotAllowedPath(location.pathname)) {
return <>{children}</>;
}
return <Navigate to={toLoginRedirect(location.pathname, location.search, location.hash)} replace />;
}
if (mustChangePassword && location.pathname !== "/change-password") {