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));
|
e.reply(segment.image(url));
|
||||||
} else {
|
} 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)));
|
e.reply(segment.image(fs.readFileSync(path)));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -185,14 +185,15 @@ export async function downloadAudio(mp3Url, path, title = "temp", redirect = "ma
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 下载一张网络图片(自动以url的最后一个为名字)
|
* 下载一张网络图片(自动以url的最后一个为名字)
|
||||||
* @param img
|
* @param {string} img
|
||||||
* @param dir
|
* @param {string} dir
|
||||||
* @param fileName
|
* @param {string} fileName
|
||||||
* @param isProxy
|
* @param {boolean} isProxy
|
||||||
* @param headersExt
|
* @param {Object} headersExt
|
||||||
|
* @param {Object} proxyInfo 参数:proxyAddr=地址,proxyPort=端口
|
||||||
* @returns {Promise<unknown>}
|
* @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 === "") {
|
if (fileName === "") {
|
||||||
fileName = img.split("/").pop();
|
fileName = img.split("/").pop();
|
||||||
}
|
}
|
||||||
@ -210,10 +211,10 @@ export async function downloadImg(img, dir, fileName = "", isProxy = false, head
|
|||||||
|
|
||||||
if (isProxy) {
|
if (isProxy) {
|
||||||
axiosConfig.httpAgent = tunnel.httpOverHttp({
|
axiosConfig.httpAgent = tunnel.httpOverHttp({
|
||||||
proxy: { host: this.proxyAddr, port: this.proxyPort },
|
proxy: { host: proxyInfo.proxyAddr, port: proxyInfo.proxyPort },
|
||||||
});
|
});
|
||||||
axiosConfig.httpsAgent = tunnel.httpOverHttp({
|
axiosConfig.httpsAgent = tunnel.httpOverHttp({
|
||||||
proxy: { host: this.proxyAddr, port: this.proxyPort },
|
proxy: { host: proxyInfo.proxyAddr, port: proxyInfo.proxyPort },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user