route.ts 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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. title?: string;
  21. isLink?: string;
  22. isHide?: boolean;
  23. isKeepAlive?: boolean;
  24. isAffix?: boolean;
  25. isIframe?: boolean;
  26. roles?: string[];
  27. icon?: string;
  28. }
  29. }
  30. /**
  31. * 定义动态路由
  32. * 前端添加路由,请在顶级节点的 `children 数组` 里添加
  33. * @description 未开启 isRequestRoutes 为 true 时使用(前端控制路由),开启时第一个顶级 children 的路由将被替换成接口请求回来的路由数据
  34. * @description 各字段请查看 `/@/views/system/menu/component/addMenu.vue 下的 ruleForm`
  35. * @returns 返回路由菜单数据
  36. */
  37. export const dynamicRoutes: Array<RouteRecordRaw> = [
  38. {
  39. path: '/',
  40. name: '/',
  41. component: () => import('/@/layout/index.vue'),
  42. redirect: '/dashboard/home',
  43. meta: {
  44. isKeepAlive: true,
  45. },
  46. children: [],
  47. },
  48. {
  49. path: '/platform/job/dashboard',
  50. name: 'jobDashboard',
  51. component: () => import('/@/views/system/job/dashboard.vue'),
  52. meta: {
  53. title: '任务看板',
  54. isLink: import.meta.env.VITE_API_URL + '/schedule',
  55. isHide: true,
  56. isKeepAlive: true,
  57. isAffix: false,
  58. isIframe: true,
  59. icon: 'ele-Clock',
  60. },
  61. },
  62. ];
  63. /**
  64. * 定义404、401界面
  65. * @link 参考:https://next.router.vuejs.org/zh/guide/essentials/history-mode.html#netlify
  66. */
  67. export const notFoundAndNoPower = [
  68. {
  69. path: '/:path(.*)*',
  70. name: 'notFound',
  71. component: () => import('/@/views/error/404.vue'),
  72. meta: {
  73. title: 'message.staticRoutes.notFound',
  74. isHide: true,
  75. },
  76. },
  77. {
  78. path: '/401',
  79. name: 'noPower',
  80. component: () => import('/@/views/error/401.vue'),
  81. meta: {
  82. title: 'message.staticRoutes.noPower',
  83. isHide: true,
  84. },
  85. },
  86. ];
  87. /**
  88. * 定义静态路由(默认路由)
  89. * 此路由不要动,前端添加路由的话,请在 `dynamicRoutes 数组` 中添加
  90. * @description 前端控制直接改 dynamicRoutes 中的路由,后端控制不需要修改,请求接口路由数据时,会覆盖 dynamicRoutes 第一个顶级 children 的内容(全屏,不包含 layout 中的路由出口)
  91. * @returns 返回路由菜单数据
  92. */
  93. export const staticRoutes: Array<RouteRecordRaw> = [
  94. {
  95. path: '/login',
  96. name: 'login',
  97. component: () => import('/@/views/login/index.vue'),
  98. meta: {
  99. title: '登录',
  100. },
  101. },
  102. /**
  103. * 提示:写在这里的为全屏界面,不建议写在这里
  104. * 请写在 `dynamicRoutes` 路由数组中
  105. */
  106. {
  107. path: '/visualizingDemo1',
  108. name: 'visualizingDemo1',
  109. component: () => import('/@/views/visualizing/demo1.vue'),
  110. meta: {
  111. title: 'message.router.visualizingLinkDemo1',
  112. },
  113. },
  114. {
  115. path: '/visualizingDemo2',
  116. name: 'visualizingDemo2',
  117. component: () => import('/@/views/visualizing/demo2.vue'),
  118. meta: {
  119. title: 'message.router.visualizingLinkDemo2',
  120. },
  121. },
  122. ];