index.vue 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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">
  27. import { computed, defineComponent, 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. export default defineComponent({
  35. name: 'PageLayout',
  36. components: { FrameLayout },
  37. setup() {
  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. return {
  50. getTransitionName,
  51. openCache,
  52. getEnableTransition,
  53. getBasicTransition,
  54. getCaches,
  55. getCanEmbedIFramePage,
  56. };
  57. },
  58. });
  59. </script>