vben
2020-12-04 f4621cc66411d8ff4ca852b548a79cd3da9be1ce
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
<!--
 * @Description: The reason is that tsx will report warnings under multi-level nesting.
-->
<template>
  <div>
    <router-view>
      <template v-slot="{ Component, route }">
        <keep-alive v-if="openCache" :include="getCaches">
          <component :is="Component" :key="route.fullPath" />
        </keep-alive>
        <component v-else :is="Component" :key="route.fullPath" />
      </template>
    </router-view>
  </div>
</template>
<script lang="ts">
  import { computed, defineComponent, unref } from 'vue';
 
  import { useRootSetting } from '/@/hooks/setting/useRootSetting';
  import { useMultipleTabSetting } from '/@/hooks/setting/useMultipleTabSetting';
 
  import { useTransitionSetting } from '/@/hooks/setting/useTransitionSetting';
  import { useCache } from './useCache';
 
  export default defineComponent({
    setup() {
      const { getCaches } = useCache(false);
 
      const { getShowMultipleTab } = useMultipleTabSetting();
 
      const { getOpenKeepAlive } = useRootSetting();
 
      const { getBasicTransition, getEnableTransition } = useTransitionSetting();
 
      const openCache = computed(() => unref(getOpenKeepAlive) && unref(getShowMultipleTab));
 
      return {
        getCaches,
        getBasicTransition,
        openCache,
        getEnableTransition,
      };
    },
  });
</script>