index.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import Vue from 'vue'
  2. import Router from 'vue-router'
  3. import path from '@/router/RoutingPath'
  4. Vue.use(Router)
  5. const routerPush = Router.prototype.push
  6. Router.prototype.push = function push(location,onResolve,onReject) {
  7. if (onResolve || onReject){
  8. return routerPush.call(this, location, onResolve, onReject)
  9. }
  10. return routerPush.call(this, location).catch(error => error)
  11. }
  12. export const constantRouterMap = [
  13. {
  14. path: '',
  15. redirect: "home",
  16. hidden: true
  17. },
  18. {
  19. path: '/login',
  20. name: 'login',
  21. component: path.logins,
  22. meta: {
  23. title: '登录',
  24. },
  25. hidden: true,
  26. },
  27. // {path: '/404', component: path.page404, name: 'page404'}, 
  28. {
  29. name: "error",
  30. path: "/error",
  31. hidden: true,
  32. redirect: "404",
  33. component: path.layout,
  34. // alwaysShow: true,
  35. // meta: { title: "报错", icon: "system", noCache: false },
  36. children: [
  37. {
  38. name: "page404",
  39. path: "/404",
  40. hidden: false,
  41. component: path.page404,
  42. meta: { title: "404", icon: "user", noCache: false },
  43. }
  44. ],
  45. },
  46. {
  47. name: "home",
  48. path: "/home",
  49. hidden: false,
  50. redirect: "home",
  51. component: path.layout,
  52. alwaysShow: true,
  53. meta: { title: "工作台", icon: "system", noCache: false },
  54. children: [
  55. {
  56. name: "home",
  57. path: "/home",
  58. hidden: false,
  59. component: path.home,
  60. meta: { title: "工作台", icon: "user", noCache: false },
  61. }
  62. ],
  63. },
  64. ]
  65. const router = new Router({
  66. mode: 'history', // 去掉url中的#
  67. routes: constantRouterMap
  68. })
  69. export default router