File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change 11<script setup lang="ts">
2- import type { RouteLocationRaw , RouteRecordNameGeneric } from ' vue-router'
2+ import type { RouteRecordNameGeneric } from ' vue-router'
33import { onBeforeRouteUpdate } from ' vue-router'
44
55const { logout } = useStore (' user' )
Original file line number Diff line number Diff line change 11<script lang="ts" setup>
22const { tabs } = useStore (' app' )
3+
4+ const router = useRouter ()
5+ const routes = router .getRoutes ()
6+ const needCacheRouteNames = routes
7+ .filter ((item ) => item .meta && ! item .meta .notCache )
8+ .map ((item ) => item .name )
9+
10+ const cacheList = computed (() => {
11+ const arr = tabs .value
12+ .map ((item ) => item .name )
13+ .filter ((item ) => needCacheRouteNames .includes (item ))
14+ return arr
15+ })
316 </script >
417
518<template >
@@ -14,7 +27,7 @@ const { tabs } = useStore('app')
1427 <el-main >
1528 <router-view v-slot =" { Component, route }" >
1629 <transition name =" fade-transform" mode =" out-in" >
17- <keep-alive :include =" tabs.map((i) => i.name) " >
30+ <keep-alive :include =" cacheList " >
1831 <component :is =" Component" :key =" route.name" />
1932 </keep-alive >
2033 </transition >
You can’t perform that action at this time.
0 commit comments