index.ts 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. import Vue from 'vue'
  2. import VueRouter, { RouteConfig,RouteRecord } from 'vue-router'
  3. // import HomeView from '../views/HomeView.vue'
  4. import Layout from '@/layout/index.vue'
  5. Vue.use(VueRouter)
  6. export const constantRoutes: Array<any> = [
  7. // {
  8. // path: '/',
  9. // name: 'home',
  10. // component: HomeView
  11. // },
  12. // {
  13. // path: '/about',
  14. // name: 'about',
  15. // // route level code-splitting
  16. // // this generates a separate chunk (about.[hash].js) for this route
  17. // // which is lazy-loaded when the route is visited.
  18. // component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
  19. // },
  20. {
  21. path: '/login',
  22. component: () => import('../views/login.vue'),
  23. hidden: true
  24. },
  25. {
  26. path: '/register',
  27. component: () => import('@/views/register.vue'),
  28. hidden: true
  29. },
  30. {
  31. path: '',
  32. component: Layout,
  33. redirect: 'index',
  34. children: [
  35. {
  36. path: 'index',
  37. component: () => import('@/views/index.vue'),
  38. name: 'Index',
  39. meta: { title: '首页', icon: 'dashboard', affix: true }
  40. }
  41. ]
  42. },
  43. {
  44. path:'/demo',
  45. name:'Demo',
  46. hidden: true,
  47. component:() => import('@/views/demo/index.vue'),
  48. // redirect: 'form',
  49. children:[
  50. {
  51. path:'form',
  52. component:()=> import('@/views/demo/form.vue'),
  53. name:'Form',
  54. meta: {
  55. title: '表单',
  56. activeMenu: '/system/user'
  57. }
  58. },
  59. {
  60. path:'table',
  61. component:()=> import('@/views/demo/table.vue'),
  62. name:'Table',
  63. meta: {
  64. title: '表格',
  65. activeMenu: '/system/user'
  66. }
  67. },
  68. {
  69. path:'moduleView',
  70. component:()=> import('@/views/demo/moduleView.vue'),
  71. name:'ModuleView',
  72. meta: {
  73. title: 'view封装'
  74. }
  75. }
  76. ]
  77. }
  78. ]
  79. // 动态路由,基于用户权限动态去加载
  80. export const dynamicRoutes = [
  81. // {
  82. // path: '/system/user-auth',
  83. // component: Layout,
  84. // hidden: true,
  85. // permissions: ['system:user:edit'],
  86. // children: [{
  87. // path: 'role/:userId(\\d+)',
  88. // component: () => import('@/views/system/user/authRole'),
  89. // name: 'AuthRole',
  90. // meta: {
  91. // title: '分配角色',
  92. // activeMenu: '/system/user'
  93. // }
  94. // }]
  95. // },
  96. // {
  97. // path: '/system/role-auth',
  98. // component: Layout,
  99. // hidden: true,
  100. // permissions: ['system:role:edit'],
  101. // children: [{
  102. // path: 'user/:roleId(\\d+)',
  103. // component: () => import('@/views/system/role/authUser'),
  104. // name: 'AuthUser',
  105. // meta: {
  106. // title: '分配用户',
  107. // activeMenu: '/system/role'
  108. // }
  109. // }]
  110. // },
  111. // {
  112. // path: '/system/dict-data',
  113. // component: Layout,
  114. // hidden: true,
  115. // permissions: ['system:dict:list'],
  116. // children: [{
  117. // path: 'index/:dictId(\\d+)',
  118. // component: () => import('@/views/system/dict/data'),
  119. // name: 'Data',
  120. // meta: {
  121. // title: '字典数据',
  122. // activeMenu: '/system/dict'
  123. // }
  124. // }]
  125. // },
  126. // {
  127. // path: '/monitor/job-log',
  128. // component: Layout,
  129. // hidden: true,
  130. // permissions: ['monitor:job:list'],
  131. // children: [{
  132. // path: 'index/:jobId(\\d+)',
  133. // component: () => import('@/views/monitor/job/log'),
  134. // name: 'JobLog',
  135. // meta: {
  136. // title: '调度日志',
  137. // activeMenu: '/monitor/job'
  138. // }
  139. // }]
  140. // },
  141. // {
  142. // path: '/tool/gen-edit',
  143. // component: Layout,
  144. // hidden: true,
  145. // permissions: ['tool:gen:edit'],
  146. // children: [{
  147. // path: 'index/:tableId(\\d+)',
  148. // component: () => import('@/views/tool/gen/editTable'),
  149. // name: 'GenEdit',
  150. // meta: {
  151. // title: '修改生成配置',
  152. // activeMenu: '/tool/gen'
  153. // }
  154. // }]
  155. // }
  156. ]
  157. // 防止连续点击多次路由报错
  158. let routerPush:any = VueRouter.prototype.push;
  159. VueRouter.prototype.push = function push(location) {
  160. return routerPush.call(this, location).catch((err:any) => err)
  161. }
  162. const router = new VueRouter({
  163. mode: 'history',
  164. base: process.env.BASE_URL,
  165. routes: constantRoutes
  166. })
  167. export default router