|
@@ -18,14 +18,18 @@ router.beforeEach(async (to, _, next) => {
|
|
|
|
|
|
// 用户刷新页面,localStorage还在,但vuex.store里的东西会reset
|
|
// 用户刷新页面,localStorage还在,但vuex.store里的东西会reset
|
|
const hasToken = getToken();
|
|
const hasToken = getToken();
|
|
|
|
+ console.log(hasToken)
|
|
if (hasToken) {
|
|
if (hasToken) {
|
|
if (whiteList.includes(to.path)) {
|
|
if (whiteList.includes(to.path)) {
|
|
|
|
+ console.log(222222222222222)
|
|
next({
|
|
next({
|
|
path: '/'
|
|
path: '/'
|
|
});
|
|
});
|
|
NProgress.done();
|
|
NProgress.done();
|
|
} else {
|
|
} else {
|
|
|
|
+ console.log(store.getters.token)
|
|
if (!store.getters.token) {
|
|
if (!store.getters.token) {
|
|
|
|
+ console.log(to)
|
|
// 首次以及用户手动刷新,token都会还原回空字符串
|
|
// 首次以及用户手动刷新,token都会还原回空字符串
|
|
const accessRoutes = await store.dispatch('permission/generateRoutes');
|
|
const accessRoutes = await store.dispatch('permission/generateRoutes');
|
|
router.addRoutes(accessRoutes);
|
|
router.addRoutes(accessRoutes);
|
|
@@ -66,6 +70,7 @@ router.beforeEach(async (to, _, next) => {
|
|
}
|
|
}
|
|
next();
|
|
next();
|
|
} else {
|
|
} else {
|
|
|
|
+ console.log(22222)
|
|
if (!whiteList.includes(to.path)) {
|
|
if (!whiteList.includes(to.path)) {
|
|
checkLoginUser();
|
|
checkLoginUser();
|
|
}
|
|
}
|