vben
2021-02-17 4d7001bbcf3ff6e62deb967cb1c15b443b8aaff4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<template>
  <div>
    <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">
            <component :is="Component" v-bind="getKey(Component, route)" />
          </keep-alive>
          <component v-else :is="Component" v-bind="getKey(Component, route)" />
        </transition>
      </template>
    </RouterView>
    <FrameLayout v-if="getCanEmbedIFramePage" />
  </div>
</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 { useCache, getKey } from './useCache';
  import { useMultipleTabSetting } from '/@/hooks/setting/useMultipleTabSetting';
  import { getTransitionName } from './transition';
 
  export default defineComponent({
    name: 'PageLayout',
    components: { FrameLayout },
    setup() {
      const { getCaches } = useCache(true);
      const { getShowMultipleTab } = useMultipleTabSetting();
 
      const { getOpenKeepAlive, getCanEmbedIFramePage } = useRootSetting();
 
      const { getBasicTransition, getEnableTransition } = useTransitionSetting();
 
      const openCache = computed(() => unref(getOpenKeepAlive) && unref(getShowMultipleTab));
 
      return {
        getTransitionName,
        openCache,
        getEnableTransition,
        getBasicTransition,
        getCaches,
        getCanEmbedIFramePage,
        getKey,
      };
    },
  });
</script>