perf(admin): 实现切页即时导航与列表 loading 壳

非阻塞 session 刷新、侧边栏 chunk 预取、KeepAlive 对齐,以及按 tab 延迟加载重型列表页。
This commit is contained in:
2026-06-18 16:45:01 +08:00
parent ca482b1916
commit 8da730762b
21 changed files with 321 additions and 117 deletions

View File

@@ -0,0 +1,25 @@
import type { Router } from 'vue-router';
const prefetchedPaths = new Set<string>();
/** 预取目标路径上所有 lazy route 的 JS chunk侧边栏 hover/focus 时调用)。 */
export function prefetchRouteChunks(router: Router, path: string) {
const key = path.split('?')[0] || '/';
if (prefetchedPaths.has(key)) return;
let matched = false;
try {
const resolved = router.resolve(path);
for (const record of resolved.matched) {
const loader = record.components?.default;
if (typeof loader === 'function') {
matched = true;
void (loader as () => Promise<unknown>)();
}
}
} catch {
return;
}
if (matched) prefetchedPaths.add(key);
}