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

96 lines
1.8 KiB
TypeScript
Raw Normal View History

2020-09-28 20:19:10 +08:00
import type { RouteRecordRaw } from 'vue-router';
import { RoleEnum } from '/@/enums/roleEnum';
2021-02-22 00:01:03 +08:00
import { defineComponent } from 'vue';
export type Component<T extends any = any> =
| ReturnType<typeof defineComponent>
| (() => Promise<typeof import('*.vue')>)
| (() => Promise<T>);
2020-09-28 20:19:10 +08:00
export interface RouteMeta {
// title
title: string;
// Whether to ignore permissions
ignoreAuth?: boolean;
// role info
roles?: RoleEnum[];
// Whether not to cache
ignoreKeepAlive?: boolean;
// Is it fixed on tab
affix?: boolean;
// icon on tab
icon?: string;
2020-12-21 22:20:01 +08:00
frameSrc?: string;
2020-09-28 20:19:10 +08:00
// current page transition
transitionName?: string;
// Whether the route has been dynamically added
hideBreadcrumb?: boolean;
2020-10-14 22:08:56 +08:00
// Carrying parameters
carryParam?: boolean;
2020-12-03 21:49:32 +08:00
2020-12-07 23:56:57 +08:00
// Used internally to mark single-level menus
2020-12-03 21:49:32 +08:00
single?: boolean;
// Currently active menu
currentActiveMenu?: string;
// Never show in tab
hideTab?: boolean;
// Never show in menu
hideMenu?: boolean;
isLink?: boolean;
2020-09-28 20:19:10 +08:00
}
// @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
}
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;
path: string;
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;