perf(web): reschedule route preloads after navigation

This commit is contained in:
lingniu
2026-07-16 07:09:55 +08:00
parent fa886abff9
commit 970ef5d7c0
2 changed files with 45 additions and 2 deletions

View File

@@ -39,11 +39,11 @@ const pageNames: Record<string, string> = {
export function AppShell() {
const location = useLocation();
const [initialPathname] = useState(() => location.pathname);
const section = location.pathname.split('/')[1] || 'monitor';
const activeRoutePath = `/${section}`;
const { session, logout } = usePlatformSession();
const roleLabel = { viewer: '只读', operator: '处置员', admin: '管理员' }[session.role];
useEffect(() => scheduleIdleRoutePreloads({ activePathname: initialPathname }), [initialPathname]);
useEffect(() => scheduleIdleRoutePreloads({ activePathname: activeRoutePath }), [activeRoutePath]);
return (
<div className="v2-shell">