index.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. import {
  2. createWebHistory,
  3. createRouter
  4. } from 'vue-router'
  5. /* Layout */
  6. import Layout from '@/layout'
  7. /**
  8. * Note: 路由配置项
  9. *
  10. * hidden: true // 当设置 true 的时候该路由不会再侧边栏出现 如401,login等页面,或者如一些编辑页面/edit/1
  11. * alwaysShow: true // 当你一个路由下面的 children 声明的路由大于1个时,自动会变成嵌套的模式--如组件页面
  12. * // 只有一个时,会将那个子路由当做根路由显示在侧边栏--如引导页面
  13. * // 若你想不管路由下面的 children 声明的个数都显示你的根路由
  14. * // 你可以设置 alwaysShow: true,这样它就会忽略之前定义的规则,一直显示根路由
  15. * redirect: noRedirect // 当设置 noRedirect 的时候该路由在面包屑导航中不可被点击
  16. * name:'router-name' // 设定路由的名字,一定要填写不然使用<keep-alive>时会出现各种问题
  17. * query: '{"id": 1, "name": "ry"}' // 访问路由的默认传递参数
  18. * roles: ['admin', 'common'] // 访问路由的角色权限
  19. * permissions: ['a:a:a', 'b:b:b'] // 访问路由的菜单权限
  20. * meta : {
  21. noCache: true // 如果设置为true,则不会被 <keep-alive> 缓存(默认 false)
  22. title: 'title' // 设置该路由在侧边栏和面包屑中展示的名字
  23. icon: 'svg-name' // 设置该路由的图标,对应路径src/assets/icons/svg
  24. breadcrumb: false // 如果设置为false,则不会在breadcrumb面包屑中显示
  25. activeMenu: '/system/user' // 当路由设置了该属性,则会高亮相对应的侧边栏。
  26. }
  27. */
  28. // 公共路由
  29. export const constantRouters = [{
  30. path: '/redirect',
  31. component: Layout,
  32. hidden: true,
  33. children: [{
  34. path: '/redirect/:path(.*)',
  35. component: () => import('@/views/redirect/index.vue')
  36. }]
  37. },
  38. {
  39. path: '/login',
  40. component: () => import('@/views/login'),
  41. hidden: true
  42. },
  43. {
  44. path: '/register',
  45. component: () => import('@/views/register'),
  46. hidden: true
  47. },
  48. {
  49. path: "/:pathMatch(.*)*",
  50. component: () => import('@/views/error/404'),
  51. hidden: true
  52. },
  53. {
  54. path: '/401',
  55. component: () => import('@/views/error/401'),
  56. hidden: true
  57. },
  58. {
  59. path: '',
  60. component: Layout,
  61. redirect: '/index',
  62. children: [{
  63. path: '/index',
  64. component: () => import('@/views/index'),
  65. name: 'Index',
  66. meta: {
  67. title: '首页',
  68. icon: 'dashboard',
  69. affix: true
  70. }
  71. }]
  72. },
  73. {
  74. path: '/user',
  75. component: Layout,
  76. hidden: true,
  77. redirect: 'noredirect',
  78. children: [{
  79. path: 'profile',
  80. component: () => import('@/views/system/user/profile/index'),
  81. name: 'Profile',
  82. meta: {
  83. title: '个人中心',
  84. icon: 'user'
  85. }
  86. }]
  87. }
  88. ]
  89. // 动态路由,基于用户权限动态去加载
  90. export const dynamicRoutes = [{
  91. path: '/system/user-auth',
  92. component: Layout,
  93. hidden: true,
  94. permissions: ['system:user:edit'],
  95. children: [{
  96. path: 'role/:userId(\\d+)',
  97. component: () => import('@/views/system/user/authRole'),
  98. name: 'AuthRole',
  99. meta: {
  100. title: '分配角色',
  101. activeMenu: '/system/user'
  102. }
  103. }]
  104. },
  105. {
  106. path: '/system/role-auth',
  107. component: Layout,
  108. hidden: true,
  109. permissions: ['system:role:edit'],
  110. children: [{
  111. path: 'user/:roleId(\\d+)',
  112. component: () => import('@/views/system/role/authUser'),
  113. name: 'AuthUser',
  114. meta: {
  115. title: '分配用户',
  116. activeMenu: '/system/role'
  117. }
  118. }]
  119. },
  120. {
  121. path: '/system/dict-data',
  122. component: Layout,
  123. hidden: true,
  124. permissions: ['system:dict:list'],
  125. children: [{
  126. path: 'index/:dictId(\\d+)',
  127. component: () => import('@/views/system/dict/data'),
  128. name: 'Data',
  129. meta: {
  130. title: '字典数据',
  131. activeMenu: '/setting/dict'
  132. }
  133. }]
  134. },
  135. {
  136. path: '/customer/dict-data',
  137. component: Layout,
  138. hidden: true,
  139. permissions: ['business:crm:dict:list'],
  140. children: [{
  141. path: 'index/:dictId(\\d+)',
  142. component: () => import('@/views/business/crm/dict/data'),
  143. name: 'CustomerData',
  144. meta: {
  145. title: '字典数据',
  146. activeMenu: '/setting/dict'
  147. }
  148. }]
  149. },
  150. {
  151. path: '/monitor/job-log',
  152. component: Layout,
  153. hidden: true,
  154. permissions: ['monitor:job:list'],
  155. children: [{
  156. path: 'index/:jobId(\\d+)',
  157. component: () => import('@/views/monitor/job/log'),
  158. name: 'JobLog',
  159. meta: {
  160. title: '调度日志',
  161. activeMenu: '/monitor/job'
  162. }
  163. }]
  164. },
  165. {
  166. path: '/tool/gen-edit',
  167. component: Layout,
  168. hidden: true,
  169. permissions: ['tool:gen:edit'],
  170. children: [{
  171. path: 'index/:tableId(\\d+)',
  172. component: () => import('@/views/tool/gen/editTable'),
  173. name: 'GenEdit',
  174. meta: {
  175. title: '修改生成配置',
  176. activeMenu: '/tool/gen'
  177. }
  178. }]
  179. },
  180. {
  181. path: '/entrust/statusment',
  182. component: Layout,
  183. hidden: true,
  184. permissions: ['business:entrustOrder:statement:list'],
  185. children: [{
  186. path: 'order/:orderId(\\d+)',
  187. component: () => import('@/views/business/entrust/statementAccount/index'),
  188. name: 'StatementOfOrder',
  189. meta: {
  190. title: '对账单列表',
  191. activeMenu: '/contracts/entrustOrder'
  192. }
  193. }]
  194. }
  195. ]
  196. const router = createRouter({
  197. history: createWebHistory(),
  198. routes: constantRouters,
  199. scrollBehavior(to, from, savedPosition) {
  200. if (savedPosition) {
  201. return savedPosition
  202. } else {
  203. return {
  204. top: 0
  205. }
  206. }
  207. },
  208. });
  209. export default router;