perf: 优化管理端生产加载体验
- 图标与重型组件按需加载,优化菜单预取和页面请求链路 - 开启 gzip 与静态缓存并修复子路由 KeepAlive 冲突
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import type { RouteRecordStringComponent } from '@easyflow/types';
|
||||
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
import { disableUnsafeMenuRouteCaching } from '../route-cache-safety';
|
||||
|
||||
function createRoute(
|
||||
path: string,
|
||||
children?: RouteRecordStringComponent[],
|
||||
): RouteRecordStringComponent {
|
||||
return {
|
||||
children,
|
||||
component: '/example/Index',
|
||||
meta: { keepAlive: true, title: path },
|
||||
name: path,
|
||||
path,
|
||||
};
|
||||
}
|
||||
|
||||
describe('route cache safety', () => {
|
||||
it('disables stale keep-alive metadata for affected menus recursively', () => {
|
||||
const knowledgeRoute = createRoute('/ai/documentCollection');
|
||||
const routes = [
|
||||
createRoute('/ai/workflow'),
|
||||
createRoute('/ai', [knowledgeRoute]),
|
||||
];
|
||||
|
||||
expect(disableUnsafeMenuRouteCaching(routes)).toBe(routes);
|
||||
expect(routes[0]?.meta?.keepAlive).toBe(false);
|
||||
expect(knowledgeRoute.meta?.keepAlive).toBe(false);
|
||||
});
|
||||
|
||||
it('does not change unrelated route caching', () => {
|
||||
const unrelatedRoute = createRoute('/example/cached');
|
||||
|
||||
disableUnsafeMenuRouteCaching([unrelatedRoute]);
|
||||
|
||||
expect(unrelatedRoute.meta?.keepAlive).toBe(true);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user