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