index.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. <SmartPageProvider>
  19. <component :is="Component" :key="route.fullPath" />
  20. </SmartPageProvider>
  21. </keep-alive>
  22. <component v-else :is="Component" :key="route.fullPath" />
  23. </transition>
  24. </template>
  25. </RouterView>
  26. <FrameLayout v-if="getCanEmbedIFramePage" />
  27. </template>
  28. <script lang="ts" setup>
  29. import { computed, unref } from 'vue';
  30. import FrameLayout from '@/layouts/iframe/index.vue';
  31. import { useRootSetting } from '@/hooks/setting/useRootSetting';
  32. import { useTransitionSetting } from '@/hooks/setting/useTransitionSetting';
  33. import { useMultipleTabSetting } from '@/hooks/setting/useMultipleTabSetting';
  34. import { getTransitionName } from './transition';
  35. import { useMultipleTabStore } from '@/store/modules/multipleTab';
  36. import { SmartPageProvider } from '@/components/SmartPageProvider';
  37. defineOptions({ name: 'PageLayout' });
  38. const { getShowMultipleTab } = useMultipleTabSetting();
  39. const tabStore = useMultipleTabStore();
  40. const { getOpenKeepAlive, getCanEmbedIFramePage } = useRootSetting();
  41. const { getBasicTransition, getEnableTransition } = useTransitionSetting();
  42. const openCache = computed(() => unref(getOpenKeepAlive) && unref(getShowMultipleTab));
  43. const getCaches = computed((): string[] => {
  44. if (!unref(getOpenKeepAlive)) {
  45. return [];
  46. }
  47. return tabStore.getCachedTabList;
  48. });
  49. </script>