index.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <template>
  2. <RouterView>
  3. <template #default="{ Component, route }">
  4. <transition
  5. :name="
  6. getTransitionName({
  7. route,
  8. openCache,
  9. enableTransition: getEnableTransition,
  10. cacheTabs: getCaches,
  11. def: getBasicTransition,
  12. })
  13. "
  14. mode="out-in"
  15. appear
  16. >
  17. <keep-alive v-if="openCache" :include="getCaches">
  18. <component :is="Component" :key="route.fullPath" />
  19. </keep-alive>
  20. <component v-else :is="Component" :key="route.fullPath" />
  21. </transition>
  22. </template>
  23. </RouterView>
  24. <FrameLayout v-if="getCanEmbedIFramePage" />
  25. </template>
  26. <script lang="ts" setup>
  27. import { computed, unref } from 'vue';
  28. import FrameLayout from '@/layouts/iframe/index.vue';
  29. import { useRootSetting } from '@/hooks/setting/useRootSetting';
  30. import { useTransitionSetting } from '@/hooks/setting/useTransitionSetting';
  31. import { useMultipleTabSetting } from '@/hooks/setting/useMultipleTabSetting';
  32. import { getTransitionName } from './transition';
  33. import { useMultipleTabStore } from '@/store/modules/multipleTab';
  34. defineOptions({ name: 'PageLayout' });
  35. const { getShowMultipleTab } = useMultipleTabSetting();
  36. const tabStore = useMultipleTabStore();
  37. const { getOpenKeepAlive, getCanEmbedIFramePage } = useRootSetting();
  38. const { getBasicTransition, getEnableTransition } = useTransitionSetting();
  39. const openCache = computed(() => unref(getOpenKeepAlive) && unref(getShowMultipleTab));
  40. const getCaches = computed((): string[] => {
  41. if (!unref(getOpenKeepAlive)) {
  42. return [];
  43. }
  44. return tabStore.getCachedTabList;
  45. });
  46. </script>