|
|
|
@ -24,30 +24,28 @@ router.beforeEach((to, from, next) => {
|
|
|
|
|
if (store.getters.roles.length === 0) {
|
|
|
|
|
isRelogin.show = true;
|
|
|
|
|
// 判断当前用户是否已拉取完user_info信息
|
|
|
|
|
store
|
|
|
|
|
.dispatch("GetInfo")
|
|
|
|
|
.then((res) => {
|
|
|
|
|
isRelogin.show = false;
|
|
|
|
|
store.dispatch("GenerateRoutes").then((accessRoutes) => {
|
|
|
|
|
// 根据roles权限生成可访问的路由表
|
|
|
|
|
// console.log(res);
|
|
|
|
|
router.addRoutes(accessRoutes); // 动态添加可访问路由表
|
|
|
|
|
//刷新之后,要去的路由肯定是自己已经保存过的新路由
|
|
|
|
|
let refresh = "";
|
|
|
|
|
if (store.state.user.new1.indexOf(to.path) != -1) {
|
|
|
|
|
refresh = to.path;
|
|
|
|
|
}
|
|
|
|
|
// console.log(to.path);
|
|
|
|
|
//进入添加的第一个路由
|
|
|
|
|
next({ path: refresh || res[0].path });
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
.catch((err) => {
|
|
|
|
|
store.dispatch("LogOut").then(() => {
|
|
|
|
|
Message.error(err);
|
|
|
|
|
next({ path: "/" });
|
|
|
|
|
});
|
|
|
|
|
store.dispatch("GetInfo").then((res) => {
|
|
|
|
|
isRelogin.show = false;
|
|
|
|
|
store.dispatch("GenerateRoutes").then((accessRoutes) => {
|
|
|
|
|
// 根据roles权限生成可访问的路由表
|
|
|
|
|
// console.log(res);
|
|
|
|
|
router.addRoutes(accessRoutes); // 动态添加可访问路由表
|
|
|
|
|
//刷新之后,要去的路由肯定是自己已经保存过的新路由
|
|
|
|
|
let refresh = "";
|
|
|
|
|
if (store.state.user.new1.indexOf(to.path) != -1) {
|
|
|
|
|
refresh = to.path;
|
|
|
|
|
}
|
|
|
|
|
// console.log(to.path);
|
|
|
|
|
//进入添加的第一个路由
|
|
|
|
|
next({ path: refresh || res[0].path });
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
// .catch((err) => {
|
|
|
|
|
// store.dispatch("LogOut").then(() => {
|
|
|
|
|
// Message.error(err);
|
|
|
|
|
// next({ path: "/" });
|
|
|
|
|
// });
|
|
|
|
|
// });
|
|
|
|
|
} else {
|
|
|
|
|
if (
|
|
|
|
|
store.state.user.old1.indexOf(to.path) != -1 &&
|
|
|
|
|