付延余
2022-04-17 8d5e327b23986583ad30d9ec1e1bae3f2e1edb38
src/router/index.js
@@ -1,6 +1,7 @@
import Vue from 'vue'
import Router from 'vue-router'
import { routers } from './router'
import store from "../store";
import { getStore, setStore, removeStore } from '../libs/store'
// 重复点击相同路由拦截报红错误
const originalPush = Router.prototype.push;
@@ -35,7 +36,14 @@
export const router = new Router(RouterConfig);
// 拦截器处理
/*router.beforeEach((to, from, next) => {
// router.beforeEach((to, from, next) => {
   // const token = store.getters.token
  // if(to.name !== 'login' && !token) {
  //   //   next({name: 'login'})
  //   // }else {
  //   //   next()
  //   // }
    // if (to.path == '/login') {
    //     removeStore('userinfo');
    // }
@@ -60,24 +68,24 @@
    // 页面不存在
    // console.log(to)
    if (to.matched.length == 0) {
        next({ path: '/404' })
    }
    // if (to.matched.length == 0) {
    //     next({ path: '/404' })
    // }
    startTime = new Date().getTime()
    // startTime = new Date().getTime()
    // NProgress.start();
    next()
})
    // next()
// })
router.afterEach((to) => {
    if (passPath.indexOf(to.path) === -1) {
// router.afterEach((to) => {
//     if (passPath.indexOf(to.path) === -1) {
        // var consumingTime = new Date().getTime() - startTime
        // notification.info({
        //     message: '此次加载页面消耗时间',
        //     duration:2,
        //     description: `耗时${consumingTime / 1000}秒`,
        // });
    }
    // }
    // NProgress.done();
});*/
// });