perf(web): warm frequent routes during idle time

This commit is contained in:
lingniu
2026-07-16 01:19:29 +08:00
parent b93e165590
commit 8ebffa4fee
5 changed files with 137 additions and 9 deletions

View File

@@ -11,10 +11,10 @@ import {
IconUser,
IconExit
} from '@douyinfe/semi-icons';
import { useState } from 'react';
import { useEffect, useState } from 'react';
import { NavLink, Outlet, useLocation } from 'react-router-dom';
import { usePlatformSession } from '../auth/AuthGate';
import { preloadRoute } from '../routing/routeModules';
import { preloadRoute, scheduleIdleRoutePreloads } from '../routing/routeModules';
const navigation = [
{ to: '/monitor', label: '全局监控', icon: IconHome },
@@ -39,9 +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 { session, logout } = usePlatformSession();
const roleLabel = { viewer: '只读', operator: '处置员', admin: '管理员' }[session.role];
useEffect(() => scheduleIdleRoutePreloads({ activePathname: initialPathname }), [initialPathname]);
return (
<div className="v2-shell">