|
|
@ -59,14 +59,15 @@ router.onError((error, to) => {
|
|
|
|
router.beforeEach(async (to, from, next) => {
|
|
|
|
router.beforeEach(async (to, from, next) => {
|
|
|
|
if (store.state.local.token) {
|
|
|
|
if (store.state.local.token) {
|
|
|
|
if (!store.state.auth.permission.length) {
|
|
|
|
if (!store.state.auth.permission.length) {
|
|
|
|
let res = true;
|
|
|
|
let res1 = true,
|
|
|
|
res &= await store.dispatch('auth/getUserInfo');
|
|
|
|
res2 = true;
|
|
|
|
|
|
|
|
res1 = await store.dispatch('auth/getUserInfo');
|
|
|
|
if (config.useLocalRouter) {
|
|
|
|
if (config.useLocalRouter) {
|
|
|
|
store.commit('auth/setPermission', routes);
|
|
|
|
store.commit('auth/setPermission', routes);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
res &= await store.dispatch('auth/getPermission');
|
|
|
|
res2 = await store.dispatch('auth/getPermission');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (res) {
|
|
|
|
if (res1 && res2) {
|
|
|
|
next({ ...to, replace: true });
|
|
|
|
next({ ...to, replace: true });
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
next(false);
|
|
|
|
next(false);
|
|
|
|