index.js 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. import { createWebHistory, createRouter } from 'vue-router'
  2. import Layout from '@/layout'
  3. import Layoutmb from "@/layoutmb";
  4. /**
  5. * Note: 路由配置项
  6. *
  7. * hidden: true // 当设置 true 的时候该路由不会再侧边栏出现 如401,login等页面,或者如一些编辑页面/edit/1
  8. * alwaysShow: true // 当你一个路由下面的 children 声明的路由大于1个时,自动会变成嵌套的模式--如组件页面
  9. * // 只有一个时,会将那个子路由当做根路由显示在侧边栏--如引导页面
  10. * // 若你想不管路由下面的 children 声明的个数都显示你的根路由
  11. * // 你可以设置 alwaysShow: true,这样它就会忽略之前定义的规则,一直显示根路由
  12. * redirect: noRedirect // 当设置 noRedirect 的时候该路由在面包屑导航中不可被点击
  13. * name:'router-name' // 设定路由的名字,一定要填写不然使用<keep-alive>时会出现各种问题
  14. * query: '{"id": 1, "name": "ry"}' // 访问路由的默认传递参数
  15. * meta : {
  16. noCache: true // 如果设置为true,则不会被 <keep-alive> 缓存(默认 false)
  17. title: 'title' // 设置该路由在侧边栏和面包屑中展示的名字
  18. icon: 'svg-name' // 设置该路由的图标,对应路径src/assets/icons/svg
  19. breadcrumb: false // 如果设置为false,则不会在breadcrumb面包屑中显示
  20. activeMenu: '/system/user' // 当路由设置了该属性,则会高亮相对应的侧边栏。
  21. }
  22. */
  23. // 公共路由
  24. export const constantRoutes = [{
  25. path: "/redirect",
  26. component: Layout,
  27. hidden: true,
  28. children: [{
  29. path: "/redirect/:path(.*)",
  30. component: () =>
  31. import ("@/views/redirect/index.vue"),
  32. }, ],
  33. },
  34. {
  35. path: "/login",
  36. component: () =>
  37. import ("@/views/login"),
  38. hidden: true,
  39. },
  40. {
  41. path: "/register",
  42. component: () =>
  43. import ("@/views/register"),
  44. hidden: true,
  45. },
  46. {
  47. path: "/:pathMatch(.*)*",
  48. component: () =>
  49. import ("@/views/error/404"),
  50. hidden: true,
  51. },
  52. {
  53. path: "/401",
  54. component: () =>
  55. import ("@/views/error/401"),
  56. hidden: true,
  57. },
  58. {
  59. path: "",
  60. component: Layout,
  61. hidden: true,
  62. redirect: "/task/list/1",
  63. children: [
  64. // {
  65. // path: "/index",
  66. // component: () =>
  67. // import ("@/views/index"),
  68. // name: "Index",
  69. // meta: { title: "首页", icon: "dashboard", affix: true },
  70. // },
  71. ],
  72. },
  73. {
  74. path: "/task",
  75. component: Layout,
  76. hidden: true,
  77. redirect: "noredirect",
  78. children: [{
  79. path: "list/:status",
  80. component: () =>
  81. import ("@/views/task/list/index"),
  82. name: "tasklist",
  83. meta: { title: "任务列表", icon: "user" },
  84. },
  85. {
  86. path: "detail/:id",
  87. component: () =>
  88. import ("@/views/task/detail/index"),
  89. name: "taskdetail",
  90. meta: { title: "任务详情", icon: "user" },
  91. },
  92. ],
  93. },
  94. {
  95. path: "/detection",
  96. component: Layout,
  97. hidden: true,
  98. redirect: "noredirect",
  99. children: [{
  100. path: "list/:status",
  101. component: () =>
  102. import ("@/views/detection/list/index"),
  103. name: "detectionlist",
  104. meta: { title: "检测计划列表", icon: "user" },
  105. },
  106. {
  107. path: "detail/:id",
  108. component: () =>
  109. import ("@/views/detection/detail/index"),
  110. name: "detectiondetail",
  111. meta: { title: "检测计划详情", icon: "user" },
  112. },
  113. ],
  114. },
  115. {
  116. path: "/maintain",
  117. component: Layout,
  118. hidden: true,
  119. redirect: "noredirect",
  120. children: [{
  121. path: "list/:status",
  122. component: () =>
  123. import ("@/views/maintain/list/index"),
  124. name: "maintainlist",
  125. meta: { title: "养护计划列表", icon: "user" },
  126. },
  127. {
  128. path: "detail/:id",
  129. component: () =>
  130. import ("@/views/maintain/detail/index"),
  131. name: "maintaindetail",
  132. meta: { title: "养护计划详情", icon: "user" },
  133. },
  134. ],
  135. },
  136. {
  137. path: "/mb",
  138. component: Layoutmb,
  139. hidden: true,
  140. redirect: "/mb/home",
  141. children: [{
  142. path: "home",
  143. component: () =>
  144. import ("@/views/mb/home/index"),
  145. name: "mbhome",
  146. meta: { title: "首页", icon: "user" },
  147. },
  148. {
  149. path: "maintain",
  150. component: () =>
  151. import ("@/views/mb/maintain/index"),
  152. name: "mbmaintain",
  153. meta: { title: "养护计划", icon: "user" },
  154. },
  155. {
  156. path: "maintain/detail/:id",
  157. component: () =>
  158. import ("@/views/mb/maintain/detail/index"),
  159. name: "mbmaintaindetail",
  160. meta: { title: "养护计划详情", icon: "user" },
  161. },
  162. {
  163. path: "detection",
  164. component: () =>
  165. import ("@/views/mb/detection/index"),
  166. name: "mbdetection",
  167. meta: { title: "检测计划", icon: "user" },
  168. },
  169. {
  170. path: "detection/detail/:id",
  171. component: () =>
  172. import ("@/views/mb/detection/detail/index"),
  173. name: "mbdetectiondetail",
  174. meta: { title: "检测计划详情", icon: "user" },
  175. },
  176. {
  177. path: "task",
  178. component: () =>
  179. import ("@/views/mb/task/index"),
  180. name: "mbtask",
  181. meta: { title: "工单", icon: "user" },
  182. },
  183. {
  184. path: "task/detail/:id",
  185. component: () =>
  186. import ("@/views/mb/task/detail/index"),
  187. name: "mbtaskdetail",
  188. meta: { title: "热线工单详情", icon: "user" },
  189. },
  190. {
  191. path: "task/add",
  192. component: () =>
  193. import ("@/views/mb/task/add/index"),
  194. name: "mbtaskadd",
  195. meta: { title: "热线工单新增", icon: "user" },
  196. },
  197. ],
  198. },
  199. {
  200. path: "/user",
  201. component: Layout,
  202. hidden: true,
  203. redirect: "noredirect",
  204. children: [{
  205. path: "profile",
  206. component: () =>
  207. import ("@/views/system/user/profile/index"),
  208. name: "Profile",
  209. meta: { title: "个人中心", icon: "user" },
  210. }, ],
  211. },
  212. {
  213. path: "/system/user-auth",
  214. component: Layout,
  215. hidden: true,
  216. children: [{
  217. path: "role/:userId(\\d+)",
  218. component: () =>
  219. import ("@/views/system/user/authRole"),
  220. name: "AuthRole",
  221. meta: { title: "分配角色", activeMenu: "/system/user" },
  222. }, ],
  223. },
  224. {
  225. path: "/system/role-auth",
  226. component: Layout,
  227. hidden: true,
  228. children: [{
  229. path: "user/:roleId(\\d+)",
  230. component: () =>
  231. import ("@/views/system/role/authUser"),
  232. name: "AuthUser",
  233. meta: { title: "分配用户", activeMenu: "/system/role" },
  234. }, ],
  235. },
  236. {
  237. path: "/system/dict-data",
  238. component: Layout,
  239. hidden: true,
  240. children: [{
  241. path: "index/:dictId(\\d+)",
  242. component: () =>
  243. import ("@/views/system/dict/data"),
  244. name: "Data",
  245. meta: { title: "字典数据", activeMenu: "/system/dict" },
  246. }, ],
  247. },
  248. {
  249. path: "/monitor/job-log",
  250. component: Layout,
  251. hidden: true,
  252. children: [{
  253. path: "index",
  254. component: () =>
  255. import ("@/views/monitor/job/log"),
  256. name: "JobLog",
  257. meta: { title: "调度日志", activeMenu: "/monitor/job" },
  258. }, ],
  259. },
  260. {
  261. path: "/tool/gen-edit",
  262. component: Layout,
  263. hidden: true,
  264. children: [{
  265. path: "index/:tableId(\\d+)",
  266. component: () =>
  267. import ("@/views/tool/gen/editTable"),
  268. name: "GenEdit",
  269. meta: { title: "修改生成配置", activeMenu: "/tool/gen" },
  270. }, ],
  271. },
  272. ];
  273. const router = createRouter({
  274. history: createWebHistory(),
  275. routes: constantRoutes,
  276. scrollBehavior(to, from, savedPosition) {
  277. if (savedPosition) {
  278. return savedPosition
  279. } else {
  280. return { top: 0 }
  281. }
  282. },
  283. });
  284. export default router;