route.ts 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. import { RouteRecordRaw } from 'vue-router';
  2. /**
  3. * 建议:路由 path 路径与文件夹名称相同,找文件可浏览器地址找,方便定位文件位置
  4. *
  5. * 路由meta对象参数说明
  6. * meta: {
  7. * title: 菜单栏及 tagsView 栏、菜单搜索名称(国际化)
  8. * isLink: 是否超链接菜单,开启外链条件,`1、isLink: 链接地址不为空 2、isIframe:false`
  9. * isHide: 是否隐藏此路由
  10. * isKeepAlive: 是否缓存组件状态
  11. * isAffix: 是否固定在 tagsView 栏上
  12. * isIframe: 是否内嵌窗口,开启条件,`1、isIframe:true 2、isLink:链接地址不为空`
  13. * roles: 当前路由权限标识,取角色管理。控制路由显示、隐藏。超级管理员:admin 普通角色:common
  14. * icon: 菜单、tagsView 图标,阿里:加 `iconfont xxx`,fontawesome:加 `fa xxx`
  15. * }
  16. */
  17. // 扩展 RouteMeta 接口
  18. declare module 'vue-router' {
  19. interface RouteMeta {
  20. isLink?: string;
  21. isHide?: boolean;
  22. isAuth?: boolean;
  23. isKeepAlive?: boolean;
  24. isAffix?: boolean;
  25. isIframe?: boolean;
  26. roles?: string[];
  27. icon?: string;
  28. }
  29. }
  30. /**
  31. * 定义静态路由(默认路由)
  32. * 前端添加路由,请在此处加
  33. */
  34. export const dynamicRoutes: Array<RouteRecordRaw> = [
  35. {
  36. path: '/home',
  37. name: 'router.home',
  38. component: () => import('/@/views/home/index.vue'),
  39. meta: {
  40. isLink: '',
  41. isHide: false,
  42. isKeepAlive: true,
  43. isAffix: true,
  44. isIframe: false,
  45. icon: 'iconfont icon-shouye',
  46. },
  47. },
  48. {
  49. path: '/personal',
  50. name: 'router.personal',
  51. component: () => import('/@/views/admin/user/personal.vue'),
  52. meta: {
  53. isHide: true,
  54. },
  55. },
  56. ];
  57. /**
  58. * 定义静态路由(默认路由)
  59. */
  60. export const staticRoutes: Array<RouteRecordRaw> = [
  61. {
  62. path: '/login',
  63. name: 'staticRoutes.login',
  64. component: () => import('/@/views/login/index.vue'),
  65. meta: {
  66. isAuth: false,
  67. },
  68. }
  69. ];
  70. /**
  71. * 定义404、401界面
  72. */
  73. export const notFoundAndNoPower = [
  74. {
  75. path: '/:path(.*)*',
  76. name: 'staticRoutes.notFound',
  77. component: () => import('/@/views/error/404.vue'),
  78. meta: {
  79. isHide: true,
  80. },
  81. },
  82. {
  83. path: '/401',
  84. name: 'staticRoutes.noPower',
  85. component: () => import('/@/views/error/401.vue'),
  86. meta: {
  87. isHide: true,
  88. },
  89. },
  90. ];
  91. /**
  92. * 基础性路由
  93. *
  94. * 所有节点都是挂载此节点下
  95. */
  96. export const baseRoutes: Array<RouteRecordRaw> = [
  97. {
  98. path: '/',
  99. name: '/',
  100. component: () => import('/@/layout/index.vue'),
  101. redirect: '/home',
  102. meta: {
  103. isKeepAlive: true,
  104. },
  105. children: [],
  106. },
  107. ];