perf(web): warm frequent routes during idle time
This commit is contained in:
@@ -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">
|
||||
|
||||
Reference in New Issue
Block a user