zhangxiaoxu123456
2022-04-24 60be35fec8bced93ae8b5c55fc554291a819adf9
src/router/index.js
@@ -39,10 +39,11 @@
router.beforeEach((to, from, next) => {
   const token = store.getters.token
  if(to.name !== 'login' && !token) {
    next({name: 'login'})
  }else {
    next()
  }
      next({name: 'login'})
    }else {
      next()
    }
    // if (to.path == '/login') {
    //     removeStore('userinfo');
    // }
@@ -61,30 +62,29 @@
    //         next({ path: '/login' })
    //     }, 1000)
    // }
    //
    // userinfo.expire_time = toTime + 1000 * 60 * 60 * 2
    // localStorage.setItem("userinfo", JSON.stringify(userinfo))
    //
    // 页面不存在
    // console.log(to)
    if (to.matched.length == 0) {
        next({ path: '/404' })
    }
    startTime = new Date().getTime()
    // if (to.matched.length == 0) {
    //     next({ path: '/404' })
    // }
    //
    // startTime = new Date().getTime()
    //
    // NProgress.start();
    next()
})
router.afterEach((to) => {
    if (passPath.indexOf(to.path) === -1) {
        // var consumingTime = new Date().getTime() - startTime
        // notification.info({
        //     message: '此次加载页面消耗时间',
        //     duration:2,
        //     description: `耗时${consumingTime / 1000}秒`,
        // });
    }
    // if (passPath.indexOf(to.path) === -1) {
    //     var consumingTime = new Date().getTime() - startTime
    //     notification.info({
    //         message: '此次加载页面消耗时间',
    //         duration:2,
    //         description: `耗时${consumingTime / 1000}秒`,
    //     });
    // }
    // NProgress.done();
});