types.ts 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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> = ReturnType<typeof defineComponent> | (() => Promise<typeof import('*.vue')>) | (() => Promise<T>)
  5. export interface MetaProps {
  6. // 标题
  7. title?: string
  8. // 图标
  9. /**
  10. * 关于icon 描述:
  11. * // 1.来自本地src/assets/icons 的svg: 'icon-[dir]-[name]'
  12. * // 2.le-iconfont svg 链接: 'le-[name]'
  13. * // 3. 匹配不到icon- & le- 默认element
  14. */
  15. icon?: string
  16. // 隐藏菜单
  17. hidden?: boolean
  18. // 是否固定
  19. affix?: boolean
  20. // 不缓存路由
  21. noCache?: boolean
  22. // 当前路由配置添加到 哪个父级: router.addRoute([parentName], route)
  23. // !!! 由于原有tree-list 有当前字段,固目前用接口拿 parentRoute 过来进行替换
  24. parentName?: string
  25. // todo???
  26. activeMenu?: string
  27. // // todo???
  28. // roles?: string[]
  29. [key: string]: any
  30. }
  31. // eslint-disable-next-line
  32. // @ts-ignore
  33. export interface AppRouteRecordRaw extends Omit<RouteRecordRaw, 'meta'> {
  34. name?: string
  35. meta?: MetaProps
  36. component?: Component | string
  37. components?: Component
  38. children?: AppRouteRecordRaw[]
  39. // props?: Recordable
  40. fullPath?: string
  41. }
  42. export interface MenuTag {
  43. type?: 'primary' | 'error' | 'warn' | 'success'
  44. content?: string
  45. dot?: boolean
  46. }
  47. export interface Menu {
  48. name: string
  49. icon?: string
  50. path: string
  51. // path contains param, auto assignment.
  52. paramPath?: string
  53. disabled?: boolean
  54. children?: Menu[]
  55. orderNo?: number
  56. // roles?: RoleEnum[]
  57. meta?: Partial<RouteMeta>
  58. tag?: MenuTag
  59. hideMenu?: boolean
  60. }
  61. export interface MenuModule {
  62. orderNo?: number
  63. menu: Menu
  64. }
  65. // export type AppRouteModule = RouteModule | AppRouteRecordRaw;
  66. export type AppRouteModule = AppRouteRecordRaw