types.ts 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. import type { RouteRecordRaw } from 'vue-router';
  2. import { RoleEnum } from '/@/enums/roleEnum';
  3. import { defineComponent } from 'vue';
  4. export type Component<T extends any = any> =
  5. | ReturnType<typeof defineComponent>
  6. | (() => Promise<typeof import('*.vue')>)
  7. | (() => Promise<T>);
  8. export interface RouteMeta {
  9. // title
  10. title: string;
  11. // Whether to ignore permissions
  12. ignoreAuth?: boolean;
  13. // role info
  14. roles?: RoleEnum[];
  15. // Whether not to cache
  16. ignoreKeepAlive?: boolean;
  17. // Is it fixed on tab
  18. affix?: boolean;
  19. // icon on tab
  20. icon?: string;
  21. frameSrc?: string;
  22. // current page transition
  23. transitionName?: string;
  24. // Whether the route has been dynamically added
  25. hideBreadcrumb?: boolean;
  26. // Carrying parameters
  27. carryParam?: boolean;
  28. // Used internally to mark single-level menus
  29. single?: boolean;
  30. // Currently active menu
  31. currentActiveMenu?: string;
  32. // Never show in tab
  33. hideTab?: boolean;
  34. // Never show in menu
  35. hideMenu?: boolean;
  36. isLink?: boolean;
  37. }
  38. // @ts-ignore
  39. export interface AppRouteRecordRaw extends Omit<RouteRecordRaw, 'meta'> {
  40. name: string;
  41. meta: RouteMeta;
  42. component?: Component | string;
  43. components?: Component;
  44. children?: AppRouteRecordRaw[];
  45. props?: Recordable;
  46. fullPath?: string;
  47. }
  48. export interface MenuTag {
  49. type?: 'primary' | 'error' | 'warn' | 'success';
  50. content?: string;
  51. dot?: boolean;
  52. }
  53. export interface Menu {
  54. name: string;
  55. icon?: string;
  56. path: string;
  57. disabled?: boolean;
  58. children?: Menu[];
  59. orderNo?: number;
  60. roles?: RoleEnum[];
  61. meta?: Partial<RouteMeta>;
  62. tag?: MenuTag;
  63. hideMenu?: boolean;
  64. }
  65. export interface MenuModule {
  66. orderNo?: number;
  67. menu: Menu;
  68. }
  69. // export type AppRouteModule = RouteModule | AppRouteRecordRaw;
  70. export type AppRouteModule = AppRouteRecordRaw;