From abd042afe81e2cd8d0567cd4dd4f1498825ac4e6 Mon Sep 17 00:00:00 2001 From: xiaoxian521 <1923740402@qq.com> Date: Tue, 16 Apr 2024 14:01:36 +0800 Subject: [PATCH] =?UTF-8?q?types:=20=E4=BC=98`src/utils/http`=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E4=B8=AD`post`=E5=92=8C`get`=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E5=87=BD=E6=95=B0=E7=9A=84=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/http/index.ts | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/utils/http/index.ts b/src/utils/http/index.ts index 594a8bc96..19b5be24d 100644 --- a/src/utils/http/index.ts +++ b/src/utils/http/index.ts @@ -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,7 +72,7 @@ class PureHttp { PureHttp.initConfig.beforeRequestCallback(config); return config; } - /** 请求白名单,放置一些不需要token的接口(通过设置请求白名单,防止token过期后再请求造成的死循环问题) */ + /** 请求白名单,放置一些不需要`token`的接口(通过设置请求白名单,防止`token`过期后再请求造成的死循环问题) */ const whiteList = ["/refresh-token", "/login"]; return whiteList.some(url => config.url.endsWith(url)) ? config @@ -172,22 +172,22 @@ class PureHttp { }); } - /** 单独抽离的post工具函数 */ + /** 单独抽离的`post`工具函数 */ public post( url: string, - params?: AxiosRequestConfig, + params?: AxiosRequestConfig

, config?: PureHttpRequestConfig - ): Promise

{ - return this.request

("post", url, params, config); + ): Promise { + return this.request("post", url, params, config); } - /** 单独抽离的get工具函数 */ + /** 单独抽离的`get`工具函数 */ public get( url: string, - params?: AxiosRequestConfig, + params?: AxiosRequestConfig

, config?: PureHttpRequestConfig - ): Promise

{ - return this.request

("get", url, params, config); + ): Promise { + return this.request("get", url, params, config); } }