mirror of
https://github.com/vbenjs/vben-admin-thin-next.git
synced 2025-02-02 18:08:40 +08:00
fix: refresh failed while token invalid
修复当token失效时,刷新页面可能出现异常的问题 fixed: #1101
This commit is contained in:
parent
2c867b3d63
commit
3a5d1a5757
@ -10,6 +10,7 @@
|
|||||||
- **其它**
|
- **其它**
|
||||||
- 修复部分封装组件在使用插槽时报错的问题
|
- 修复部分封装组件在使用插槽时报错的问题
|
||||||
- 修复`useECharts`的`theme`参数不起作用的问题
|
- 修复`useECharts`的`theme`参数不起作用的问题
|
||||||
|
- 修复`Token`失效时,按 F5 刷新页面可能会出现页面加载异常的问题
|
||||||
|
|
||||||
## 2.7.1(2021-08-16)
|
## 2.7.1(2021-08-16)
|
||||||
|
|
||||||
|
@ -72,7 +72,12 @@ export function createPermissionGuard(router: Router) {
|
|||||||
|
|
||||||
// get userinfo while last fetch time is empty
|
// get userinfo while last fetch time is empty
|
||||||
if (userStore.getLastUpdateTime === 0) {
|
if (userStore.getLastUpdateTime === 0) {
|
||||||
await userStore.getUserInfoAction();
|
try {
|
||||||
|
await userStore.getUserInfoAction();
|
||||||
|
} catch (err) {
|
||||||
|
next();
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (permissionStore.getIsDynamicAddedRoute) {
|
if (permissionStore.getIsDynamicAddedRoute) {
|
||||||
|
@ -128,10 +128,12 @@ export const useUserStore = defineStore({
|
|||||||
* @description: logout
|
* @description: logout
|
||||||
*/
|
*/
|
||||||
async logout(goLogin = false) {
|
async logout(goLogin = false) {
|
||||||
try {
|
if (this.token) {
|
||||||
await doLogout();
|
try {
|
||||||
} catch {
|
await doLogout();
|
||||||
console.log('注销Token失败');
|
} catch {
|
||||||
|
console.log('注销Token失败');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.setToken(undefined);
|
this.setToken(undefined);
|
||||||
this.setSessionTimeout(false);
|
this.setSessionTimeout(false);
|
||||||
|
@ -28,9 +28,9 @@ export function checkStatus(
|
|||||||
// Jump to the login page if not logged in, and carry the path of the current page
|
// Jump to the login page if not logged in, and carry the path of the current page
|
||||||
// Return to the current page after successful login. This step needs to be operated on the login page.
|
// Return to the current page after successful login. This step needs to be operated on the login page.
|
||||||
case 401:
|
case 401:
|
||||||
errMessage = t('sys.api.errMsg401');
|
userStore.setToken(undefined);
|
||||||
|
errMessage = msg || t('sys.api.errMsg401');
|
||||||
if (stp === SessionTimeoutProcessingEnum.PAGE_COVERAGE) {
|
if (stp === SessionTimeoutProcessingEnum.PAGE_COVERAGE) {
|
||||||
userStore.setToken(undefined);
|
|
||||||
userStore.setSessionTimeout(true);
|
userStore.setSessionTimeout(true);
|
||||||
} else {
|
} else {
|
||||||
userStore.logout(true);
|
userStore.logout(true);
|
||||||
|
Loading…
Reference in New Issue
Block a user