index.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  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 constantRoutes = [{
  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. {
  60. path: "/jxst/pro/qrDetails",
  61. component: () => import("@/views/JXSK/production/qrDetails/index"),
  62. hidden: false,
  63. },
  64. // 物料详情
  65. {
  66. path: "/jxst/pro/materialDetails",
  67. component: () => import("@/views/JXSK/materialDetails/index"),
  68. hidden: false,
  69. },
  70. {
  71. path: "",
  72. component: Layout,
  73. redirect: "/index",
  74. children: [{
  75. path: "/index",
  76. component: () => import("@/views/index"),
  77. name: "Index",
  78. meta: {
  79. title: "首页",
  80. icon: "dashboard",
  81. affix: true
  82. },
  83. },
  84. {
  85. path: "/platform_manage/process/processApproval",
  86. component: () => import("@/views/process/processApproval/index.vue"),
  87. name: "ProcessApproval",
  88. meta: {
  89. title: "流程审批",
  90. icon: "dashboard",
  91. affix: false
  92. },
  93. },
  94. ],
  95. },
  96. {
  97. path: "/user",
  98. component: Layout,
  99. hidden: true,
  100. redirect: "noredirect",
  101. children: [{
  102. path: "profile",
  103. component: () => import("@/views/system/user/profile/index"),
  104. name: "Profile",
  105. meta: {
  106. title: "个人中心",
  107. icon: "user"
  108. },
  109. }, ],
  110. },
  111. ];
  112. // 动态路由,基于用户权限动态去加载
  113. export const dynamicRoutes = [{
  114. path: "/system/user-auth",
  115. component: Layout,
  116. hidden: true,
  117. permissions: ["system:user:edit"],
  118. children: [{
  119. path: "role/:userId(\\d+)",
  120. component: () => import("@/views/system/user/authRole"),
  121. name: "AuthRole",
  122. meta: {
  123. title: "分配角色",
  124. activeMenu: "/system/user"
  125. },
  126. }, ],
  127. },
  128. {
  129. path: "/system/role-auth",
  130. component: Layout,
  131. hidden: true,
  132. permissions: ["system:role:edit"],
  133. children: [{
  134. path: "user/:roleId(\\d+)",
  135. component: () => import("@/views/system/role/authUser"),
  136. name: "AuthUser",
  137. meta: {
  138. title: "分配用户",
  139. activeMenu: "/system/role"
  140. },
  141. }, ],
  142. },
  143. {
  144. path: "/system/dict-data",
  145. component: Layout,
  146. hidden: true,
  147. permissions: ["system:dict:list"],
  148. children: [{
  149. path: "index/:dictId(\\d+)",
  150. component: () => import("@/views/system/dict/data"),
  151. name: "Data",
  152. meta: {
  153. title: "字典数据",
  154. activeMenu: "/system/dict"
  155. },
  156. }, ],
  157. },
  158. {
  159. path: "/monitor/job-log",
  160. component: Layout,
  161. hidden: true,
  162. permissions: ["monitor:job:list"],
  163. children: [{
  164. path: "index/:jobId(\\d+)",
  165. component: () => import("@/views/monitor/job/log"),
  166. name: "JobLog",
  167. meta: {
  168. title: "调度日志",
  169. activeMenu: "/monitor/job"
  170. },
  171. }, ],
  172. },
  173. {
  174. path: "/tool/gen-edit",
  175. component: Layout,
  176. hidden: true,
  177. permissions: ["tool:gen:edit"],
  178. children: [{
  179. path: "index/:tableId(\\d+)",
  180. component: () => import("@/views/tool/gen/editTable"),
  181. name: "GenEdit",
  182. meta: {
  183. title: "修改生成配置",
  184. activeMenu: "/tool/gen"
  185. },
  186. }, ],
  187. },
  188. ];
  189. const router = createRouter({
  190. history: createWebHistory(),
  191. routes: constantRoutes,
  192. scrollBehavior(to, from, savedPosition) {
  193. if (savedPosition) {
  194. return savedPosition;
  195. } else {
  196. return {
  197. top: 0
  198. };
  199. }
  200. },
  201. });
  202. export default router;