index.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. import {createWebHistory, createRouter, createWebHashHistory} from 'vue-router'
  2. import Layout from '@/layout'
  3. /**
  4. * Note: 路由配置项
  5. *
  6. * hidden: true // 当设置 true 的时候该路由不会再侧边栏出现 如401,login等页面,或者如一些编辑页面/edit/1
  7. * alwaysShow: true // 当你一个路由下面的 children 声明的路由大于1个时,自动会变成嵌套的模式--如组件页面
  8. * // 只有一个时,会将那个子路由当做根路由显示在侧边栏--如引导页面
  9. * // 若你想不管路由下面的 children 声明的个数都显示你的根路由
  10. * // 你可以设置 alwaysShow: true,这样它就会忽略之前定义的规则,一直显示根路由
  11. * redirect: noRedirect // 当设置 noRedirect 的时候该路由在面包屑导航中不可被点击
  12. * name:'router-name' // 设定路由的名字,一定要填写不然使用<keep-alive>时会出现各种问题
  13. * query: '{"id": 1, "name": "ry"}' // 访问路由的默认传递参数
  14. * meta : {
  15. noCache: true // 如果设置为true,则不会被 <keep-alive> 缓存(默认 false)
  16. title: 'title' // 设置该路由在侧边栏和面包屑中展示的名字
  17. icon: 'svg-name' // 设置该路由的图标,对应路径src/assets/icons/svg
  18. breadcrumb: false // 如果设置为false,则不会在breadcrumb面包屑中显示
  19. activeMenu: '/system/user' // 当路由设置了该属性,则会高亮相对应的侧边栏。
  20. }
  21. */
  22. // 公共路由
  23. export const constantRoutes = [
  24. //首页
  25. {
  26. path: '/',
  27. component: Layout,
  28. redirect: '/index',
  29. children: [
  30. {
  31. path: 'index',
  32. name: 'index',
  33. component: () => import('@/views/home'),
  34. meta: {
  35. title: '首页',
  36. icon: 'user',
  37. affix: true
  38. }
  39. }
  40. ]
  41. },
  42. //登录
  43. {
  44. path: '/login',
  45. component: () => import('@/views/login'),
  46. hidden: true
  47. },
  48. //注册
  49. {
  50. path: '/register',
  51. component: () => import('@/views/register'),
  52. hidden: true
  53. },
  54. {
  55. path: '/:pathMatch(.*)*',
  56. component: () => import('@/views/error/404'),
  57. hidden: true
  58. },
  59. {
  60. path: '/401',
  61. component: () => import('@/views/error/401'),
  62. hidden: true
  63. },
  64. {
  65. path: '/visualization',
  66. component: () => import('@/views/visualization/index.vue'),
  67. hidden: true,
  68. },
  69. //个人中心
  70. {
  71. path: '/user',
  72. component: Layout,
  73. hidden: true,
  74. redirect: '/user/profile',
  75. children: [
  76. {
  77. path: 'profile',
  78. component: () => import('@/views/system/user/profile/index'),
  79. name: 'Profile',
  80. meta: { title: '个人中心', icon: 'user' }
  81. }
  82. ]
  83. },
  84. // //角色分配用户
  85. {
  86. path: '/system/role-auth',
  87. component: Layout,
  88. hidden: true,
  89. children: [
  90. {
  91. path: 'user/:roleId(\\d+)',
  92. component: () => import('@/views/system/role/authUser'),
  93. name: 'AuthUser',
  94. meta: { title: '分配用户', activeMenu: '/system/role' }
  95. }
  96. ]
  97. },
  98. // 用户分配角色
  99. {
  100. path: '/system/user-auth',
  101. component: Layout,
  102. hidden: true,
  103. children: [
  104. {
  105. path: 'role/:userId(\\d+)',
  106. component: () => import('@/views/system/user/authRole'),
  107. name: 'AuthRole',
  108. meta: { title: '分配角色', activeMenu: '/system/user' }
  109. }
  110. ]
  111. },
  112. //字典数据分配
  113. {
  114. path: '/system/dict-data',
  115. component: Layout,
  116. hidden: true,
  117. children: [
  118. {
  119. path: 'index/:dictId(\\d+)',
  120. component: () => import('@/views/system/dict/data'),
  121. name: 'Data',
  122. meta: { title: '字典数据', activeMenu: '/system/dict' }
  123. }
  124. ]
  125. }
  126. //系统监控
  127. // {
  128. // path: '/monitor/job-log',
  129. // component: Layout,
  130. // hidden: true,
  131. // children: [
  132. // {
  133. // path: 'index',
  134. // component: () => import('@/views/monitor/job/log'),
  135. // name: 'JobLog',
  136. // meta: { title: '调度日志', activeMenu: '/monitor/job' }
  137. // }
  138. // ]
  139. // }
  140. ]
  141. const router = createRouter({
  142. history: createWebHashHistory(),
  143. routes: constantRoutes,
  144. scrollBehavior(to, from, savedPosition) {
  145. if (savedPosition) {
  146. return savedPosition
  147. } else {
  148. return { top: 0 }
  149. }
  150. }
  151. })
  152. export default router