diff --git a/src/layouts/default.vue b/src/layouts/default.vue index 22c4d207..c1c9d93f 100644 --- a/src/layouts/default.vue +++ b/src/layouts/default.vue @@ -4,7 +4,14 @@ import DefaultLayout from './default/components/DefaultLayout.vue' const route = useRoute() // keep-alive 缓存按页面身份命中,避免 query 变化导致同一页面反复新建实例。 -const routeCacheKey = computed(() => route.meta.keepAliveKey?.toString() || route.path) +const routeCacheKey = computed(() => { + if (route.meta.keepAliveKey) return route.meta.keepAliveKey.toString() + + // 部分列表页的 query 会参与接口参数,缓存 key 需要保留完整路由避免串用旧数据。 + if (route.meta.keepAliveByFullPath) return route.fullPath + + return route.path +}) // 页面过渡按实际页面身份触发;keep-alive 页面避免 query 变化时反复入场。 const routeTransitionKey = computed(() => (route.meta.keepAlive ? routeCacheKey.value : route.fullPath)) diff --git a/src/router/index.ts b/src/router/index.ts index 8494b6c8..ede7cf40 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -189,6 +189,8 @@ const router = createRouter({ component: () => import('../pages/browse.vue'), props: true, meta: { + keepAlive: true, + keepAliveByFullPath: true, requiresAuth: true, permission: 'discovery', },