Blame view

src/layouts/page/transition.ts 783 Bytes
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 };
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
  route: RouteLocation;
}

export function getTransitionName({
  route,
  openCache,
  cacheTabs,
  enableTransition,
  def,
}: Pick<DefaultContext, 'route'> & {
  enableTransition: boolean;
  openCache: boolean;
  def: string;
  cacheTabs: string[];
}) {
21
22
23
24
  if (!enableTransition) {
    return null;
  }
25
26
27
28
29
  const isInCache = cacheTabs.includes(route.name as string);
  const transitionName = 'fade-slide';
  let name: string | null = transitionName;

  if (openCache) {
30
    name = isInCache && route.meta.loaded ? transitionName : null;
31
32
33
  }
  return name || route.meta.transitionName || def;
}