perf(web): bound speculative route warming

This commit is contained in:
lingniu
2026-07-16 03:39:47 +08:00
parent cad39d6326
commit 2f26fd25b9
5 changed files with 135 additions and 37 deletions

View File

@@ -14,7 +14,7 @@ import {
import { useEffect, useState } from 'react';
import { NavLink, Outlet, useLocation } from 'react-router-dom';
import { usePlatformSession } from '../auth/AuthGate';
import { preloadRoute, scheduleIdleRoutePreloads } from '../routing/routeModules';
import { preloadRoute, scheduleIdleRoutePreloads, shouldPreloadRouteOnIntent } from '../routing/routeModules';
const navigation = [
{ to: '/monitor', label: '全局监控', icon: IconHome },
@@ -65,7 +65,7 @@ export function AppShell() {
function Sidebar() {
const [collapsed, setCollapsed] = useState(false);
const warmRoute = (path: string) => { void preloadRoute(path); };
const warmRoute = (path: string) => { if (shouldPreloadRouteOnIntent()) void preloadRoute(path); };
return (
<aside className={`v2-sidebar${collapsed ? ' is-collapsed' : ''}`}>