doc: 添加路由缓存说明

This commit is contained in:
zhangyh
2025-10-21 11:28:12 +08:00
parent f886ba30a1
commit c179451c49
2 changed files with 12 additions and 4 deletions

View File

@@ -22,18 +22,17 @@ watch(
const routeName = newRoute.name as string
const shouldCache = newRoute.meta?.cache === true
console.log('🔄 路由变化:', { routeName, shouldCache, currentCache: cachedViews.value })
// console.log('🔄 路由变化:', { routeName, shouldCache, currentCache: cachedViews.value })
if (shouldCache && routeName && !cachedViews.value.includes(routeName)) {
// 添加到缓存列表
cachedViews.value.push(routeName)
console.log('✅ 添加到缓存:', routeName)
// console.log('✅ 添加到缓存:', routeName)
} else if (!shouldCache && routeName && cachedViews.value.includes(routeName)) {
// 从缓存列表中移除
const index = cachedViews.value.indexOf(routeName)
if (index > -1) {
cachedViews.value.splice(index, 1)
console.log('❌ 从缓存移除:', routeName)
// console.log('❌ 从缓存移除:', routeName)
}
}
},