🎈 pref: 优化X解析逻辑

This commit is contained in:
zhiyu1998 2024-07-15 15:33:22 +08:00
parent a493b98f98
commit d26fd51eee

View File

@ -7,6 +7,7 @@ import fetch from "node-fetch";
import { mkdirIfNotExists } from "./file.js"; import { mkdirIfNotExists } from "./file.js";
import { TEN_THOUSAND } from "../constants/constant.js"; import { TEN_THOUSAND } from "../constants/constant.js";
import { exec } from "child_process"; import { exec } from "child_process";
import { HttpsProxyAgent } from 'https-proxy-agent';
/** /**
* 请求模板 * 请求模板
@ -208,13 +209,11 @@ export async function downloadImg(img, dir, fileName = "", isProxy = false, head
}, },
responseType: "stream", responseType: "stream",
}; };
// 添加🪜
if (isProxy) { if (isProxy) {
axiosConfig.httpAgent = tunnel.httpOverHttp({ axiosConfig.httpsAgent = new HttpsProxyAgent({
proxy: { host: proxyInfo.proxyAddr, port: proxyInfo.proxyPort }, host: proxyInfo.proxyAddr,
}); port: proxyInfo.proxyPort
axiosConfig.httpsAgent = tunnel.httpOverHttp({
proxy: { host: proxyInfo.proxyAddr, port: proxyInfo.proxyPort },
}); });
} }
try { try {