import Vue from 'vue'; import VueRouter from 'vue-router'; import Index from '../views/teacher-dev/index.vue'; Vue.use(VueRouter); import { Loading } from 'element-ui'; import { getToken } from '@/utils/auth'; // get token from cookie const routes = [{ path: '/EnterSys', // component: Index, beforeEnter: (to, from, next) => { let loadingInstance = Loading.service({ text: '跳转中...', }); let token = getToken(); if (token) { if (JSON.parse(token).popedom_code_list.indexOf(2000006) === -1) { next({ path: '/' }); loadingInstance.close(); } else { next('/teacherdevEntering'); loadingInstance.close(); } } }, }, { path: '/GoodsDetail', beforeEnter: (to, from, next) => { let loadingInstance = Loading.service({ text: '跳转中...', }); if (to.query.goods_type === 401) { next({ path: '/Preview', query: { id: to.query.goods_id, invok_module: to.query.invok_module, }, }); loadingInstance.close(); } }, }, // 教研中心 { path: '/', name: 'Index', component: Index, meta: { title: '', keepAlive: false }, }, { path: '/login', name: 'login', component: () => import ('../views/login.vue'), }, { path: '/Preview', name: 'Preview', component: () => import ('../views/teacher-dev/Preview.vue'), }, { path: '/Viewmore', name: 'Viewmore', meta: { title: '', keepAlive: false }, component: () => import ('../views/teacher-dev/Viewmore.vue'), }, { path: '/TextAnalysis', name: 'TextAnalysis', meta: { title: '', keepAlive: false }, component: () => import ('../views/teacher-dev/TextAnalysis.vue'), }, { path: '/Integration/TextAnalyser', name: 'IntegrationTextAnalysis', meta: { title: '', keepAlive: false }, component: () => import ('../views/teacher-dev/TextAnalysis.vue'), }, { path: '/teacherdevEntering', name: 'teacherdevEntering', meta: { title: '', keepAlive: false }, component: () => import ('../views/teacher-devEntering/index.vue'), }, { path: '/creadDocument', name: 'creadDocument', component: () => import ('../views/teacher-devEntering/creadDocument.vue'), }, { path: '/discountCodeList', name: 'discountCodeList', component: () => import ('@/views/teacher-devEntering/discountCodeList'), }, { path: '/textanalysis/Result', component: () => import ('@/views/Textanalysis/index'), }, { path: '/textanalysis/WordTable', component: () => import ('@/views/Textanalysis/WordTable'), }, { path: '/corpus/seekPage', component: () => import ('@/views/corpus/seekPage'), }, { path: '/Integration/Corpus', name: 'IntegrationCorpus', component: () => import ('@/views/corpus/seekPage'), }, { path: '/corpus/Result', component: () => import ('@/views/corpus/Result'), }, { path: '/wordcard/table', component: () => import ('@/views/wordcard/table'), }, { path: '/wordcard/cread', component: () => import ('@/views/wordcard/cread'), meta: { title: '创建词汇卡片', keepAlive: true }, }, { path: '/wordcard/print', component: () => import ('@/views/wordcard/print'), }, { path: '/CalligraphyMaster/table', component: () => import ('@/views/CalligraphyMaster/table'), }, { path: '/CalligraphyMaster/cread', component: () => import ('@/views/CalligraphyMaster/cread'), }, { path: '/CalligraphyMaster/fontFamilyList', component: () => import ('@/views/CalligraphyMaster/fontFamilyList'), }, { path: '/textanalysis/checkArticle', component: () => import ('@/views/Textanalysis/CheckArticle'), }, { path: '/textanalysis/checkPinyin', component: () => import ('@/views/Textanalysis/CheckPinyin'), }, { path: '/textanalysis/checkWord', component: () => import ('@/views/Textanalysis/CheckWord'), }, { path: '/textanalysis/checkPos', component: () => import ('@/views/Textanalysis/CheckPos'), }, { path: '*', redirect: '/404', }, ]; const router = new VueRouter({ // mode: 'history', base: process.env.BASE_URL, routes, }); // 获取原型对象上的push函数 const originalPush = VueRouter.prototype.push; // 修改原型对象中的push方法 VueRouter.prototype.push = function push(location) { return originalPush.call(this, location).catch((err) => err); }; export default router;