@@ -153,7 +153,7 @@ function setupKeepAlive(router: Router) {
const keepAliveStore = useKeepAliveStore()
// 判断当前页面是否开启缓存,如果开启,则将当前页面的 name 信息存入 keep-alive 全局状态
if (to.meta.cache) {
- const componentName = to.matched.at(-1)?.components?.default.name
+ const componentName = to.matched.at(-1)?.path.split('/').pop()
if (componentName) {
keepAliveStore.add(componentName)
}
@@ -180,9 +180,10 @@ function formatBackRoutes(routes: any, views = import.meta.glob('../../views/**/
case 'Layout':
route.component = () => import('@/layouts/index.vue')
break
- default:
- if (route.component) {
+ default:
+ if (route.component) {
route.component = views[`../../views${route.component}.vue`]
+ if(route.keepAlive==='1') route.cache=true
if (route.menu ==0) {
route.menu = false;