mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-07-21 12:33:28 +08:00
refactor: optimize Keep-Alive component rendering and data synchronization by introducing silent refresh states and fallback layout calculations.
This commit is contained in:
@@ -2,13 +2,16 @@
|
||||
import DefaultLayout from './components/DefaultLayout.vue'
|
||||
|
||||
const route = useRoute()
|
||||
|
||||
// keep-alive 缓存按页面身份命中,避免 query 变化导致同一页面反复新建实例。
|
||||
const routeCacheKey = computed(() => route.meta.keepAliveKey?.toString() || route.path)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<DefaultLayout>
|
||||
<router-view v-slot="{ Component }">
|
||||
<keep-alive :max="12">
|
||||
<component :is="Component" v-if="route.meta.keepAlive" :key="route.fullPath" />
|
||||
<keep-alive :max="24">
|
||||
<component :is="Component" v-if="route.meta.keepAlive" :key="routeCacheKey" />
|
||||
</keep-alive>
|
||||
<component :is="Component" v-if="!route.meta.keepAlive" :key="route.fullPath" />
|
||||
</router-view>
|
||||
|
||||
Reference in New Issue
Block a user