index.js 9.7 KB

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