index.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. import Vue from 'vue'
  2. import Router from 'vue-router'
  3. import { getToken } from "@/utils/auth";
  4. Vue.use(Router)
  5. let userMessage = getToken() ? JSON.parse(getToken()) : null
  6. let url = userMessage ? import('@/views/bookShelf/index.vue') : import('@/views/bookStore/index.vue')
  7. /**
  8. * Note: sub-menu only appear when route children.length >= 1
  9. * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
  10. *
  11. * hidden: true if set true, item will not show in the sidebar(default is false)
  12. * alwaysShow: true if set true, will always show the root menu
  13. * if not set alwaysShow, when item has more than one children route,
  14. * it will becomes nested mode, otherwise not show the root menu
  15. * redirect: noRedirect if set noRedirect will no redirect in the breadcrumb
  16. * name:'router-name' the name is used by <keep-alive> (must set!!!)
  17. * meta : {
  18. roles: ['admin','editor'] control the page roles (you can set multiple roles)
  19. title: 'title' the name show in sidebar and breadcrumb (recommend set)
  20. icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
  21. breadcrumb: false if set false, the item will hidden in breadcrumb(default is true)
  22. activeMenu: '/example/list' if set path, the sidebar will highlight the path you set
  23. }
  24. */
  25. /**
  26. * constantRoutes
  27. * a base page that does not have permission requirements
  28. * all roles can be accessed
  29. */
  30. export const constantRoutes = [{
  31. path: '/404',
  32. component: () =>
  33. import ('@/views/404'),
  34. hidden: true
  35. },
  36. {
  37. path: '/login',
  38. component: () =>
  39. import ('@/views/login'),
  40. hidden: true
  41. },
  42. {
  43. path: '/',
  44. redirect: '/EnterSys',
  45. hidden: true
  46. },
  47. {
  48. path: '/EnterSys',
  49. component: () =>
  50. url
  51. },
  52. {
  53. path: '/bookStore',
  54. component: () =>
  55. import ('@/views/bookStore/index.vue')
  56. },
  57. {
  58. path: '/bookStore/all',
  59. component: () =>
  60. import ('@/views/bookStore/all.vue')
  61. },
  62. {
  63. path: '/articleDetail',
  64. component: () =>
  65. import ('@/views/bookShelf/articleDetail')
  66. },
  67. {
  68. path: '/dictionary',
  69. component: () =>
  70. import ('@/views/dictionary/index.vue')
  71. },
  72. {
  73. path: '/dictionary/detail',
  74. component: () =>
  75. import ('@/views/dictionary/searchDetail.vue')
  76. },
  77. {
  78. path: '/search',
  79. component: () =>
  80. import ('@/views/search/index.vue')
  81. },
  82. {
  83. path: '/search/detail',
  84. component: () =>
  85. import ('@/views/search/searchDetail.vue')
  86. },
  87. {
  88. path: '/bookShelf',
  89. component: () =>
  90. import ('@/views/bookShelf/index.vue')
  91. },
  92. {
  93. path: '/bookItem',
  94. component: () =>
  95. import ('@/views/bookShelf/bookItem.vue')
  96. },
  97. {
  98. path: '/bookPeruseItem',
  99. component: () =>
  100. import ('@/views/bookShelf/bookPeruseItem.vue')
  101. },
  102. {
  103. path: '/courseDetail',
  104. component: () =>
  105. import ('@/views/bookShelf/courseDetail.vue')
  106. },
  107. {
  108. path: '/videoDetail',
  109. component: () =>
  110. import ('@/views/bookShelf/videoDetail.vue')
  111. },
  112. {
  113. path: '/peraonal',
  114. component: () =>
  115. import ('@/views/personalCenter/index.vue')
  116. },
  117. {
  118. path: '/register',
  119. component: () =>
  120. import ('@/views/register.vue')
  121. },
  122. {
  123. path: '/evaluation',
  124. component: () =>
  125. import ('@/views/evaluation/index.vue')
  126. },
  127. {
  128. path: '/evaluDetail',
  129. component: () =>
  130. import ('@/views/evaluation/evaluDetail.vue')
  131. },
  132. {
  133. path: '/magazineDetail',
  134. component: () =>
  135. import ('@/views/bookShelf/magazineDetail.vue')
  136. },
  137. {
  138. path: '/reporter',
  139. component: () =>
  140. import ('@/views/reporter/index.vue')
  141. },
  142. {
  143. path: '/orgManage',
  144. component: () =>
  145. import ('@/views/organize_manage/PersonList.vue')
  146. },
  147. {
  148. path: '/editOrgPerson',
  149. component: () =>
  150. import ('@/views/organize_manage/EditPerson.vue')
  151. },
  152. {
  153. path: '/subscribe',
  154. component: () =>
  155. import ('@/views/bookStore/Subscribe.vue')
  156. },
  157. {
  158. path: '/articlePeruseDetail',
  159. component: () =>
  160. import ('@/views/bookShelf/articlePeruseDetail.vue')
  161. },
  162. {
  163. path: '/share',
  164. component: () =>
  165. import ('@/views/bookShelf/share.vue')
  166. },
  167. {
  168. path: '/articleShareDetail',
  169. component: () =>
  170. import ('@/views/bookShelf/articleShareDetail.vue')
  171. },
  172. // 404 page must be placed at the end !!!
  173. { path: '*', redirect: '/', hidden: true }
  174. ]
  175. const createRouter = () =>
  176. new Router({
  177. // mode: 'history', // require service support
  178. scrollBehavior: () => ({ y: 0 }),
  179. routes: constantRoutes
  180. })
  181. const router = createRouter()
  182. // Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
  183. export function resetRouter() {
  184. const newRouter = createRouter()
  185. router.matcher = newRouter.matcher // reset router
  186. }
  187. export default router