perf/route (#54)

* perf: router

* perf: route
This commit is contained in:
啝裳
2021-10-12 23:33:13 +08:00
committed by GitHub
parent 0408fa6f96
commit a31d154806
18 changed files with 257 additions and 38 deletions

View File

@@ -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" />