index.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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({ path: '/' });
  18. loadingInstance.close();
  19. } else {
  20. next('/teacherdevEntering');
  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: '/Integration/TextAnalyser',
  79. name: 'IntegrationTextAnalysis',
  80. meta: { title: '', keepAlive: false },
  81. component: () =>
  82. import ('../views/teacher-dev/TextAnalysis.vue'),
  83. },
  84. {
  85. path: '/teacherdevEntering',
  86. name: 'teacherdevEntering',
  87. meta: { title: '', keepAlive: false },
  88. component: () =>
  89. import ('../views/teacher-devEntering/index.vue'),
  90. },
  91. {
  92. path: '/creadDocument',
  93. name: 'creadDocument',
  94. component: () =>
  95. import ('../views/teacher-devEntering/creadDocument.vue'),
  96. },
  97. {
  98. path: '/discountCodeList',
  99. name: 'discountCodeList',
  100. component: () =>
  101. import ('@/views/teacher-devEntering/discountCodeList'),
  102. },
  103. {
  104. path: '/textanalysis/Result',
  105. component: () =>
  106. import ('@/views/Textanalysis/index'),
  107. },
  108. {
  109. path: '/textanalysis/WordTable',
  110. component: () =>
  111. import ('@/views/Textanalysis/WordTable'),
  112. },
  113. {
  114. path: '/corpus/seekPage',
  115. component: () =>
  116. import ('@/views/corpus/seekPage'),
  117. },
  118. {
  119. path: '/Integration/Corpus',
  120. name: 'IntegrationCorpus',
  121. component: () =>
  122. import ('@/views/corpus/seekPage'),
  123. },
  124. {
  125. path: '/corpus/Result',
  126. component: () =>
  127. import ('@/views/corpus/Result'),
  128. },
  129. {
  130. path: '/wordcard/table',
  131. component: () =>
  132. import ('@/views/wordcard/table'),
  133. },
  134. {
  135. path: '/wordcard/cread',
  136. component: () =>
  137. import ('@/views/wordcard/cread'),
  138. meta: { title: '创建词汇卡片', keepAlive: true },
  139. },
  140. {
  141. path: '/wordcard/print',
  142. component: () =>
  143. import ('@/views/wordcard/print'),
  144. },
  145. {
  146. path: '/CalligraphyMaster/table',
  147. component: () =>
  148. import ('@/views/CalligraphyMaster/table'),
  149. },
  150. {
  151. path: '/CalligraphyMaster/cread',
  152. component: () =>
  153. import ('@/views/CalligraphyMaster/cread'),
  154. },
  155. {
  156. path: '/CalligraphyMaster/fontFamilyList',
  157. component: () =>
  158. import ('@/views/CalligraphyMaster/fontFamilyList'),
  159. },
  160. {
  161. path: '/textanalysis/checkArticle',
  162. component: () =>
  163. import ('@/views/Textanalysis/CheckArticle'),
  164. },
  165. {
  166. path: '/textanalysis/checkPinyin',
  167. component: () =>
  168. import ('@/views/Textanalysis/CheckPinyin'),
  169. },
  170. {
  171. path: '/textanalysis/checkWord',
  172. component: () =>
  173. import ('@/views/Textanalysis/CheckWord'),
  174. },
  175. {
  176. path: '/textanalysis/checkPos',
  177. component: () =>
  178. import ('@/views/Textanalysis/CheckPos'),
  179. },
  180. {
  181. path: '*',
  182. redirect: '/404',
  183. },
  184. ];
  185. const router = new VueRouter({
  186. // mode: 'history',
  187. base: process.env.BASE_URL,
  188. routes,
  189. });
  190. // 获取原型对象上的push函数
  191. const originalPush = VueRouter.prototype.push;
  192. // 修改原型对象中的push方法
  193. VueRouter.prototype.push = function push(location) {
  194. return originalPush.call(this, location).catch((err) => err);
  195. };
  196. export default router;