import Router from 'vue-router' import router from "./index" // 解决ElementUI导航栏中的vue-router在3.0版本以上重复点菜单报错问题 const originalPush = Router.prototype.push Router.prototype.push = function push(location) { return originalPush.call(this, location).catch(err => err) } router.beforeEach((to, from, next) => { console.log(from); console.log(to); if (to.fullPath === '/' || to.name === '*') { let { code, ticket } = to.query; if (code && ticket) { next({ path: "/mainPage", query: { code, ticket }, replace: true }); } else { next({ path: "/mainPage", replace: true }); } } else { if (from.path === '/login' || from.name === 'login') { if (localStorage.getItem('Authorization')) { next(); } else { next(false); // return false } } else { next(); } } });