index.js 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  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: '/tableMange',
  55. component: Layout,
  56. hidden: true,
  57. name: 'tableMange',
  58. meta: {
  59. title: "表格编辑",
  60. icon: "form",
  61. noCache: false,
  62. link: null
  63. },
  64. children: [
  65. {
  66. path: 'index',
  67. component: () => import('@/views/tableMange/index'),
  68. }
  69. ]
  70. },
  71. {
  72. path: '/progressShow',
  73. component: Layout,
  74. hidden: true,
  75. name: 'progressShow',
  76. meta: {
  77. title: "管道展示",
  78. icon: "form",
  79. noCache: false,
  80. link: null
  81. },
  82. children: [
  83. {
  84. path: 'index',
  85. component: () => import('@/views/bussiness/progressShow'),
  86. }
  87. ]
  88. },
  89. {
  90. path: '/processMange',
  91. component: Layout,
  92. hidden: true,
  93. name: 'processMange',
  94. meta: {
  95. title: "管道流程",
  96. icon: "form",
  97. noCache: false,
  98. link: null
  99. },
  100. children: [
  101. {
  102. path: 'index',
  103. component: () => import('@/views/bussiness/processMange'),
  104. }
  105. ]
  106. },
  107. // {
  108. // path: '/bpmn',
  109. // component: Layout,
  110. // hidden: true,
  111. // name: 'bpmn',
  112. // meta: {
  113. // title: "流程图",
  114. // icon: "form",
  115. // noCache: false,
  116. // link: null
  117. // },
  118. // children: [
  119. // {
  120. // path: 'index',
  121. // component: () => import('@/views/system/bpmn/index.vue'),
  122. // }
  123. // ]
  124. // },
  125. {
  126. path: '/bpmnPro',
  127. component: () => import('@/views/system/bpmnPro'),
  128. hidden: true,
  129. },
  130. {
  131. path: '/login',
  132. component: () => import('@/views/login'),
  133. hidden: true
  134. },
  135. {
  136. path: '/register',
  137. component: () => import('@/views/register'),
  138. hidden: true
  139. },
  140. {
  141. path: '/404',
  142. component: () => import('@/views/error/404'),
  143. hidden: true
  144. },
  145. {
  146. path: '/401',
  147. component: () => import('@/views/error/401'),
  148. hidden: true
  149. },
  150. {
  151. path: '',
  152. component: Layout,
  153. redirect: 'index',
  154. children: [
  155. {
  156. path: 'index',
  157. component: () => import('@/views/index'),
  158. name: 'Index',
  159. meta: { title: '首页', icon: 'dashboard', affix: true }
  160. }
  161. ]
  162. },
  163. {
  164. path: '/user',
  165. component: Layout,
  166. hidden: true,
  167. redirect: 'noredirect',
  168. children: [
  169. {
  170. path: 'profile',
  171. component: () => import('@/views/system/user/profile/index'),
  172. name: 'Profile',
  173. meta: { title: '个人中心', icon: 'user' }
  174. }
  175. ]
  176. },
  177. ]
  178. // 动态路由,基于用户权限动态去加载
  179. export const dynamicRoutes = [
  180. {
  181. path: '/system/data/index',
  182. component: Layout,
  183. hidden: true,
  184. permissions: ['system:data:index'],
  185. children: [
  186. {
  187. path: 'role/:userId(\\d+)',
  188. component: () => import('@/views/system/data/index'),
  189. name: 'AuthRole',
  190. meta: { title: '数据源配置', activeMenu: '/system/data' }
  191. }
  192. ]
  193. },
  194. {
  195. path: '/system/user-auth',
  196. component: Layout,
  197. hidden: true,
  198. permissions: ['system:user:edit'],
  199. children: [
  200. {
  201. path: 'role/:userId(\\d+)',
  202. component: () => import('@/views/system/user/authRole'),
  203. name: 'AuthRole',
  204. meta: { title: '分配角色', activeMenu: '/system/user' }
  205. }
  206. ]
  207. },
  208. {
  209. path: '/system/fromModel/index',
  210. component: Layout,
  211. hidden: true,
  212. permissions: ['system:fromModel:edit'],
  213. children: [
  214. {
  215. path: 'fromModel/:index',
  216. component: () => import('@/views/system/fromModel/index'),
  217. name: 'fromModel',
  218. meta: { title: '表单建模', activeMenu: '/system/fromModel/index' }
  219. },
  220. // {
  221. // path: '/fromModel/:index',
  222. // component: () => import('@/views/system/fromModel/formBuild'),
  223. // name: 'fromModel',
  224. // meta: { title: '表单建模', activeMenu: '/system/fromModel/formBuild' }
  225. // }
  226. ]
  227. },
  228. {
  229. path: '/system/role-auth',
  230. component: Layout,
  231. hidden: true,
  232. permissions: ['system:role:edit'],
  233. children: [
  234. {
  235. path: 'user/:roleId(\\d+)',
  236. component: () => import('@/views/system/role/authUser'),
  237. name: 'AuthUser',
  238. meta: { title: '分配用户', activeMenu: '/system/role' }
  239. }
  240. ]
  241. },
  242. {
  243. path: '/system/dict-data',
  244. component: Layout,
  245. hidden: true,
  246. permissions: ['system:dict:list'],
  247. children: [
  248. {
  249. path: 'index/:dictId(\\d+)',
  250. component: () => import('@/views/system/dict/data'),
  251. name: 'Data',
  252. meta: { title: '字典数据', activeMenu: '/system/dict' }
  253. }
  254. ]
  255. },
  256. {
  257. path: '/system/tenant/dict-data',
  258. component: Layout,
  259. hidden: true,
  260. permissions: ['system:tenantDict:list'],
  261. children: [
  262. {
  263. path: 'index/:dictId(\\d+)',
  264. component: () => import('@/views/system/tenant/dict/data'),
  265. name: 'TenantData',
  266. meta: { title: '字典数据', activeMenu: '/system/tenant/dict' }
  267. }
  268. ]
  269. },
  270. {
  271. path: '/monitor/job-log',
  272. component: Layout,
  273. hidden: true,
  274. permissions: ['monitor:job:list'],
  275. children: [
  276. {
  277. path: 'index/:jobId(\\d+)',
  278. component: () => import('@/views/monitor/job/log'),
  279. name: 'JobLog',
  280. meta: { title: '调度日志', activeMenu: '/monitor/job' }
  281. }
  282. ]
  283. },
  284. {
  285. path: '/tool/gen-edit',
  286. component: Layout,
  287. hidden: true,
  288. permissions: ['tool:gen:edit'],
  289. children: [
  290. {
  291. path: 'index/:tableId(\\d+)',
  292. component: () => import('@/views/tool/gen/editTable'),
  293. name: 'GenEdit',
  294. meta: { title: '修改生成配置', activeMenu: '/tool/gen' }
  295. }
  296. ]
  297. }
  298. ]
  299. // 防止连续点击多次路由报错
  300. let routerPush = Router.prototype.push;
  301. let routerReplace = Router.prototype.replace;
  302. // push
  303. Router.prototype.push = function push(location) {
  304. return routerPush.call(this, location).catch(err => err)
  305. }
  306. // replace
  307. Router.prototype.replace = function push(location) {
  308. console.log(location)
  309. return routerReplace.call(this, location).catch(err => err)
  310. }
  311. export default new Router({
  312. mode: 'history', // 去掉url中的#
  313. scrollBehavior: () => ({ y: 0 }),
  314. routes: constantRoutes
  315. })