vben
authored
|
1
2
3
4
5
|
<!--
* @Description: The reason is that tsx will report warnings under multi-level nesting.
-->
<template>
<div>
|
vben
authored
|
6
|
<RouterView>
|
vben
authored
|
7
|
<template #default="{ Component, route }">
|
vben
authored
|
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
<transition
:name="
getTransitionName({
route,
openCache: openCache,
enableTransition: getEnableTransition,
cacheTabs: getCaches,
def: getBasicTransition,
})
"
mode="out-in"
appear
>
<keep-alive v-if="openCache" :include="getCaches">
|
vben
authored
|
22
|
<component :is="Component" v-bind="getKey(Component, route)" />
|
vben
authored
|
23
|
</keep-alive>
|
vben
authored
|
24
|
<component v-else :is="Component" v-bind="getKey(Component, route)" />
|
vben
authored
|
25
|
</transition>
|
vben
authored
|
26
|
</template>
|
vben
authored
|
27
|
</RouterView>
|
vben
authored
|
28
29
30
31
32
33
34
35
36
|
</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';
|
vben
authored
|
37
|
import { useCache, getKey } from './useCache';
|
vben
authored
|
38
|
import { getTransitionName } from './transition';
|
vben
authored
|
39
40
|
export default defineComponent({
|
vben
authored
|
41
|
parentView: true,
|
vben
authored
|
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
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,
|
vben
authored
|
58
|
getTransitionName,
|
vben
authored
|
59
|
getKey,
|
vben
authored
|
60
61
62
63
|
};
},
});
</script>
|