index.ts 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  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: '/user',
  45. component: Layout,
  46. hidden: true,
  47. redirect: 'noredirect',
  48. children: [
  49. {
  50. path: 'profile',
  51. component: () => import('@/views/system/user/profile/index.vue'),
  52. name: 'Profile',
  53. meta: { title: '个人中心', icon: 'user' }
  54. }
  55. ]
  56. },
  57. {
  58. path:'/order',
  59. name:'Order',
  60. component:() => import('@/views/demo/order/order.vue')
  61. },
  62. {
  63. path:'/demo',
  64. name:'Demo',
  65. hidden: true,
  66. component:() => import('@/views/demo/index.vue'),
  67. // redirect: 'form',
  68. children:[
  69. {
  70. path:'form',
  71. component:()=> import('@/views/demo/form.vue'),
  72. name:'Form',
  73. meta: {
  74. title: '表单',
  75. activeMenu: '/system/user'
  76. }
  77. },
  78. {
  79. path:'table',
  80. component:()=> import('@/views/demo/table.vue'),
  81. name:'Table',
  82. meta: {
  83. title: '表格',
  84. activeMenu: '/system/user'
  85. }
  86. },
  87. {
  88. path:'moduleView',
  89. component:()=> import('@/views/demo/moduleView.vue'),
  90. name:'ModuleView',
  91. meta: {
  92. title: 'view封装'
  93. }
  94. },
  95. {
  96. path:'bill',
  97. component:()=> import('@/views/demo/bill.vue'),
  98. name:'Bill',
  99. meta: {
  100. title: '单据'
  101. }
  102. },
  103. {
  104. path:'dialog',
  105. component:()=> import('@/views/demo/dialogDemo.vue'),
  106. name:'Dialog',
  107. meta: {
  108. title: '弹窗'
  109. }
  110. },
  111. {
  112. path:'tab',
  113. component:()=> import('@/views/demo/tab.vue'),
  114. name:'Tab',
  115. meta: {
  116. title: '标签'
  117. }
  118. }
  119. ]
  120. }
  121. ]
  122. // 动态路由,基于用户权限动态去加载
  123. export const dynamicRoutes = [
  124. // {
  125. // path: '/system/user-auth',
  126. // component: Layout,
  127. // hidden: true,
  128. // permissions: ['system:user:edit'],
  129. // children: [{
  130. // path: 'role/:userId(\\d+)',
  131. // component: () => import('@/views/system/user/authRole'),
  132. // name: 'AuthRole',
  133. // meta: {
  134. // title: '分配角色',
  135. // activeMenu: '/system/user'
  136. // }
  137. // }]
  138. // },
  139. // {
  140. // path: '/system/role-auth',
  141. // component: Layout,
  142. // hidden: true,
  143. // permissions: ['system:role:edit'],
  144. // children: [{
  145. // path: 'user/:roleId(\\d+)',
  146. // component: () => import('@/views/system/role/authUser'),
  147. // name: 'AuthUser',
  148. // meta: {
  149. // title: '分配用户',
  150. // activeMenu: '/system/role'
  151. // }
  152. // }]
  153. // },
  154. // {
  155. // path: '/system/dict-data',
  156. // component: Layout,
  157. // hidden: true,
  158. // permissions: ['system:dict:list'],
  159. // children: [{
  160. // path: 'index/:dictId(\\d+)',
  161. // component: () => import('@/views/system/dict/data'),
  162. // name: 'Data',
  163. // meta: {
  164. // title: '字典数据',
  165. // activeMenu: '/system/dict'
  166. // }
  167. // }]
  168. // },
  169. // {
  170. // path: '/monitor/job-log',
  171. // component: Layout,
  172. // hidden: true,
  173. // permissions: ['monitor:job:list'],
  174. // children: [{
  175. // path: 'index/:jobId(\\d+)',
  176. // component: () => import('@/views/monitor/job/log'),
  177. // name: 'JobLog',
  178. // meta: {
  179. // title: '调度日志',
  180. // activeMenu: '/monitor/job'
  181. // }
  182. // }]
  183. // },
  184. // {
  185. // path: '/tool/gen-edit',
  186. // component: Layout,
  187. // hidden: true,
  188. // permissions: ['tool:gen:edit'],
  189. // children: [{
  190. // path: 'index/:tableId(\\d+)',
  191. // component: () => import('@/views/tool/gen/editTable'),
  192. // name: 'GenEdit',
  193. // meta: {
  194. // title: '修改生成配置',
  195. // activeMenu: '/tool/gen'
  196. // }
  197. // }]
  198. // }
  199. ]
  200. // 防止连续点击多次路由报错
  201. let routerPush:any = VueRouter.prototype.push;
  202. VueRouter.prototype.push = function push(location) {
  203. return routerPush.call(this, location).catch((err:any) => err)
  204. }
  205. const router = new VueRouter({
  206. mode: 'history',
  207. base: process.env.BASE_URL,
  208. routes: constantRoutes
  209. })
  210. export default router