无木
2021-08-20 3a5d1a5757c0a2be17e6dd370cbb023ddbb30d5e
fix: refresh failed while token invalid

修复当token失效时,刷新页面可能出现异常的问题

fixed: #1101
4个文件已修改
12 ■■■■ 已修改文件
CHANGELOG.zh_CN.md 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/router/guard/permissionGuard.ts 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/store/modules/user.ts 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/http/axios/checkStatus.ts 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
CHANGELOG.zh_CN.md
@@ -10,6 +10,7 @@
- **其它**
  - 修复部分封装组件在使用插槽时报错的问题
  - 修复`useECharts`的`theme`参数不起作用的问题
  - 修复`Token`失效时,按 F5 刷新页面可能会出现页面加载异常的问题
## 2.7.1(2021-08-16)
src/router/guard/permissionGuard.ts
@@ -72,7 +72,12 @@
    // get userinfo while last fetch time is empty
    if (userStore.getLastUpdateTime === 0) {
      try {
      await userStore.getUserInfoAction();
      } catch (err) {
        next();
        return;
      }
    }
    if (permissionStore.getIsDynamicAddedRoute) {
src/store/modules/user.ts
@@ -128,11 +128,13 @@
     * @description: logout
     */
    async logout(goLogin = false) {
      if (this.token) {
      try {
        await doLogout();
      } catch {
        console.log('注销Token失败');
      }
      }
      this.setToken(undefined);
      this.setSessionTimeout(false);
      goLogin && router.push(PageEnum.BASE_LOGIN);
src/utils/http/axios/checkStatus.ts
@@ -28,9 +28,9 @@
    // 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.
    case 401:
      errMessage = t('sys.api.errMsg401');
      if (stp === SessionTimeoutProcessingEnum.PAGE_COVERAGE) {
        userStore.setToken(undefined);
      errMessage = msg || t('sys.api.errMsg401');
      if (stp === SessionTimeoutProcessingEnum.PAGE_COVERAGE) {
        userStore.setSessionTimeout(true);
      } else {
        userStore.logout(true);