yuang-framework-ui-common 1.0.30 → 1.0.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/config/httpConfig.ts
CHANGED
@@ -39,7 +39,7 @@ http.interceptors.request.use(async config => {
|
|
39
39
|
|
40
40
|
|
41
41
|
/* 响应拦截器 */
|
42
|
-
http.interceptors.response.use((res: any) => {
|
42
|
+
http.interceptors.response.use(async (res: any) => {
|
43
43
|
if (!res?.data?.statusCode) {
|
44
44
|
showErrorMessage(messageMap.responseSturctError);
|
45
45
|
return Promise.reject(new Error(messageMap.responseSturctError));
|
@@ -69,19 +69,9 @@ http.interceptors.response.use((res: any) => {
|
|
69
69
|
window.location.href = getSsoLoginUrl() || '';
|
70
70
|
return Promise.reject(new Error(res?.data?.message));
|
71
71
|
} else if (res?.data?.statusCode === 815002) {
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
}
|
76
|
-
axios.get(`/sso-api/client/auth/getSsoRefreshToken`, config).then(innerRes => {
|
77
|
-
if (innerRes?.data?.statusCode !== 200) {
|
78
|
-
return;
|
79
|
-
}
|
80
|
-
setSsoAccessToken(innerRes.data.data);
|
81
|
-
// 重发请求
|
82
|
-
return axios.request(res.config);
|
83
|
-
});
|
84
|
-
return;
|
72
|
+
await refreshSsoAccessToken(res);
|
73
|
+
// 重发请求
|
74
|
+
return axios.request(res.config);
|
85
75
|
} else if (res?.data?.statusCode === 815003) {
|
86
76
|
showErrorMessage(res?.data?.message || messageMap.requestError);
|
87
77
|
return Promise.reject(new Error(res?.data?.message));
|
@@ -134,4 +124,24 @@ const beforeRequestConfig = (config: any) => {
|
|
134
124
|
}
|
135
125
|
|
136
126
|
|
127
|
+
/**
|
128
|
+
* 刷新ssoAccessToken
|
129
|
+
* @param res
|
130
|
+
*/
|
131
|
+
const refreshSsoAccessToken = (res: any) => {
|
132
|
+
return new Promise((resolve, reject) => {
|
133
|
+
const config = res.config
|
134
|
+
config.params = {
|
135
|
+
ssoRefreshToken: encodeURIComponent(getLocalStorageItem("ssoRefreshToken") ?? ''),
|
136
|
+
}
|
137
|
+
axios.get(`/sso-api/client/auth/getSsoRefreshToken`, config).then(res => {
|
138
|
+
if (res?.data?.statusCode !== 200) {
|
139
|
+
return reject();
|
140
|
+
}
|
141
|
+
setSsoAccessToken(res.data.data);
|
142
|
+
return resolve(void 0);
|
143
|
+
});
|
144
|
+
});
|
145
|
+
}
|
146
|
+
|
137
147
|
export { http }
|
package/package.json
CHANGED