@@ -5,6 +5,7 @@ import type {
5
5
RouteLocationNormalizedLoadedGeneric ,
6
6
} from ' vue-router' ;
7
7
8
+ import { computed } from ' vue' ;
8
9
import { RouterView } from ' vue-router' ;
9
10
10
11
import { preferences , usePreferences } from ' @vben/preferences' ;
@@ -20,6 +21,15 @@ const { keepAlive } = usePreferences();
20
21
const { getCachedTabs, getExcludeCachedTabs, renderRouteView } =
21
22
storeToRefs (tabbarStore );
22
23
24
+ /**
25
+ * 是否使用动画
26
+ */
27
+ const getEnabledTransition = computed (() => {
28
+ const { transition } = preferences ;
29
+ const transitionName = transition .name ;
30
+ return transitionName && transition .enable ;
31
+ });
32
+
23
33
// 页面切换动画
24
34
function getTransitionName(_route : RouteLocationNormalizedLoaded ) {
25
35
// 如果偏好设置未设置,则不使用动画
@@ -90,7 +100,12 @@ function transformComponent(
90
100
<div class =" relative h-full" >
91
101
<IFrameRouterView />
92
102
<RouterView v-slot =" { Component, route }" >
93
- <Transition :name =" getTransitionName(route)" appear mode =" out-in" >
103
+ <Transition
104
+ v-if =" getEnabledTransition"
105
+ :name =" getTransitionName(route)"
106
+ appear
107
+ mode =" out-in"
108
+ >
94
109
<KeepAlive
95
110
v-if =" keepAlive"
96
111
:exclude =" getExcludeCachedTabs"
@@ -109,6 +124,25 @@ function transformComponent(
109
124
:key =" route.fullPath"
110
125
/>
111
126
</Transition >
127
+ <template v-else >
128
+ <KeepAlive
129
+ v-if =" keepAlive"
130
+ :exclude =" getExcludeCachedTabs"
131
+ :include =" getCachedTabs"
132
+ >
133
+ <component
134
+ :is =" transformComponent(Component, route)"
135
+ v-if =" renderRouteView"
136
+ v-show =" !route.meta.iframeSrc"
137
+ :key =" route.fullPath"
138
+ />
139
+ </KeepAlive >
140
+ <component
141
+ :is =" Component"
142
+ v-else-if =" renderRouteView"
143
+ :key =" route.fullPath"
144
+ />
145
+ </template >
112
146
</RouterView >
113
147
</div >
114
148
</template >
0 commit comments