直接看代码:
/**
* [路由跳转验证]
* 开启全局进度条,监听路由跳转
*/
router.beforeEach(function (to, from, next) {
iView.LoadingBar.start();
let islogin = Tools.session.get("jwt-token") || false;
if (to.name && to.name.toUpperCase() === 'LOGIN' && islogin) {
//已登录的情况再去登录页,跳转至首页
next({path: '/system'});
}
if (to.path && (to.path.toUpperCase().indexOf('SYSTEM') >= 0)) {
//未登录 进入登录模块需要登录
if (!islogin) {
next({path: '/login'})
}else{
next();
}
}else{
next();
}
next();
});
router.afterEach(route => {
iView.LoadingBar.finish();
});
看不懂,找我。哈哈