perf: 优化管理端生产加载体验
- 图标与重型组件按需加载,优化菜单预取和页面请求链路 - 开启 gzip 与静态缓存并修复子路由 KeepAlive 冲突
This commit is contained in:
31
easyflow-ui-admin/app/src/router/route-cache-safety.ts
Normal file
31
easyflow-ui-admin/app/src/router/route-cache-safety.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import type { RouteRecordStringComponent } from '@easyflow/types';
|
||||
|
||||
const UNSAFE_KEEP_ALIVE_MENU_PATHS = new Set([
|
||||
'/ai/agents',
|
||||
'/ai/documentCollection',
|
||||
'/ai/model',
|
||||
'/ai/skill',
|
||||
'/ai/workflow',
|
||||
'/dashboard/workspace',
|
||||
'/sys/sysAccount',
|
||||
]);
|
||||
|
||||
/**
|
||||
* Disable route-level caching that conflicts with independent hidden child
|
||||
* routes. Assigning false also replaces stale true values in persisted tabs.
|
||||
*/
|
||||
function disableUnsafeMenuRouteCaching(
|
||||
routes: RouteRecordStringComponent[],
|
||||
): RouteRecordStringComponent[] {
|
||||
for (const route of routes) {
|
||||
if (UNSAFE_KEEP_ALIVE_MENU_PATHS.has(route.path) && route.meta) {
|
||||
route.meta.keepAlive = false;
|
||||
}
|
||||
if (route.children?.length) {
|
||||
disableUnsafeMenuRouteCaching(route.children);
|
||||
}
|
||||
}
|
||||
return routes;
|
||||
}
|
||||
|
||||
export { disableUnsafeMenuRouteCaching };
|
||||
Reference in New Issue
Block a user