index.js 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  1. import Vue from 'vue'
  2. import Router from 'vue-router'
  3. Vue.use(Router)
  4. /* Layout */
  5. import Layout from '@/layout'
  6. /**
  7. * Note: 路由配置项
  8. *
  9. * hidden: true // 当设置 true 的时候该路由不会再侧边栏出现 如401,login等页面,或者如一些编辑页面/edit/1
  10. * alwaysShow: true // 当你一个路由下面的 children 声明的路由大于1个时,自动会变成嵌套的模式--如组件页面
  11. * // 只有一个时,会将那个子路由当做根路由显示在侧边栏--如引导页面
  12. * // 若你想不管路由下面的 children 声明的个数都显示你的根路由
  13. * // 你可以设置 alwaysShow: true,这样它就会忽略之前定义的规则,一直显示根路由
  14. * redirect: noRedirect // 当设置 noRedirect 的时候该路由在面包屑导航中不可被点击
  15. * name:'router-name' // 设定路由的名字,一定要填写不然使用<keep-alive>时会出现各种问题
  16. * query: '{"id": 1, "name": "ry"}' // 访问路由的默认传递参数
  17. * roles: ['admin', 'common'] // 访问路由的角色权限
  18. * permissions: ['a:a:a', 'b:b:b'] // 访问路由的菜单权限
  19. * meta : {
  20. noCache: true // 如果设置为true,则不会被 <keep-alive> 缓存(默认 false)
  21. title: 'title' // 设置该路由在侧边栏和面包屑中展示的名字
  22. icon: 'svg-name' // 设置该路由的图标,对应路径src/assets/icons/svg
  23. breadcrumb: false // 如果设置为false,则不会在breadcrumb面包屑中显示
  24. activeMenu: '/system/user' // 当路由设置了该属性,则会高亮相对应的侧边栏。
  25. }
  26. */
  27. // 公共路由
  28. export const constantRoutes = [
  29. // {
  30. // path: '/data',
  31. // component: data,
  32. // hidden: true,
  33. // children: [
  34. // {
  35. // path: 'data',
  36. // component: () => import('../data/index.vue'),
  37. // name: 'data',
  38. // meta: { title: '数据引擎', icon: 'user' }
  39. // }
  40. // ]
  41. // },
  42. {
  43. path: '/redirect',
  44. component: Layout,
  45. hidden: true,
  46. children: [
  47. {
  48. path: '/redirect/:path(.*)',
  49. component: () => import('@/views/redirect')
  50. }
  51. ]
  52. },
  53. // {
  54. // path: '/planTable/index',
  55. // component: () => {
  56. // return import('@/views/orderMange/planTable/index')
  57. // },
  58. // hidden: true
  59. // },
  60. {
  61. path: '/redirect',
  62. component: Layout,
  63. hidden: true,
  64. children: [
  65. {
  66. path: '/redirect/:path(.*)',
  67. component: () => import('@/views/redirect')
  68. }
  69. ]
  70. },
  71. {
  72. path: '/planTable/show/northWorkshop',
  73. component: () => {
  74. return import('@/views/orderMange/planTable/show/northWorkshop')
  75. },
  76. hidden: true
  77. },
  78. {
  79. path: '/planTable/show/southWorkshop',
  80. component: () => {
  81. return import('@/views/orderMange/planTable/show/southWorkshop')
  82. },
  83. hidden: true
  84. },
  85. {
  86. path: '/planTable/show/fankuang',
  87. component: () => {
  88. return import('@/views/orderMange/planTable/show/fankuang')
  89. },
  90. hidden: true
  91. },
  92. {
  93. path: '/planTable/show/fangsi',
  94. component: () => {
  95. return import('@/views/orderMange/planTable/show/fangsi')
  96. },
  97. hidden: true
  98. },
  99. {
  100. path: '/planTable/show/luotong',
  101. component: () => {
  102. return import('@/views/orderMange/planTable/show/luotong')
  103. },
  104. hidden: true
  105. },
  106. {
  107. path: '/tableMange',
  108. component: Layout,
  109. hidden: true,
  110. name: 'tableMange',
  111. meta: {
  112. title: "表格编辑",
  113. icon: "form",
  114. noCache: false,
  115. link: null
  116. },
  117. children: [
  118. {
  119. path: 'index',
  120. component: () => import('@/views/tableMange/index'),
  121. }
  122. ]
  123. },
  124. {
  125. path: '/progressShow',
  126. component: Layout,
  127. hidden: true,
  128. name: 'progressShow',
  129. meta: {
  130. title: "管道展示",
  131. icon: "form",
  132. noCache: false,
  133. link: null
  134. },
  135. children: [
  136. {
  137. path: 'index',
  138. component: () => import('@/views/bussiness/progressShow'),
  139. }
  140. ]
  141. },
  142. {
  143. path: '/processMange',
  144. component: Layout,
  145. hidden: true,
  146. name: 'processMange',
  147. meta: {
  148. title: "管道流程",
  149. icon: "form",
  150. noCache: false,
  151. link: null
  152. },
  153. children: [
  154. {
  155. path: 'index',
  156. component: () => import('@/views/bussiness/processMange'),
  157. }
  158. ]
  159. },
  160. // {
  161. // path: '/bpmn',
  162. // component: Layout,
  163. // hidden: true,
  164. // name: 'bpmn',
  165. // meta: {
  166. // title: "流程图",
  167. // icon: "form",
  168. // noCache: false,
  169. // link: null
  170. // },
  171. // children: [
  172. // {
  173. // path: 'index',
  174. // component: () => import('@/views/system/bpmn/index.vue'),
  175. // }
  176. // ]
  177. // },
  178. {
  179. path: '/bpmnPro',
  180. component: () => import('@/views/system/bpmnPro'),
  181. hidden: true,
  182. },
  183. {
  184. path: '/login',
  185. component: () => {
  186. return import('@/views/login')
  187. // var url = new URL(window.location.href);
  188. // var params = new URLSearchParams(url.search);
  189. // let temp = params.get('tenantId')
  190. // if (temp) {
  191. // return import('@/views/login')
  192. // } else {
  193. // // return import('@/views/error/404')
  194. // return import('@/views/login')
  195. // }
  196. },
  197. hidden: true
  198. },
  199. {
  200. path: '/tenantLogin',
  201. component: () => import('@/views/login'),
  202. hidden: true
  203. },
  204. {
  205. path: '/register',
  206. component: () => import('@/views/register'),
  207. hidden: true
  208. },
  209. {
  210. path: '/404',
  211. component: () => import('@/views/error/404'),
  212. hidden: true
  213. },
  214. {
  215. path: '/401',
  216. component: () => import('@/views/error/401'),
  217. hidden: true
  218. },
  219. {
  220. path: '',
  221. component: Layout,
  222. redirect: 'index',
  223. children: [
  224. {
  225. path: 'index',
  226. component: () => import('@/views/index'),
  227. name: 'Index',
  228. meta: { title: '首页', icon: 'dashboard', affix: true }
  229. }
  230. ]
  231. },
  232. {
  233. path: '/user',
  234. component: Layout,
  235. hidden: true,
  236. redirect: 'noredirect',
  237. children: [
  238. {
  239. path: 'profile',
  240. component: () => import('@/views/system/user/profile/index'),
  241. name: 'Profile',
  242. meta: { title: '个人中心', icon: 'user' }
  243. }
  244. ]
  245. },
  246. ]
  247. // 动态路由,基于用户权限动态去加载
  248. export const dynamicRoutes = [
  249. {
  250. path: '/system/data/index',
  251. component: Layout,
  252. hidden: true,
  253. permissions: ['system:data:index'],
  254. children: [
  255. {
  256. path: 'role/:userId(\\d+)',
  257. component: () => import('@/views/system/data/index'),
  258. name: 'AuthRole',
  259. meta: { title: '数据源配置', activeMenu: '/system/data' }
  260. }
  261. ]
  262. },
  263. {
  264. path: '/system/user-auth',
  265. component: Layout,
  266. hidden: true,
  267. permissions: ['system:user:edit'],
  268. children: [
  269. {
  270. path: 'role/:userId(\\d+)',
  271. component: () => import('@/views/system/user/authRole'),
  272. name: 'AuthRole',
  273. meta: { title: '分配角色', activeMenu: '/system/user' }
  274. }
  275. ]
  276. },
  277. {
  278. path: '/system/fromModel/index',
  279. component: Layout,
  280. hidden: true,
  281. permissions: ['system:fromModel:edit'],
  282. children: [
  283. {
  284. path: 'fromModel/:index',
  285. component: () => import('@/views/system/fromModel/index'),
  286. name: 'fromModel',
  287. meta: { title: '表单建模', activeMenu: '/system/fromModel/index' }
  288. },
  289. // {
  290. // path: '/fromModel/:index',
  291. // component: () => import('@/views/system/fromModel/formBuild'),
  292. // name: 'fromModel',
  293. // meta: { title: '表单建模', activeMenu: '/system/fromModel/formBuild' }
  294. // }
  295. ]
  296. },
  297. {
  298. path: '/system/role-auth',
  299. component: Layout,
  300. hidden: true,
  301. permissions: ['system:role:edit'],
  302. children: [
  303. {
  304. path: 'user/:roleId(\\d+)',
  305. component: () => import('@/views/system/role/authUser'),
  306. name: 'AuthUser',
  307. meta: { title: '分配用户', activeMenu: '/system/role' }
  308. }
  309. ]
  310. },
  311. {
  312. path: '/system/dict-data',
  313. component: Layout,
  314. hidden: true,
  315. permissions: ['system:dict:list'],
  316. children: [
  317. {
  318. path: 'index/:dictId(\\d+)',
  319. component: () => import('@/views/system/dict/data'),
  320. name: 'Data',
  321. meta: { title: '字典数据', activeMenu: '/system/dict' }
  322. }
  323. ]
  324. },
  325. {
  326. path: '/system/tenant/dict-data',
  327. component: Layout,
  328. hidden: true,
  329. permissions: ['system:tenantDict:list'],
  330. children: [
  331. {
  332. path: 'index/:dictId(\\d+)',
  333. component: () => import('@/views/system/tenant/dict/data'),
  334. name: 'TenantData',
  335. meta: { title: '字典数据', activeMenu: '/system/tenant/dict' }
  336. }
  337. ]
  338. },
  339. {
  340. path: '/monitor/job-log',
  341. component: Layout,
  342. hidden: true,
  343. permissions: ['monitor:job:list'],
  344. children: [
  345. {
  346. path: 'index/:jobId(\\d+)',
  347. component: () => import('@/views/monitor/job/log'),
  348. name: 'JobLog',
  349. meta: { title: '调度日志', activeMenu: '/monitor/job' }
  350. }
  351. ]
  352. },
  353. {
  354. path: '/tool/gen-edit',
  355. component: Layout,
  356. hidden: true,
  357. permissions: ['tool:gen:edit'],
  358. children: [
  359. {
  360. path: 'index/:tableId(\\d+)',
  361. component: () => import('@/views/tool/gen/editTable'),
  362. name: 'GenEdit',
  363. meta: { title: '修改生成配置', activeMenu: '/tool/gen' }
  364. }
  365. ]
  366. }
  367. ]
  368. // 防止连续点击多次路由报错
  369. let routerPush = Router.prototype.push;
  370. let routerReplace = Router.prototype.replace;
  371. // push
  372. Router.prototype.push = function push(location) {
  373. return routerPush.call(this, location).catch(err => err)
  374. }
  375. // replace
  376. Router.prototype.replace = function push(location) {
  377. console.log(location)
  378. return routerReplace.call(this, location).catch(err => err)
  379. }
  380. export default new Router({
  381. mode: 'history', // 去掉url中的#
  382. scrollBehavior: () => ({ y: 0 }),
  383. routes: constantRoutes
  384. })