index.js 11 KB

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