index.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. import Vue from 'vue'
  2. import VueRouter from 'vue-router'
  3. import Layout from '@/layout'
  4. import Backstage from '@/backstage'
  5. import ParentView from '@/components/ParentView'
  6. //路由报错处理
  7. Vue.use(VueRouter)
  8. const originalPush = VueRouter.prototype.push
  9. VueRouter.prototype.push = function push(location) {
  10. return originalPush.call(this, location).catch((err) => err)
  11. }
  12. const originalReplace = VueRouter.prototype.replace
  13. VueRouter.prototype.replace = function replace(location) {
  14. return originalReplace.call(this, location).catch((err) => err)
  15. }
  16. const routes = [
  17. {
  18. path: '/',
  19. component: Layout,
  20. redirect: '/home',
  21. // name: 'gf',
  22. children: [
  23. {
  24. path: 'home',
  25. component: () => import('@/views/home/index'),
  26. meta: { title: '首页', icon: '', affix: true }
  27. },
  28. {
  29. path: 'menuList',
  30. component: () => import('@/views/menuList/index'),
  31. meta: { title: '其他', icon: '', affix: true }
  32. },
  33. {
  34. path: 'info',
  35. component: () => import('@/views/info/index'),
  36. meta: { title: '文章详情', icon: '', affix: true }
  37. },
  38. {
  39. path: 'searchKey',
  40. component: () => import('@/views/searchKey/index'),
  41. meta: { title: '搜索页', icon: '', affix: true }
  42. },
  43. {
  44. path: 'contribute',
  45. component: () => import('@/views/contribute/index'),
  46. meta: { title: '投稿中心', icon: '', affix: true }
  47. },
  48. {
  49. path: 'certsearch',
  50. component: () => import('@/views/certsearch/index'),
  51. meta: { title: '证书查询', icon: '', affix: true }
  52. },
  53. {
  54. path: 'problem',
  55. component: () => import('@/views/problem/index'),
  56. meta: { title: '常见问题', icon: '', affix: true }
  57. },
  58. ]
  59. },
  60. // {
  61. // path: '/System',
  62. // component: Backstage,
  63. // redirect: '/System/home',
  64. // // name: 'gf',
  65. // children: [
  66. // {
  67. // path: '/System/home',
  68. // component: () => import('@/views/System/home/index'),
  69. // meta: { title: '工作台', icon: '', affix: true }
  70. // },
  71. // {
  72. // path: '/System/setting',
  73. // redirect: '/System/setting/menu',
  74. // component: ParentView,
  75. // meta: { title: '栏目设置', icon: '', affix: true },
  76. // children: [
  77. // {
  78. // path: '/System/setting/websiteMenu',
  79. // component: () => import('@/views/System/setting/websiteMenu/index'),
  80. // meta: { title: '官网菜单设置', icon: '', affix: true }
  81. // },
  82. // {
  83. // path: '/System/setting/menu',
  84. // component: () => import('@/views/System/setting/menu/index'),
  85. // meta: { title: '后台菜单设置', icon: '', affix: true }
  86. // }
  87. // ]
  88. // }
  89. // ]
  90. // },
  91. {
  92. path: '/login',
  93. name: 'login',
  94. component: () => import('@/views/login/index'),
  95. meta: { title: '登录页', icon: '', affix: true },
  96. hidden: true
  97. },
  98. {
  99. path: '/404',
  100. name: 'error',
  101. component: () => import('@/views/404'),
  102. hidden: true
  103. }
  104. ]
  105. const router = new VueRouter({
  106. mode: 'history', // 去掉url中的#
  107. scrollBehavior: () => ({ y: 0 }),
  108. routes
  109. })
  110. export default router