index.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. import Vue from 'vue';
  2. import Router from 'vue-router';
  3. Vue.use(Router);
  4. /**
  5. * Note: sub-menu only appear when route children.length >= 1
  6. * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
  7. *
  8. * hidden: true if set true, item will not show in the sidebar(default is false)
  9. * alwaysShow: true if set true, will always show the root menu
  10. * if not set alwaysShow, when item has more than one children route,
  11. * it will becomes nested mode, otherwise not show the root menu
  12. * redirect: noRedirect if set noRedirect will no redirect in the breadcrumb
  13. * name:'router-name' the name is used by <keep-alive> (must set!!!)
  14. * meta : {
  15. roles: ['admin','editor'] control the page roles (you can set multiple roles)
  16. title: 'title' the name show in sidebar and breadcrumb (recommend set)
  17. icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
  18. breadcrumb: false if set false, the item will hidden in breadcrumb(default is true)
  19. activeMenu: '/example/list' if set path, the sidebar will highlight the path you set
  20. }
  21. */
  22. /**
  23. * constantRoutes
  24. * a base page that does not have permission requirements
  25. * all roles can be accessed
  26. */
  27. export const constantRoutes = [{
  28. path: '/404',
  29. component: () =>
  30. import('@/views/404'),
  31. hidden: true
  32. },
  33. {
  34. path: '/login',
  35. component: () =>
  36. import('@/views/login'),
  37. hidden: true
  38. },
  39. {
  40. path: '/',
  41. redirect: '/EnterSys',
  42. hidden: true
  43. },
  44. {
  45. path: '/EnterSys',
  46. component: () =>
  47. import('@/views/courseList')
  48. },
  49. {
  50. path: '/courseView',
  51. component: () =>
  52. import('@/views/courseView')
  53. },
  54. {
  55. path: '/bookView',
  56. component: () =>
  57. import('@/views/bookView')
  58. },
  59. {
  60. path: '/adultInput',
  61. component: () =>
  62. import('@/views/adultInput')
  63. },
  64. {
  65. path: '/adultInput3',
  66. component: () =>
  67. import('@/views/adultInput3')
  68. },
  69. {
  70. path: '/JoinLine',
  71. component: () =>
  72. import('@/components/common/JoinLine')
  73. },
  74. {
  75. path: '/discountCodeList',
  76. component: () =>
  77. import('@/views/discountCodeList')
  78. },
  79. {
  80. path: '/GoodsDetail',
  81. component: () =>
  82. import('@/views/TextbookDetail')
  83. },
  84. // 404 page must be placed at the end !!!
  85. { path: '*', redirect: '/', hidden: true }
  86. ];
  87. const createRouter = () =>
  88. new Router({
  89. // mode: 'history', // require service support
  90. scrollBehavior: () => ({ y: 0 }),
  91. routes: constantRoutes
  92. });
  93. const router = createRouter();
  94. // Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
  95. export function resetRouter() {
  96. const newRouter = createRouter();
  97. router.matcher = newRouter.matcher; // reset router
  98. }
  99. export default router;