router.d.ts 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. icon: 'svg-name' 设置该路由的图标
  15. noCache: true 如果设置为true,则不会被 <keep-alive> 缓存(默认 false)
  16. breadcrumb: false 如果设置为false,则不会在breadcrumb面包屑中显示(默认 true)
  17. affix: true 如果设置为true,则会一直固定在tag项中(默认 false)
  18. noTagsView: true 如果设置为true,则不会出现在tag中(默认 false)
  19. activeMenu: '/home' 显示高亮的路由路径
  20. followAuth: '/home' 跟随哪个路由进行权限过滤
  21. canTo: true 设置为true即使hidden为true,也依然可以进行路由跳转(默认 false)
  22. }
  23. **/
  24. declare module 'vue-router' {
  25. interface RouteMeta extends Record<string | number | symbol, unknown> {
  26. hidden?: boolean
  27. alwaysShow?: boolean
  28. title?: string
  29. icon?: string
  30. noCache?: boolean
  31. breadcrumb?: boolean
  32. affix?: boolean
  33. activeMenu?: string
  34. noTagsView?: boolean
  35. followAuth?: string
  36. canTo?: boolean
  37. }
  38. }
  39. type Component<T = any> =
  40. | ReturnType<typeof defineComponent>
  41. | (() => Promise<typeof import('*.vue')>)
  42. | (() => Promise<T>)
  43. declare global {
  44. interface AppRouteRecordRaw extends Omit<RouteRecordRaw, 'meta'> {
  45. name: string
  46. meta: RouteMeta
  47. component?: Component | string
  48. children?: AppRouteRecordRaw[]
  49. props?: Recordable
  50. fullPath?: string
  51. keepAlive?: boolean
  52. }
  53. interface AppCustomRouteRecordRaw extends Omit<RouteRecordRaw, 'meta'> {
  54. icon: any
  55. name: string
  56. meta: RouteMeta
  57. component: string
  58. componentName?: string
  59. path: string
  60. redirect: string
  61. children?: AppCustomRouteRecordRaw[]
  62. keepAlive?: boolean
  63. visible?: boolean
  64. parentId?: number
  65. alwaysShow?: boolean
  66. }
  67. }