|
|
@ -59,13 +59,18 @@ 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) {
|
|
|
|
await store.dispatch('auth/getUserInfo');
|
|
|
|
let res = true;
|
|
|
|
|
|
|
|
res &= await store.dispatch('auth/getUserInfo');
|
|
|
|
if (config.useLocalRouter) {
|
|
|
|
if (config.useLocalRouter) {
|
|
|
|
store.commit('auth/setPermission', routes);
|
|
|
|
store.commit('auth/setPermission', routes);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
await store.dispatch('auth/getPermission');
|
|
|
|
res &= await store.dispatch('auth/getPermission');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (res) {
|
|
|
|
next({ ...to, replace: true });
|
|
|
|
next({ ...to, replace: true });
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
next(false);
|
|
|
|
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
console.info(`[router] from ${from.name} to ${to.name}`);
|
|
|
|
console.info(`[router] from ${from.name} to ${to.name}`);
|
|
|
|
const deep = (route) => {
|
|
|
|
const deep = (route) => {
|
|
|
|