router.d.ts 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. import type { RouteRecordRaw } from 'vue-router'
  2. import { defineComponent } from 'vue'
  3. /**
  4. * redirect: noredirect 当设置 noredirect 的时候该路由在面包屑导航中不可被点击
  5. * name:'router-name' 设定路由的名字,一定要填写不然使用<keep-alive>时会出现各种问题
  6. * meta : {
  7. hidden: true 当设置 true 的时候该路由不会再侧边栏出现 如404,login等页面(默认 false)
  8. alwaysShow: true 当你一个路由下面的 children 声明的路由大于1个时,自动会变成嵌套的模式,
  9. 只有一个时,会将那个子路由当做根路由显示在侧边栏,
  10. 若你想不管路由下面的 children 声明的个数都显示你的根路由,
  11. 你可以设置 alwaysShow: true,这样它就会忽略之前定义的规则,
  12. 一直显示根路由(默认 false)
  13. title: 'title' 设置该路由在侧边栏和面包屑中展示的名字
  14. titleSuffix: '2' 当 path 和 title 重复时的后缀或备注
  15. icon: 'svg-name' 设置该路由的图标
  16. noCache: true 如果设置为true,则不会被 <keep-alive> 缓存(默认 false)
  17. viewKey: 'view-name' 设置稳定的页面实例标识,路由地址变化时复用同一个组件实例
  18. breadcrumb: false 如果设置为false,则不会在breadcrumb面包屑中显示(默认 true)
  19. affix: true 如果设置为true,则会一直固定在tag项中(默认 false)
  20. noTagsView: true 如果设置为true,则不会出现在tag中(默认 false)
  21. activeMenu: '/home' 显示高亮的路由路径
  22. followAuth: '/home' 跟随哪个路由进行权限过滤
  23. canTo: true 设置为true即使hidden为true,也依然可以进行路由跳转(默认 false)
  24. }
  25. **/
  26. declare module 'vue-router' {
  27. interface RouteMeta extends Record<string | number | symbol, unknown> {
  28. hidden?: boolean
  29. alwaysShow?: boolean
  30. title?: string
  31. titleSuffix?: string
  32. icon?: string
  33. noCache?: boolean
  34. viewKey?: string
  35. breadcrumb?: boolean
  36. affix?: boolean
  37. activeMenu?: string
  38. noTagsView?: boolean
  39. followAuth?: string
  40. canTo?: boolean
  41. hash?: string
  42. iframeSrc?: string
  43. link?: string
  44. params?: Recordable
  45. query?: Recordable
  46. }
  47. }
  48. type Component<T = any> =
  49. | ReturnType<typeof defineComponent>
  50. | (() => Promise<typeof import('*.vue')>)
  51. | (() => Promise<T>)
  52. declare global {
  53. interface AppRouteRecordRaw extends Omit<RouteRecordRaw, 'meta'> {
  54. name: string
  55. meta: RouteMeta
  56. component?: Component | string
  57. children?: AppRouteRecordRaw[]
  58. props?: Recordable
  59. fullPath?: string
  60. keepAlive?: boolean
  61. }
  62. interface AppCustomRouteRecordRaw extends Omit<RouteRecordRaw, 'meta'> {
  63. icon: any
  64. name: string
  65. meta: RouteMeta
  66. component: string
  67. componentName?: string
  68. id?: number | string
  69. path: string
  70. redirect: string
  71. children?: AppCustomRouteRecordRaw[]
  72. keepAlive?: boolean
  73. visible?: boolean
  74. parentId?: number
  75. alwaysShow?: boolean
  76. }
  77. }