mirror of
https://github.com/Jerryplusy/rc-plugin.git
synced 2025-10-14 16:19:18 +00:00
🎈 pref: 优化X解析逻辑
This commit is contained in:
parent
f6541d512b
commit
a1d6e612a5
@ -770,7 +770,12 @@ export class tools extends plugin {
|
||||
e.reply(segment.image(url));
|
||||
} else {
|
||||
// 非海外使用🪜下载
|
||||
downloadImg(url, this.getCurDownloadPath(e), "", !isOversea).then(path => {
|
||||
const proxy = this.myProxy;
|
||||
const port = this.proxyPort;
|
||||
downloadImg(url, this.getCurDownloadPath(e), "", !isOversea, {}, {
|
||||
proxyAddr: proxy,
|
||||
proxyPort: port
|
||||
}).then(path => {
|
||||
e.reply(segment.image(fs.readFileSync(path)));
|
||||
});
|
||||
}
|
||||
|
@ -185,14 +185,15 @@ export async function downloadAudio(mp3Url, path, title = "temp", redirect = "ma
|
||||
|
||||
/**
|
||||
* 下载一张网络图片(自动以url的最后一个为名字)
|
||||
* @param img
|
||||
* @param dir
|
||||
* @param fileName
|
||||
* @param isProxy
|
||||
* @param headersExt
|
||||
* @param {string} img
|
||||
* @param {string} dir
|
||||
* @param {string} fileName
|
||||
* @param {boolean} isProxy
|
||||
* @param {Object} headersExt
|
||||
* @param {Object} proxyInfo 参数:proxyAddr=地址,proxyPort=端口
|
||||
* @returns {Promise<unknown>}
|
||||
*/
|
||||
export async function downloadImg(img, dir, fileName = "", isProxy = false, headersExt = {}) {
|
||||
export async function downloadImg(img, dir, fileName = "", isProxy = false, headersExt = {}, proxyInfo = {}) {
|
||||
if (fileName === "") {
|
||||
fileName = img.split("/").pop();
|
||||
}
|
||||
@ -210,10 +211,10 @@ export async function downloadImg(img, dir, fileName = "", isProxy = false, head
|
||||
|
||||
if (isProxy) {
|
||||
axiosConfig.httpAgent = tunnel.httpOverHttp({
|
||||
proxy: { host: this.proxyAddr, port: this.proxyPort },
|
||||
proxy: { host: proxyInfo.proxyAddr, port: proxyInfo.proxyPort },
|
||||
});
|
||||
axiosConfig.httpsAgent = tunnel.httpOverHttp({
|
||||
proxy: { host: this.proxyAddr, port: this.proxyPort },
|
||||
proxy: { host: proxyInfo.proxyAddr, port: proxyInfo.proxyPort },
|
||||
});
|
||||
}
|
||||
try {
|
||||
|
Loading…
x
Reference in New Issue
Block a user