vben
authored
|
1
2
3
4
|
import type { FunctionalComponent } from 'vue';
import type { RouteLocation } from 'vue-router';
export interface DefaultContext {
|
Vben
authored
|
5
|
Component: FunctionalComponent & { type: Recordable };
|
vben
authored
|
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
route: RouteLocation;
}
export function getTransitionName({
route,
openCache,
cacheTabs,
enableTransition,
def,
}: Pick<DefaultContext, 'route'> & {
enableTransition: boolean;
openCache: boolean;
def: string;
cacheTabs: string[];
|
Vben
authored
|
20
|
}): string | undefined {
|
Vben
authored
|
21
|
if (!enableTransition) {
|
Vben
authored
|
22
|
return undefined;
|
Vben
authored
|
23
24
|
}
|
vben
authored
|
25
26
|
const isInCache = cacheTabs.includes(route.name as string);
const transitionName = 'fade-slide';
|
Vben
authored
|
27
|
let name: string | undefined = transitionName;
|
vben
authored
|
28
29
|
if (openCache) {
|
Vben
authored
|
30
|
name = isInCache && route.meta.loaded ? transitionName : undefined;
|
vben
authored
|
31
|
}
|
Vben
authored
|
32
|
return name || (route.meta.transitionName as string) || def;
|
vben
authored
|
33
|
}
|