Skip to content

Commit 1b826ee

Browse files
authored
Merge pull request #187 from mfish-qf/develop
Develop
2 parents ac2483a + 273f374 commit 1b826ee

File tree

7 files changed

+19
-32
lines changed

7 files changed

+19
-32
lines changed

src/layouts/default/header/components/tenant-dropdown/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
let userInfo = toRaw(userStore.getUserInfo);
5858
while (!userInfo) {
5959
userInfo = toRaw(userStore.getUserInfo);
60-
await sleep(100);
60+
await sleep(500);
6161
}
6262
tenants.value = userInfo.tenants;
6363
const tenant: TenantVo = tenants.value?.find((tenant) => tenant.id == userStore.getTenantId) as TenantVo;

src/layouts/default/header/components/user-dropdown/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
let userInfo = toRaw(userStore.getUserInfo);
8181
while (!userInfo) {
8282
userInfo = toRaw(userStore.getUserInfo);
83-
await sleep(100);
83+
await sleep(500);
8484
}
8585
getUserInfo.id = userInfo.id;
8686
getUserInfo.nickname = userInfo.nickname ? userInfo.nickname : userInfo.account;

src/logics/InitAppConfig.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { sleep } from "/@/utils/Utils";
1818
export async function initAppConfigStore() {
1919
const userStore = useUserStoreWithOut();
2020
while (!userStore.getUserInfo) {
21-
await sleep(100);
21+
await sleep(500);
2222
}
2323
setAppConfigStore().then();
2424
}

src/store/modules/Lock.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { defineStore } from "pinia";
33
import { LOCK_INFO_KEY } from "/@/enums/CacheEnum";
44
import { Persistent } from "/@/utils/cache/Persistent";
55
import { useUserStore } from "./User";
6+
import { oauth2Config } from "/@/settings/LoginSetting";
67

78
interface LockState {
89
lockInfo: Nullable<LockInfo>;
@@ -40,10 +41,10 @@ export const useLockStore = defineStore({
4041
const res = await userStore.login({
4142
username: username!,
4243
password: password!,
43-
client_id: "system",
44-
client_secret: "system",
44+
client_id: oauth2Config.client_id,
45+
client_secret: oauth2Config.client_secret,
4546
grant_type: "password",
46-
redirect_uri: "http://baidu.com",
47+
redirect_uri: oauth2Config.redirect_uri,
4748
mode: "none"
4849
});
4950
if (res) {

src/store/modules/User.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -169,17 +169,15 @@ export const useUserStore = defineStore({
169169
async logout() {
170170
if (this.getToken) {
171171
try {
172-
const result = await doLogout();
173-
if (result) {
174-
this.setToken(undefined);
175-
this.setRefreshToken(undefined);
176-
this.setSessionTimeout(false);
177-
this.setUserInfo(null);
178-
this.setTenantId(undefined);
179-
clearAuthCache(true);
180-
this.setIsLogout(true);
181-
await router.push(PageEnum.BASE_LOGIN);
182-
}
172+
await doLogout();
173+
this.setToken(undefined);
174+
this.setRefreshToken(undefined);
175+
this.setSessionTimeout(false);
176+
this.setUserInfo(null);
177+
this.setTenantId(undefined);
178+
clearAuthCache(true);
179+
this.setIsLogout(true);
180+
await router.push(PageEnum.BASE_LOGIN);
183181
} catch {
184182
throw new Error("注销Token失败");
185183
}

src/utils/http/axios/CheckStatus.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,12 @@ export function checkStatus(
2929
break;
3030
// 401: 认证失败返回401
3131
case 401:
32-
userStore.setToken(undefined);
3332
errMessage = t("sys.api.errMsg401");
3433
if (stp === SessionTimeoutProcessingEnum.PAGE_COVERAGE) {
3534
userStore.setSessionTimeout(true);
3635
break;
3736
}
38-
userStore.logout();
37+
userStore.logout().then();
3938
break;
4039
case 403:
4140
errMessage = t("sys.api.errMsg403");

src/utils/http/axios/index.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import { deepMerge, setObjToUrlParams } from "/@/utils";
1313
import { useErrorLogStoreWithOut } from "/@/store/modules/ErrorLog";
1414
import { useI18n } from "/@/hooks/web/UseI18n";
1515
import { formatRequestDate, joinTimestamp, messageTips } from "./Helper";
16-
import { useUserStoreWithOut } from "/@/store/modules/User";
1716
import { AxiosRetry } from "/@/utils/http/axios/AxiosRetry";
1817

1918
const globSetting = useGlobSetting();
@@ -42,8 +41,8 @@ const transform: AxiosTransform = {
4241
// 抛出请求异常
4342
throw new Error(t("sys.api.apiRequestFailed"));
4443
}
45-
let { code, msg } = data;
46-
const hasSuccess = data && code === ResultEnum.SUCCESS;
44+
let { msg } = data;
45+
const hasSuccess = data && data.code === ResultEnum.SUCCESS;
4746
if (hasSuccess) {
4847
if (msg === null || msg === undefined || msg === "") {
4948
msg = t("sys.api.operationSuccess");
@@ -54,16 +53,6 @@ const transform: AxiosTransform = {
5453
}
5554
return data.data;
5655
}
57-
// 在此处根据自己项目的实际情况对不同的code执行不同的操作
58-
// 如果不希望中断当前请求,请return数据,否则直接抛出异常即可
59-
switch (code) {
60-
case ResultEnum.TIMEOUT:
61-
msg = t("sys.api.timeoutMessage");
62-
const userStore = useUserStoreWithOut();
63-
userStore.setToken(undefined);
64-
userStore.logout().then();
65-
break;
66-
}
6756
// errorMessageMode=‘modal’的时候会显示modal错误弹窗,而不是消息提示,用于一些比较重要的错误
6857
// errorMessageMode='none' 一般是调用时明确表示不希望自动弹出错误提示
6958
messageTips(options.errorMessageMode, msg, true, 0);

0 commit comments

Comments
 (0)