33 lines
857 B
TypeScript
33 lines
857 B
TypeScript
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/approval',
|
|
'/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 };
|