index.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. import Vue from 'vue'
  2. import VueRouter from 'vue-router'
  3. import Index from '../views/teacher-dev/index.vue'
  4. Vue.use(VueRouter)
  5. import { Loading } from 'element-ui';
  6. import { getToken } from '@/utils/auth' // get token from cookie
  7. const routes = [{
  8. path: '/EnterSys',
  9. // component: Index,
  10. beforeEnter: (to, from, next) => {
  11. let loadingInstance = Loading.service({
  12. text: '跳转中...'
  13. });
  14. let token = getToken();
  15. if (token) {
  16. if (JSON.parse(token).popedom_code_list.indexOf(2000006) != -1) {
  17. next("/teacherdevEntering");
  18. loadingInstance.close()
  19. } else {
  20. next({ path: "/" });
  21. loadingInstance.close()
  22. }
  23. }
  24. }
  25. },
  26. {
  27. path: '/GoodsDetail',
  28. beforeEnter: (to, from, next) => {
  29. let loadingInstance = Loading.service({
  30. text: '跳转中...'
  31. });
  32. if (to.query.goods_type == 401) {
  33. next({
  34. path: "/Preview",
  35. query: {
  36. id: to.query.goods_id,
  37. invok_module: to.query.invok_module
  38. },
  39. })
  40. loadingInstance.close()
  41. }
  42. }
  43. },
  44. // 教研中心
  45. {
  46. path: '/',
  47. name: 'Index',
  48. component: Index,
  49. meta: { title: '', keepAlive: false },
  50. },
  51. {
  52. path: '/login',
  53. name: 'login',
  54. component: () =>
  55. import('../views/login.vue'),
  56. },
  57. {
  58. path: '/Preview',
  59. name: 'Preview',
  60. component: () =>
  61. import('../views/teacher-dev/Preview.vue')
  62. },
  63. {
  64. path: "/Viewmore",
  65. name: 'Viewmore',
  66. meta: { title: '', keepAlive: false },
  67. component: () =>
  68. import('../views/teacher-dev/Viewmore.vue')
  69. },
  70. {
  71. path: "/TextAnalysis",
  72. name: 'TextAnalysis',
  73. meta: { title: '', keepAlive: false },
  74. component: () =>
  75. import('../views/teacher-dev/TextAnalysis.vue')
  76. },
  77. {
  78. path: '/teacherdevEntering',
  79. name: 'teacherdevEntering',
  80. meta: { title: '', keepAlive: false },
  81. component: () =>
  82. import('../views/teacher-devEntering/index.vue')
  83. },
  84. {
  85. path: '/creadDocument',
  86. name: 'creadDocument',
  87. component: () =>
  88. import('../views/teacher-devEntering/creadDocument.vue')
  89. },
  90. {
  91. path: '/discountCodeList',
  92. name: "discountCodeList",
  93. component: () =>
  94. import('@/views/teacher-devEntering/discountCodeList')
  95. },
  96. {
  97. path: '/textanalysis/Result',
  98. component: () =>
  99. import('@/views/Textanalysis/index')
  100. },
  101. {
  102. path: '/textanalysis/WordTable',
  103. component: () =>
  104. import('@/views/Textanalysis/WordTable')
  105. },
  106. {
  107. path: '/corpus/seekPage',
  108. component: () =>
  109. import('@/views/corpus/seekPage')
  110. },
  111. {
  112. path: '/corpus/Result',
  113. component: () =>
  114. import('@/views/corpus/Result')
  115. },
  116. {
  117. path: '/wordcard/table',
  118. component: () =>
  119. import('@/views/wordcard/table')
  120. },
  121. {
  122. path: '/wordcard/cread',
  123. component: () =>
  124. import('@/views/wordcard/cread'),
  125. meta: { title: '创建词汇卡片', keepAlive: true }
  126. },
  127. {
  128. path: '/wordcard/print',
  129. component: () =>
  130. import('@/views/wordcard/print')
  131. },
  132. {
  133. path: '/CalligraphyMaster/table',
  134. component: () =>
  135. import('@/views/CalligraphyMaster/table')
  136. },
  137. {
  138. path: '/CalligraphyMaster/cread',
  139. component: () =>
  140. import('@/views/CalligraphyMaster/cread')
  141. },
  142. {
  143. path: '/CalligraphyMaster/fontFamilyList',
  144. component: () =>
  145. import('@/views/CalligraphyMaster/fontFamilyList')
  146. },
  147. {
  148. path: '*',
  149. redirect: '/404',
  150. }
  151. ]
  152. const router = new VueRouter({
  153. // mode: 'history',
  154. base: process.env.BASE_URL,
  155. routes
  156. })
  157. //获取原型对象上的push函数
  158. const originalPush = VueRouter.prototype.push
  159. //修改原型对象中的push方法
  160. VueRouter.prototype.push = function push(location) {
  161. return originalPush.call(this, location).catch(err => err)
  162. }
  163. export default router