index.vue 2.1 KB

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