@@ -31,16 +31,35 @@ const key = computed(() => route.path)
3131// leaveRmCachePage: is true, keep-alive remote when page leave
3232let oldRoute: rawConfig = {}
3333let deepOldRouter: RouteLocationMatched | null = null
34+ let cacheGroup: any = []
3435const basicStore = useBasicStore ()
3536const removeDeepChildren = (deepOldRouter ) => {
3637 deepOldRouter .children ?.forEach ((fItem ) => {
37- basicStore .setCacheViewDeep (fItem .name )
38+ basicStore .delCacheViewDeep (fItem .name )
3839 })
3940}
4041watch (
4142 () => route .name ,
4243 () => {
4344 const routerLevel = route .matched .length
45+
46+ // 缓存组处理
47+ // first judge cacheGroup and then remove
48+ if (cacheGroup .length ) {
49+ if (! cacheGroup .includes (route .name )) {
50+ cacheGroup .forEach ((item ) => {
51+ basicStore .delCachedView (item )
52+ })
53+ }
54+ }
55+ // and then cache the current router config page
56+ if (route .meta ?.cacheGroup ) {
57+ cacheGroup = route .meta ?.cacheGroup || []
58+ cacheGroup .forEach ((fItem ) => {
59+ basicStore .addCachedView (fItem )
60+ })
61+ }
62+
4463 // 二级路由处理
4564 if (routerLevel === 2 ) {
4665 if (deepOldRouter ?.name ) {
@@ -81,7 +100,7 @@ watch(
81100 // 否则走正常两级路由处理流程
82101 if (oldRoute ?.name ) {
83102 if (oldRoute .meta ?.leaveRmCachePage && oldRoute .meta ?.cachePage ) {
84- basicStore .setCacheViewDeep (oldRoute .name )
103+ basicStore .delCacheViewDeep (oldRoute .name )
85104 }
86105 }
87106 }
0 commit comments