Blame view

src/layouts/page/index.vue 2.03 KB
vben authored
1
<template>
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
  <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">
18
          <component :is="Component" :key="route.fullPath" />
19
        </keep-alive>
20
21
22
        <div v-else :key="route.name">
          <component :is="Component" :key="route.fullPath" />
        </div>
23
24
25
26
      </transition>
    </template>
  </RouterView>
  <FrameLayout v-if="getCanEmbedIFramePage" />
vben authored
27
28
29
30
31
32
33
34
35
36
37
38
39
</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';
Vben authored
40
  import { useMultipleTabStore } from '/@/store/modules/multipleTab';
41
vben authored
42
43
44
45
46
  export default defineComponent({
    name: 'PageLayout',
    components: { FrameLayout },
    setup() {
      const { getShowMultipleTab } = useMultipleTabSetting();
Vben authored
47
      const tabStore = useMultipleTabStore();
vben authored
48
49
50
51
52
53
54

      const { getOpenKeepAlive, getCanEmbedIFramePage } = useRootSetting();

      const { getBasicTransition, getEnableTransition } = useTransitionSetting();

      const openCache = computed(() => unref(getOpenKeepAlive) && unref(getShowMultipleTab));
55
56
57
58
      const getCaches = computed((): string[] => {
        if (!unref(getOpenKeepAlive)) {
          return [];
        }
Vben authored
59
        return tabStore.getCachedTabList;
60
61
      });
vben authored
62
63
64
65
66
67
68
69
70
71
72
      return {
        getTransitionName,
        openCache,
        getEnableTransition,
        getBasicTransition,
        getCaches,
        getCanEmbedIFramePage,
      };
    },
  });
</script>