fix(web): retry rejected route modules

This commit is contained in:
lingniu
2026-07-16 07:01:34 +08:00
parent ec3071d59b
commit fa886abff9
4 changed files with 61 additions and 25 deletions

View File

@@ -82,6 +82,10 @@ function loadRoute(section: RouteSection) {
return next;
}
export function createRouteComponent(section: RouteSection) {
return lazy(() => loadRoute(section));
}
export function routeSectionForPath(pathname: string): RouteSection | undefined {
const section = pathname.split('?')[0].split('#')[0].split('/').filter(Boolean)[0] as RouteSection | undefined;
return section && section in importers ? section : undefined;
@@ -184,12 +188,23 @@ export function scheduleIdleRoutePreloads({
}
export const RoutePages = {
Monitor: lazy(() => loadRoute('monitor')),
Vehicles: lazy(() => loadRoute('vehicles')),
Tracks: lazy(() => loadRoute('tracks')),
History: lazy(() => loadRoute('history')),
Statistics: lazy(() => loadRoute('statistics')),
Access: lazy(() => loadRoute('access')),
Alerts: lazy(() => loadRoute('alerts')),
Operations: lazy(() => loadRoute('operations'))
Monitor: createRouteComponent('monitor'),
Vehicles: createRouteComponent('vehicles'),
Tracks: createRouteComponent('tracks'),
History: createRouteComponent('history'),
Statistics: createRouteComponent('statistics'),
Access: createRouteComponent('access'),
Alerts: createRouteComponent('alerts'),
Operations: createRouteComponent('operations')
} as const;
export const RoutePageFactories = {
Monitor: () => createRouteComponent('monitor'),
Vehicles: () => createRouteComponent('vehicles'),
Tracks: () => createRouteComponent('tracks'),
History: () => createRouteComponent('history'),
Statistics: () => createRouteComponent('statistics'),
Access: () => createRouteComponent('access'),
Alerts: () => createRouteComponent('alerts'),
Operations: () => createRouteComponent('operations')
} as const;