perf: 通知选择器优化

This commit is contained in:
xiaojunnuo
2024-12-02 14:06:55 +08:00
parent 68a503796c
commit 2c0cbdd29e
11 changed files with 274 additions and 150 deletions
+16 -3
View File
@@ -98,10 +98,22 @@ export function createAxiosService({ logger }: { logger: Logger }) {
config.timeout = 15000;
}
let agents = defaultAgents;
if (config.skipSslVerify) {
logger.info('跳过SSL验证');
agents = createAgent({ rejectUnauthorized: false } as any);
if (config.skipSslVerify || config.httpProxy) {
let rejectUnauthorized = true;
if (config.skipSslVerify) {
logger.info('跳过SSL验证');
rejectUnauthorized = false;
}
const proxy: any = {};
if (config.httpProxy) {
logger.info('使用自定义http代理:', config.httpProxy);
proxy.httpProxy = config.httpProxy;
proxy.httpsProxy = config.httpProxy;
}
agents = createAgent({ rejectUnauthorized, ...proxy } as any);
}
delete config.skipSslVerify;
config.httpsAgent = agents.httpsAgent;
config.httpAgent = agents.httpAgent;
@@ -200,6 +212,7 @@ export type HttpRequestConfig<D = any> = {
skipCheckRes?: boolean;
logParams?: boolean;
logRes?: boolean;
httpProxy?: string;
} & AxiosRequestConfig<D>;
export type HttpClient = {
request<D = any, R = any>(config: HttpRequestConfig<D>): Promise<HttpClientResponse<R>>;