Blame view

src/router/types.ts 1.13 KB
Vben authored
1
import type { RouteRecordRaw, RouteMeta } from 'vue-router';
陈文彬 authored
2
import { RoleEnum } from '/@/enums/roleEnum';
vben authored
3
4
import { defineComponent } from 'vue';
vben authored
5
export type Component<T = any> =
vben authored
6
7
8
  | ReturnType<typeof defineComponent>
  | (() => Promise<typeof import('*.vue')>)
  | (() => Promise<T>);
9
10

// @ts-ignore
陈文彬 authored
11
export interface AppRouteRecordRaw extends Omit<RouteRecordRaw, 'meta'> {
12
  name: string;
陈文彬 authored
13
  meta: RouteMeta;
14
  component?: Component | string;
vben authored
15
  components?: Component;
陈文彬 authored
16
  children?: AppRouteRecordRaw[];
vben authored
17
  props?: Recordable;
vben authored
18
  fullPath?: string;
陈文彬 authored
19
}
Vben authored
20
21
22
23
24
25
export interface MenuTag {
  type?: 'primary' | 'error' | 'warn' | 'success';
  content?: string;
  dot?: boolean;
}
陈文彬 authored
26
27
28
29
30
31
32
33

export interface Menu {
  name: string;

  icon?: string;

  path: string;
34
35
36
  // path contains param, auto assignment.
  paramPath?: string;
陈文彬 authored
37
38
39
40
41
42
43
44
45
  disabled?: boolean;

  children?: Menu[];

  orderNo?: number;

  roles?: RoleEnum[];

  meta?: Partial<RouteMeta>;
46
47

  tag?: MenuTag;
48
49

  hideMenu?: boolean;
陈文彬 authored
50
}
51
陈文彬 authored
52
53
54
55
56
export interface MenuModule {
  orderNo?: number;
  menu: Menu;
}
vben authored
57
58
// export type AppRouteModule = RouteModule | AppRouteRecordRaw;
export type AppRouteModule = AppRouteRecordRaw;