index.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import Vue from 'vue'
  2. import VueRouter from 'vue-router'
  3. import DefaultLayout from '@/layouts/DefaultLayout/index.vue'
  4. import page from './modules/page'
  5. import form from './modules/form'
  6. import template from './modules/template'
  7. import list from './modules/list'
  8. import editor from './modules/editor'
  9. // 全局处理路由导航重复
  10. const originalPush = VueRouter.prototype.push
  11. VueRouter.prototype.push = function push(location, onResolve, onReject) {
  12. if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
  13. return originalPush.call(this, location).catch(err => err)
  14. }
  15. Vue.use(VueRouter)
  16. export const routes = [
  17. {
  18. path: '/',
  19. component: DefaultLayout,
  20. redirect: '/dashboard',
  21. children: [
  22. {
  23. path: 'dashboard',
  24. component: () => import(/* webpackChunkName: "dashboard" */ '@/views/dashboard/index.vue'),
  25. name: 'Dashboard',
  26. meta: {
  27. title: '首页',
  28. icon: 'dashboard',
  29. affix: true
  30. }
  31. }
  32. ]
  33. },
  34. ...page,
  35. ...template,
  36. ...form,
  37. ...list,
  38. ...editor,
  39. {
  40. path: '/tinymce',
  41. name: 'tinymce',
  42. component: DefaultLayout,
  43. redirect: 'tinymce',
  44. children: [
  45. {
  46. path: '/index',
  47. name: 'tinymceText',
  48. meta: {
  49. title: '富文本'
  50. },
  51. component: () => import(/* webpackChunkName: "tinymce-example" */'@/components/tinymce/example/Index.vue')
  52. }
  53. ]
  54. }
  55. ]
  56. const router = new VueRouter({
  57. routes,
  58. mode: 'history'
  59. })
  60. export default router