vue-vben-admin/src/router/types.ts

61 lines
1.1 KiB
TypeScript
Raw Normal View History

2021-06-19 22:38:29 +08:00
import type { RouteRecordRaw, RouteMeta } from 'vue-router';
2020-09-28 20:19:10 +08:00
import { RoleEnum } from '/@/enums/roleEnum';
2021-02-22 00:01:03 +08:00
import { defineComponent } from 'vue';
2021-10-25 23:49:03 +08:00
export type Component<T = any> =
2021-02-22 00:01:03 +08:00
| ReturnType<typeof defineComponent>
| (() => Promise<typeof import('*.vue')>)
| (() => Promise<T>);
// @ts-ignore
2020-09-28 20:19:10 +08:00
export interface AppRouteRecordRaw extends Omit<RouteRecordRaw, 'meta'> {
2020-11-12 23:15:11 +08:00
name: string;
2020-09-28 20:19:10 +08:00
meta: RouteMeta;
component?: Component | string;
2020-12-03 21:49:32 +08:00
components?: Component;
2020-09-28 20:19:10 +08:00
children?: AppRouteRecordRaw[];
2020-12-25 01:09:44 +08:00
props?: Recordable;
2020-10-14 21:08:07 +08:00
fullPath?: string;
2020-09-28 20:19:10 +08:00
}
2021-06-19 22:38:29 +08:00
2020-11-10 23:16:42 +08:00
export interface MenuTag {
type?: 'primary' | 'error' | 'warn' | 'success';
content?: string;
dot?: boolean;
}
2020-09-28 20:19:10 +08:00
export interface Menu {
name: string;
icon?: string;
img?: string;
2020-09-28 20:19:10 +08:00
path: string;
// path contains param, auto assignment.
paramPath?: string;
2020-09-28 20:19:10 +08:00
disabled?: boolean;
children?: Menu[];
orderNo?: number;
roles?: RoleEnum[];
meta?: Partial<RouteMeta>;
2020-11-10 23:16:42 +08:00
tag?: MenuTag;
hideMenu?: boolean;
2020-09-28 20:19:10 +08:00
}
2020-11-21 22:47:10 +08:00
2020-09-28 20:19:10 +08:00
export interface MenuModule {
orderNo?: number;
menu: Menu;
}
2020-12-03 21:49:32 +08:00
// export type AppRouteModule = RouteModule | AppRouteRecordRaw;
export type AppRouteModule = AppRouteRecordRaw;