zhengyiming
2 天以前 64eb1c2ebfc25f11f5757a0eef04de230fa8fa15
src/store/modules/user.ts
@@ -68,15 +68,7 @@
          .then((res) => {
            if (res) {
              console.log('res: ', res);
              this.setToken(res.accessToken);
              const accountInfo = getAccountInfoFromAccessToken(res.accessToken);
              this.setName(accountInfo.name);
              this.setAccountInfo(accountInfo);
              // 获取用户信息
              this.setUserInfo(res);
              this.loginSuccess(res);
              resolve();
            }
@@ -87,6 +79,27 @@
      });
    },
    async twoFactorLoginSms(params: API.TwoFactorLoginSmsInput) {
      try {
        let res = await accountServices.twoFactorLoginSms(params, { showLoading: false });
        if (res) {
          this.loginSuccess(res);
        }
      } catch (error) {}
    },
    loginSuccess(res: API.IdentityModelToken) {
      this.setToken(res.accessToken);
      const accountInfo = getAccountInfoFromAccessToken(res.accessToken);
      this.setName(accountInfo.name);
      this.setAccountInfo(accountInfo);
      // 获取用户信息
      this.setUserInfo(res);
    },
    // 登出 清空缓存
    logout(redirectPath = '/') {
      return new Promise(async (resolve) => {