refactor: 刷新页面获取最新权限

--bug=1018835 --user=刘瑞斌 【系统设置】修改用户组权限后,刷新页面没生效,需要退出重新登录才行 https://www.tapd.cn/55049933/s/1282713
This commit is contained in:
CaptainB 2022-10-28 21:59:03 +08:00 committed by 刘瑞斌
parent b1df71c717
commit efae671f29
2 changed files with 7 additions and 16 deletions

View File

@ -100,22 +100,6 @@ export default {
this.isFixed = localStorage.getItem('app-fixed') === 'true' || false;
this.isCollapse = this.isFixed === true ? false : true;
},
beforeCreate() {
if (checkMicroMode()) {
return;
}
const userStore = useUserStore();
userStore.getIsLogin()
.then(response => {
if (window.location.href.endsWith('/#/login')) {
window.location.replace("/#/setting/personsetting");
}
})
.catch(() => {
userStore.userLogout();
window.location.replace('/#/login');
});
},
//
provide() {
return {

View File

@ -59,6 +59,13 @@ const createRouter = () => new Router({
const router = createRouter()
let userStore = null;
// 刷新整个页面会到这里
import('@/store').then(async ({useUserStore}) => {
userStore = useUserStore();
await userStore.getIsLogin()
});
let store = null;
router.beforeEach(async (to, from, next) => {
if (store === null) {