vue-vben-admin/src/layouts/page/index.vue

71 lines
2.0 KiB
Vue
Raw Normal View History

2021-01-09 23:28:52 +08:00
<template>
<RouterView>
<template #default="{ Component, route }">
<transition
:name="
getTransitionName({
route,
openCache,
enableTransition: getEnableTransition,
cacheTabs: getCaches,
def: getBasicTransition,
})
"
mode="out-in"
appear
>
<keep-alive v-if="openCache" :include="getCaches">
<component :is="Component" :key="route.fullPath" />
</keep-alive>
<component v-else :is="Component" :key="route.fullPath" />
</transition>
</template>
</RouterView>
<FrameLayout v-if="getCanEmbedIFramePage" />
2021-01-09 23:28:52 +08:00
</template>
<script lang="ts">
import { computed, defineComponent, unref } from 'vue';
import FrameLayout from '/@/layouts/iframe/index.vue';
import { useRootSetting } from '/@/hooks/setting/useRootSetting';
import { useTransitionSetting } from '/@/hooks/setting/useTransitionSetting';
import { useMultipleTabSetting } from '/@/hooks/setting/useMultipleTabSetting';
import { getTransitionName } from './transition';
2021-04-10 19:25:49 +08:00
import { useMultipleTabStore } from '/@/store/modules/multipleTab';
2021-01-09 23:28:52 +08:00
export default defineComponent({
name: 'PageLayout',
components: { FrameLayout },
setup() {
const { getShowMultipleTab } = useMultipleTabSetting();
2021-04-10 19:25:49 +08:00
const tabStore = useMultipleTabStore();
2021-01-09 23:28:52 +08:00
const { getOpenKeepAlive, getCanEmbedIFramePage } = useRootSetting();
const { getBasicTransition, getEnableTransition } = useTransitionSetting();
const openCache = computed(() => unref(getOpenKeepAlive) && unref(getShowMultipleTab));
const getCaches = computed((): string[] => {
if (!unref(getOpenKeepAlive)) {
return [];
}
2021-04-10 19:25:49 +08:00
return tabStore.getCachedTabList;
});
2021-01-09 23:28:52 +08:00
return {
getTransitionName,
openCache,
getEnableTransition,
getBasicTransition,
getCaches,
getCanEmbedIFramePage,
};
},
});
</script>