release: update 5.4.0

This commit is contained in:
xiaoxian521
2024-04-22 14:15:05 +08:00
parent 270df1b17a
commit e25f4bcf39
44 changed files with 1013 additions and 903 deletions

View File

@@ -35,16 +35,16 @@ class PureHttp {
this.httpInterceptorsResponse();
}
/** token过期后暂存待执行的请求 */
/** `token`过期后,暂存待执行的请求 */
private static requests = [];
/** 防止重复刷新token */
/** 防止重复刷新`token` */
private static isRefreshing = false;
/** 初始化配置对象 */
private static initConfig: PureHttpRequestConfig = {};
/** 保存当前Axios实例对象 */
/** 保存当前`Axios`实例对象 */
private static axiosInstance: AxiosInstance = Axios.create(defaultConfig);
/** 重连原始请求 */
@@ -72,9 +72,9 @@ class PureHttp {
PureHttp.initConfig.beforeRequestCallback(config);
return config;
}
/** 请求白名单放置一些不需要token的接口通过设置请求白名单防止token过期后再请求造成的死循环问题 */
/** 请求白名单,放置一些不需要`token`的接口(通过设置请求白名单,防止`token`过期后再请求造成的死循环问题) */
const whiteList = ["/refresh-token", "/login"];
return whiteList.find(url => url === config.url)
return whiteList.some(url => config.url.endsWith(url))
? config
: new Promise(resolve => {
const data = getToken();
@@ -172,22 +172,22 @@ class PureHttp {
});
}
/** 单独抽离的post工具函数 */
/** 单独抽离的`post`工具函数 */
public post<T, P>(
url: string,
params?: AxiosRequestConfig<T>,
params?: AxiosRequestConfig<P>,
config?: PureHttpRequestConfig
): Promise<P> {
return this.request<P>("post", url, params, config);
): Promise<T> {
return this.request<T>("post", url, params, config);
}
/** 单独抽离的get工具函数 */
/** 单独抽离的`get`工具函数 */
public get<T, P>(
url: string,
params?: AxiosRequestConfig<T>,
params?: AxiosRequestConfig<P>,
config?: PureHttpRequestConfig
): Promise<P> {
return this.request<P>("get", url, params, config);
): Promise<T> {
return this.request<T>("get", url, params, config);
}
}