mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-11-03 13:44:47 +08:00
@@ -1,17 +1,10 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, unref, computed, getCurrentInstance } from "vue";
|
||||
import { useSettingStoreHook } from "/@/store/modules/settings";
|
||||
import { ref, getCurrentInstance } from "vue";
|
||||
import { usePermissionStoreHook } from "/@/store/modules/permission";
|
||||
|
||||
const keepAlive: Boolean = ref(
|
||||
getCurrentInstance().appContext.config.globalProperties.$config?.KeepAlive
|
||||
);
|
||||
|
||||
const getCachedPageList = computed((): string[] => {
|
||||
if (!unref(keepAlive)) {
|
||||
return [];
|
||||
}
|
||||
return useSettingStoreHook().cachedPageList;
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -19,7 +12,10 @@ const getCachedPageList = computed((): string[] => {
|
||||
<router-view>
|
||||
<template #default="{ Component, route }">
|
||||
<transition appear name="fade-transform" mode="out-in">
|
||||
<keep-alive v-if="keepAlive" :include="getCachedPageList">
|
||||
<keep-alive
|
||||
v-if="keepAlive"
|
||||
:include="usePermissionStoreHook().cachePageList"
|
||||
>
|
||||
<component :is="Component" :key="route.fullPath" />
|
||||
</keep-alive>
|
||||
<component v-else :is="Component" :key="route.fullPath" />
|
||||
|
||||
@@ -12,8 +12,10 @@ import {
|
||||
import { RouteConfigs, relativeStorageType, tagsViewsType } from "../../types";
|
||||
import { emitter } from "/@/utils/mitt";
|
||||
import { templateRef } from "@vueuse/core";
|
||||
import { handleAliveRoute } from "/@/router";
|
||||
import { storageLocal } from "/@/utils/storage";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
import { usePermissionStoreHook } from "/@/store/modules/permission";
|
||||
import { toggleClass, removeClass, hasClass } from "/@/utils/operate";
|
||||
|
||||
import close from "/@/assets/svg/close.svg";
|
||||
@@ -171,6 +173,8 @@ function deleteDynamicTag(obj: any, current: any, tag?: string) {
|
||||
relativeStorage.routesInStorage = routerArrays;
|
||||
}
|
||||
router.push(obj.path);
|
||||
// 删除缓存路由
|
||||
handleAliveRoute(route.matched, "delete");
|
||||
};
|
||||
|
||||
if (tag === "other") {
|
||||
@@ -253,7 +257,9 @@ function onClickDrop(key, item, selectRoute?: RouteConfigs) {
|
||||
// 关闭全部标签页
|
||||
routerArrays.splice(1, routerArrays.length);
|
||||
relativeStorage.routesInStorage = routerArrays;
|
||||
usePermissionStoreHook().clearAllCachePage();
|
||||
router.push("/welcome");
|
||||
|
||||
break;
|
||||
}
|
||||
setTimeout(() => {
|
||||
|
||||
Reference in New Issue
Block a user