types.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import type { RouteRecordRaw, RouteMeta } from 'vue-router';
  2. import { RoleEnum } from '@/enums/roleEnum';
  3. import { defineComponent } from 'vue';
  4. export type Component<T = any> =
  5. | ReturnType<typeof defineComponent>
  6. | (() => Promise<typeof import('*.vue')>)
  7. | (() => Promise<T>);
  8. // @ts-ignore
  9. export interface AppRouteRecordRaw extends Omit<RouteRecordRaw, 'meta'> {
  10. name: string;
  11. meta: RouteMeta;
  12. component?: Component | string;
  13. components?: Component;
  14. children?: AppRouteRecordRaw[];
  15. props?: Recordable;
  16. fullPath?: string;
  17. ver?: string;
  18. }
  19. export interface MenuTag {
  20. type?: 'primary' | 'error' | 'warn' | 'success';
  21. content?: string;
  22. dot?: boolean;
  23. }
  24. export interface Menu {
  25. name: string;
  26. icon?: string;
  27. img?: string;
  28. path: string;
  29. // path contains param, auto assignment.
  30. paramPath?: string;
  31. disabled?: boolean;
  32. children?: Menu[];
  33. orderNo?: number;
  34. roles?: RoleEnum[];
  35. meta?: Partial<RouteMeta>;
  36. tag?: MenuTag;
  37. hideMenu?: boolean;
  38. }
  39. export interface MenuModule {
  40. orderNo?: number;
  41. menu: Menu;
  42. }
  43. // export type AppRouteModule = RouteModule | AppRouteRecordRaw;
  44. export type AppRouteModule = AppRouteRecordRaw;