diff --git "a/\347\275\221\347\233\230\347\233\264\351\223\276\344\270\213\350\275\275\345\212\251\346\211\213.user.js" "b/\347\275\221\347\233\230\347\233\264\351\223\276\344\270\213\350\275\275\345\212\251\346\211\213.user.js"
index fda8920..e86a0e0 100644
--- "a/\347\275\221\347\233\230\347\233\264\351\223\276\344\270\213\350\275\275\345\212\251\346\211\213.user.js"
+++ "b/\347\275\221\347\233\230\347\233\264\351\223\276\344\270\213\350\275\275\345\212\251\346\211\213.user.js"
@@ -112,7 +112,7 @@
} catch (e) { }
}
let pageNum = '', selectedFiles = [], panInfo = {}, color = '',
- doc = $(document), downloadProgress = {}, pendingRequests = {}, intervals = {};
+ doc = $(document), downloadProgress = {}, intervals = {};
const MARK_OK = '✓';
const MARK_NO = '✗';
@@ -473,7 +473,7 @@
downloadState.downloader = d.downloader;
downloadState.protocol = pick ? pick.id : '';
},
- _rpcConfig() {
+ _rpcConfig($scope) {
const rpc = {
domain: base.getValue('setting_rpc_domain'),
port: base.getValue('setting_rpc_port'),
@@ -482,12 +482,12 @@
dir: base.getValue('setting_rpc_dir'),
};
if (!base.validRpcDomain(rpc.domain)) {
- base.panelNotice('RPC主机无效,仅允许本机或内网地址(如 http://127.0.0.1)', 'error');
+ base.panelNoticeScoped($scope, 'RPC主机无效,仅允许本机或内网地址(如 http://127.0.0.1)', 'error');
return null;
}
const partErr = base.localPartError(rpc.port, rpc.path);
if (partErr) {
- base.panelNotice('RPC ' + partErr, 'error');
+ base.panelNoticeScoped($scope, 'RPC ' + partErr, 'error');
return null;
}
const dir = base.rpcDir(rpc.dir);
@@ -551,29 +551,22 @@
},
_resetData() {
downloadProgress = {};
- $.each(pendingRequests, (key) => {
- (pendingRequests[key]).abort();
- });
$.each(intervals, (key) => {
clearInterval(intervals[key]);
});
intervals = {};
- pendingRequests = {};
},
post(url, data, headers, type) {
if (this.isType(data) === 'object') {
data = JSON.stringify(data);
}
return new Promise((resolve, reject) => {
- const key = 'post_' + Date.now() + '_' + Math.random().toString(36).slice(2, 7);
- const clear = () => { delete pendingRequests[key]; };
- pendingRequests[key] = GM_xmlhttpRequest({
+ GM_xmlhttpRequest({
method: "POST", url, headers, data,
responseType: type || 'json',
timeout: 30000,
- ontimeout: () => { clear(); reject(new Error('请求超时(30s)')); },
+ ontimeout: () => { reject(new Error('请求超时(30s)')); },
onload: (res) => {
- clear();
if (type === 'blob') { resolve(res); return; }
if (res.status >= 400) {
const body = res.response || res.responseText || '';
@@ -588,7 +581,6 @@
resolve(res.response || res.responseText);
},
onerror: (err) => {
- clear();
reject(err);
},
});
@@ -597,15 +589,12 @@
get(url, headers, type, extra) {
headers = Object.assign({ 'Referer': location.origin }, headers);
return new Promise((resolve, reject) => {
- const key = 'get_' + (extra && extra.index != null ? extra.index : Date.now());
- const clear = () => { delete pendingRequests[key]; };
- let requestObj = GM_xmlhttpRequest({
+ GM_xmlhttpRequest({
method: "GET", url, headers,
responseType: type || 'json',
timeout: type === 'blob' ? 0 : 30000,
- ontimeout: () => { clear(); reject(new Error('请求超时(30s)')); },
+ ontimeout: () => { reject(new Error('请求超时(30s)')); },
onload: (res) => {
- clear();
resolve(res.response || res.responseText);
},
onprogress: (res) => {
@@ -619,32 +608,27 @@
}
},
onerror: (err) => {
- clear();
reject(err);
},
});
- pendingRequests[key] = requestObj;
});
},
getFinalUrl(url, headers) {
headers = Object.assign({ 'Referer': location.origin }, headers);
return new Promise((resolve, reject) => {
- const key = 'finalurl_' + Date.now();
- const done = (v) => { delete pendingRequests[key]; resolve(v); };
- pendingRequests[key] = GM_xmlhttpRequest({
+ GM_xmlhttpRequest({
method: "HEAD", url, headers,
timeout: 10000,
- ontimeout: () => { delete pendingRequests[key]; reject(new Error('请求超时(10s)')); },
- onload: (res) => { done(res.finalUrl || url); },
+ ontimeout: () => { reject(new Error('请求超时(10s)')); },
+ onload: (res) => { resolve(res.finalUrl || url); },
onerror: () => {
- delete pendingRequests[key];
- pendingRequests[key] = GM_xmlhttpRequest({
+ GM_xmlhttpRequest({
method: "GET", url,
headers: Object.assign({}, headers, { 'Range': 'bytes=0-0' }),
timeout: 10000,
- ontimeout: () => { delete pendingRequests[key]; reject(new Error('请求超时(10s)')); },
- onload: (res) => { done(res.finalUrl || url); },
- onerror: () => { delete pendingRequests[key]; resolve(url); }
+ ontimeout: () => { reject(new Error('请求超时(10s)')); },
+ onload: (res) => { resolve(res.finalUrl || url); },
+ onerror: () => { resolve(url); }
});
}
});
@@ -1100,6 +1084,11 @@
clearTimeout(this._noticeTimer);
this._noticeTimer = setTimeout(() => { $t.fadeOut(200, () => $t.remove()); }, ms || 2500);
},
+ // 批次内的提示只发给发起面板:面板没了就静默,别写到新面板上
+ panelNoticeScoped($scope, text, type, ms) {
+ if ($scope && (!$scope[0] || !$scope[0].isConnected)) return;
+ base.panelNotice(text, type, ms);
+ },
createTip() {
doc.on('click', '.fl-dl-chip[data-type="downloader"]', (e) => {
const id = e.currentTarget.dataset.id;
@@ -1135,14 +1124,8 @@
doc.on('click', '.listener-dl-execute', async () => {
if (!downloadState.downloader || !downloadState.protocol) return;
if (!base.panelFiles || !base.panelFiles.length) return;
- if (base._executing) return; // 上一次还没跑完,重复点会把提示弹两遍
- base._executing = true;
- try {
- const files = base.panelFiles.map((f, i) => ({ ...f, _idx: i }));
- await base.executeAction(files, base._activeAdapter);
- } finally {
- base._executing = false;
- }
+ const files = base.panelFiles.map((f, i) => ({ ...f, _idx: i }));
+ await base.executeAction(files, base._activeAdapter);
});
doc.on('click', '.listener-dl-copy-name', (e) => {
if (!base.panelFiles || !base.panelFiles.length) return;
@@ -1214,9 +1197,9 @@
if (!name) return link;
return link + (link.indexOf('?') >= 0 ? '&' : '?') + 'filename=' + encodeURIComponent(name);
},
- async iframeDownload(link, filename) {
+ async iframeDownload(link, filename, $scope) {
if (!/^https?:\/\//i.test(link)) {
- base.panelNotice('提示:下载链接无效!', 'error');
+ base.panelNoticeScoped($scope, '提示:下载链接无效!', 'error');
return false;
}
// 城通直链带 inline,浏览器会拿去播放
@@ -1225,13 +1208,13 @@
try { name = decodeURIComponent((link.match(/[?&]fname=([^&]*)/) || [])[1] || ''); } catch (e) { }
name = base.fixFilename(name).slice(0, 120) || 'download';
let why = '';
- try { return await this._swDownload(link, name); }
+ try { return await this._swDownload(link, name, $scope); }
catch (e) { why = (e && e.message) || '中转不可用'; }
let r = await this._opfsDownload(link, name);
if (r && r.ok) return r;
// 两条路都不通就让浏览器打开
GM_openInTab(link, { active: false, insert: true, setParent: true });
- base.panelNotice('脚本取不回这条直链(' + why + '),已在新标签打开', 'info', 9000);
+ base.panelNoticeScoped($scope, '脚本取不回这条直链(' + why + '),已在新标签打开', 'info', 9000);
return { ok: true };
}
link = base._withName(link, filename);
@@ -1240,7 +1223,7 @@
return true;
},
// 借城通 SW 中转:它给响应加 attachment 头
- async _swDownload(url, filename) {
+ async _swDownload(url, filename, $scope) {
let bridge = document.createElement('iframe');
bridge.hidden = true;
bridge.src = new URL('/download/bridge.html', location.href).href;
@@ -1283,10 +1266,10 @@
sink.hidden = true; sink.src = streamUrl;
document.body.appendChild(sink);
// 通道建好就交付,喂数据在后台跑
- this._feedSw(resp, ch, bridge, sink);
+ this._feedSw(resp, ch, bridge, sink, $scope);
return { ok: true };
},
- async _feedSw(resp, ch, bridge, sink) {
+ async _feedSw(resp, ch, bridge, sink, $scope) {
try {
let reader = resp.body.getReader(), gated = true;
for (;;) {
@@ -1305,7 +1288,7 @@
ch.port1.postMessage('end');
} catch (e) {
try { ch.port1.postMessage('abort'); } catch (err) { }
- try { base.panelNotice('取回中断:' + ((e && e.message) || e), 'error', 9000); } catch (err) { }
+ try { base.panelNoticeScoped($scope, '取回中断:' + ((e && e.message) || e), 'error', 9000); } catch (err) { }
} finally {
// sink 是浏览器取数的入口,删了会掐断下载
setTimeout(() => { try { bridge.remove(); } catch (e) { } }, 60000);
@@ -1579,12 +1562,14 @@
},
async _executeNav(files, adapter, proto) {
const $btn = $('.listener-dl-execute');
+ const $scope = $btn.closest('.fl-dl-panel');
+ const uiAlive = () => $scope[0] && $scope[0].isConnected;
if (files.length > 5) base.panelNotice('共 ' + files.length + ' 个文件,逐个触发中…如遇拦截可改用推送/复制', 'info');
$btn.text('正在逐个触发 ' + files.length + ' 个下载…').prop('disabled', true);
let ok = 0, fail = 0;
for (let i = 0; i < files.length; i++) {
const f = files[i];
- const $st = $('.fl-dl-file-status[data-status-index="' + f._idx + '"]');
+ const $st = $scope.find('.fl-dl-file-status[data-status-index="' + f._idx + '"]');
if (base._isBigBaiduLink(f)) {
const bar = base._paintBar($st, '下载中');
bar.paint(0);
@@ -1593,11 +1578,11 @@
if (r.ok) {
ok++;
$st.html(MARK_OK);
- if (r.by) base.panelNotice('已成功唤起 ' + r.by + ',请查看 ' + r.by + ' 下载框!', 'success');
+ if (r.by) base.panelNoticeScoped($scope, '已成功唤起 ' + r.by + ',请查看 ' + r.by + ' 下载框!', 'success');
} else {
fail++;
$st.html(MARK_NO);
- base.panelNotice('下载失败:' + r.why + '。大文件请用 IDM/Aria2/cURL。', 'error');
+ base.panelNoticeScoped($scope, '下载失败:' + r.why + '。大文件请用 IDM/Aria2/cURL。', 'error');
}
} else if (proto && proto.id === 'seg' && base._useSegDownload(f)) {
const bar = base._paintBar($st, '多链下载');
@@ -1606,17 +1591,17 @@
bar.done();
if (r.ok) {
ok++; $st.html(MARK_OK);
- base.panelNotice('已下载 ' + f.filename + '(' + base.sizeFormat(f.rawSize || 0) + ')', 'success', 5000);
- } else { fail++; $st.html(MARK_NO); base.panelNotice('多链下载失败:' + r.why, 'error'); }
+ base.panelNoticeScoped($scope, '已下载 ' + f.filename + '(' + base.sizeFormat(f.rawSize || 0) + ')', 'success', 5000);
+ } else { fail++; $st.html(MARK_NO); base.panelNoticeScoped($scope, '多链下载失败:' + r.why, 'error'); }
} else {
- const r = await base.iframeDownload(f.dlink, f.filename);
+ const r = await base.iframeDownload(f.dlink, f.filename, $scope);
if (r === true || (r && r.ok)) { ok++; $st.html(MARK_OK); }
- else { fail++; $st.html(MARK_NO); if (r && r.why) base.panelNotice('下载失败:' + r.why, 'error', 9000); }
+ else { fail++; $st.html(MARK_NO); if (r && r.why) base.panelNoticeScoped($scope, '下载失败:' + r.why, 'error', 9000); }
}
if (i < files.length - 1) await base.sleep(800);
}
$btn.text('下载完成:成功 ' + ok + ',失败 ' + fail);
- setTimeout(() => base._updateMainButton(), 4000);
+ setTimeout(() => { if (uiAlive()) base._updateMainButton(); }, 4000);
},
// 进度画在「链接」格上:两个下载路径共用,别各写一份
_paintBar($st, label) {
@@ -1780,12 +1765,14 @@
},
async _executePush(files, adapter) {
const $btn = $('.listener-dl-execute');
+ const $scope = $btn.closest('.fl-dl-panel');
+ const alive = () => $scope[0] && $scope[0].isConnected;
const pid = downloadState.protocol;
if (pid === 'idm') {
$btn.text('正在推送 ' + files.length + ' 个任务至 IDM…').prop('disabled', true);
let ok = 0, fail = 0, rejected = '', stopped = false;
for (let f of files) {
- const $cell = $('.fl-dl-file-status[data-status-index="' + f._idx + '"]');
+ const $cell = $scope.find('.fl-dl-file-status[data-status-index="' + f._idx + '"]');
let r;
try {
r = stopped ? { ok: false, kind: 'down' } : await base.sendLinkToIDM(f.dlink, f.filename, f.rawSize || 0, base._cdnHeaders(f.dlink));
@@ -1802,9 +1789,9 @@
const why = rejected ? 'IDM 拒收任务(状态 ' + rejected + '),请反馈脚本版本'
: ok > 0 ? '已推送 ' + ok + ' 个,' + fail + ' 个未完成,可重试'
: 'IDM 未响应,请检查 IDM 浏览器插件是否启用';
- base.panelNotice(why, ok > 0 ? 'warning' : 'error');
- } else if (ok > 0) base.panelNotice('已推送至 IDM', 'success');
- setTimeout(() => base._updateMainButton(), 4000);
+ base.panelNoticeScoped($scope, why, ok > 0 ? 'warning' : 'error');
+ } else if (ok > 0) base.panelNoticeScoped($scope, '已推送至 IDM', 'success');
+ setTimeout(() => { if (alive()) base._updateMainButton(); }, 4000);
} else if (pid === 'rpc') {
const d = base.getValue('setting_rpc_domain'), p = base.getValue('setting_rpc_port'), pa = base.getValue('setting_rpc_path');
if (!d || !p || !pa) { base.showRPCSetting(false); return; }
@@ -1812,46 +1799,46 @@
const dirErr = base.rpcDir(base.getValue('setting_rpc_dir')).err;
let ok = 0, fail = 0;
for (let f of files) {
- const $cell = $('.fl-dl-file-status[data-status-index="' + f._idx + '"]');
- base._lastNotice = ''; // 清掉上一条,免得把别人的提示当成本次失败原因
- const r = await adapter.sendLinkToRPC(f.filename, f.dlink);
+ const $cell = $scope.find('.fl-dl-file-status[data-status-index="' + f._idx + '"]');
+ if (alive()) base._lastNotice = ''; // 清掉上一条,免得把别人的提示当成本次失败原因
+ const r = await adapter.sendLinkToRPC(f.filename, f.dlink, $scope);
if (r === 'success') { ok++; $cell.html(MARK_OK); }
else { fail++; $cell.html(MARK_NO); base._markFailWithReason($cell, base._lastNotice); }
}
$btn.text('推送完成:成功 ' + ok + ',失败 ' + fail);
const dirNote = dirErr ? ';' + dirErr : '';
- if (fail > 0) base.panelNotice('部分文件推送失败,原因见各行说明' + dirNote, 'error');
- else if (ok > 0) base.panelNotice('已推送 ' + ok + ' 个任务给 Aria2,进度请看下载器' + dirNote, dirErr ? undefined : 'success');
- setTimeout(() => base._updateMainButton(), 4000);
+ if (fail > 0) base.panelNoticeScoped($scope, '部分文件推送失败,原因见各行说明' + dirNote, 'error');
+ else if (ok > 0) base.panelNoticeScoped($scope, '已推送 ' + ok + ' 个任务给 Aria2,进度请看下载器' + dirNote, dirErr ? undefined : 'success');
+ setTimeout(() => { if (alive()) base._updateMainButton(); }, 4000);
} else if (pid === 'bc-rpc') {
// 先探远程,通就静默推送,不通调本地 BC
- // 探活上限 2.5s:点击的激活态只有 5s,卡住就把导航机会耗光
+ // 探活上限 1s:本机/内网 RPC 正常几十毫秒,1s 足够;卡住就直接走本地 BC
const remote = await Promise.race([
base.testBitcometConnection(true),
- base.sleep(2500).then(() => false),
+ base.sleep(1000).then(() => false),
]);
- if (!remote) { base._launchBC(files); return; }
+ if (!remote) { base._launchBC(files, adapter, $scope); return; }
$btn.text('正在推送 ' + files.length + ' 个任务至 BitComet…').prop('disabled', true);
let ok = 0, fail = 0;
for (let f of files) {
- const $cell = $('.fl-dl-file-status[data-status-index="' + f._idx + '"]');
- base._lastNotice = '';
- const r = await base.sendLinkToBitcomet(f.filename, f.dlink, base._cdnHeaders(f.dlink));
+ const $cell = $scope.find('.fl-dl-file-status[data-status-index="' + f._idx + '"]');
+ if (alive()) base._lastNotice = '';
+ const r = await base.sendLinkToBitcomet(f.filename, f.dlink, base._cdnHeaders(f.dlink), $scope);
if (r === 'success') { ok++; $cell.html(MARK_OK); }
else { fail++; $cell.html(MARK_NO); base._markFailWithReason($cell, base._lastNotice); }
}
$btn.text('推送完成:成功 ' + ok + ',失败 ' + fail);
- if (ok > 0) base.panelNotice('已推送至 BitComet', 'success');
- setTimeout(() => base._updateMainButton(), 4000);
+ if (ok > 0) base.panelNoticeScoped($scope, '已推送至 BitComet', 'success');
+ setTimeout(() => { if (alive()) base._updateMainButton(); }, 4000);
}
},
_markFailWithReason($cell, why) {
const text = why || '推送失败(未返回原因)';
$cell.siblings('.fl-dl-file-link').text(text).attr('title', text);
},
- _launchBC(files) {
- const $btn = $('.listener-dl-execute');
- const adapter = base._activeAdapter;
+ _launchBC(files, adapter, $scope) {
+ const $btn = $scope.find('.listener-dl-execute');
+ const alive = () => $scope[0] && $scope[0].isConnected;
if (!adapter) return;
let ok = 0, fail = 0, delay = 0;
files.forEach((f, i) => {
@@ -1860,7 +1847,7 @@
try { b = adapter.convertLinkToBC(f.dlink, f.filename, panInfo.ua || navigator.userAgent); } catch (e) { b = ''; }
if (typeof b === 'object') b = b.link || '';
const url = decodeURIComponent(b || '');
- const $cell = $('.fl-dl-file-status[data-status-index="' + idx + '"]');
+ const $cell = $scope.find('.fl-dl-file-status[data-status-index="' + idx + '"]');
if (!/^bc:\/\//i.test(url)) { fail++; $cell.html(MARK_NO); return; }
setTimeout(() => {
const a = document.createElement('a');
@@ -1875,8 +1862,8 @@
$cell.html(MARK_OK);
});
$btn.text('推送成功:成功 ' + ok + ',失败 ' + fail);
- if (fail > 0) base.panelNotice('调起失败 ' + fail + ' 个:bc:// 地址生成失败', 'error');
- setTimeout(() => base._updateMainButton(), 4000);
+ if (fail > 0) base.panelNoticeScoped($scope, '调起失败 ' + fail + ' 个:bc:// 地址生成失败', 'error');
+ setTimeout(() => { if (alive()) base._updateMainButton(); }, 4000);
},
async _executeCopy(files, adapter) {
const $btn = $('.listener-dl-execute');
@@ -1965,7 +1952,7 @@
if (h['Cookie']) p.push('cookie=' + encodeURIComponent(h['Cookie']));
return encodeURIComponent(`bc://http/${this.e(`AA/${encodeURIComponent(filename)}/?${p.join('&')}ZZ`)}`);
},
- async sendLinkToBitcomet(filename, link, headers) {
+ async sendLinkToBitcomet(filename, link, headers, $scope) {
const domain = base.getValue('setting_bitcomet_domain');
const port = base.getValue('setting_bitcomet_port');
const path = base.getValue('setting_bitcomet_path');
@@ -1973,11 +1960,11 @@
const pass = base.getValue('setting_bitcomet_pass');
const dir = base.getValue('setting_bitcomet_dir') || '';
if (!base.validRpcDomain(domain)) {
- base.panelNotice('BitComet 服务器地址无效,仅允许本机或内网地址', 'error');
+ base.panelNoticeScoped($scope, 'BitComet 服务器地址无效,仅允许本机或内网地址', 'error');
return 'fail';
}
const pErr = base.localPartError(port, path);
- if (pErr) { base.panelNotice('BitComet ' + pErr, 'error'); return 'fail'; }
+ if (pErr) { base.panelNoticeScoped($scope, 'BitComet ' + pErr, 'error'); return 'fail'; }
const url = domain + ':' + port + path;
const origin = domain + ':' + port; // BitComet 面板自身的 origin
headers = this.standHeaders(headers);
@@ -2002,12 +1989,12 @@
'User-Agent': navigator.userAgent,
}, 'text');
if (res && String(res).includes('Add task failed!')) {
- base.panelNotice('BitComet 添加任务失败', 'error');
+ base.panelNoticeScoped($scope, 'BitComet 添加任务失败', 'error');
return 'fail';
}
return 'success';
} catch (e) {
- base.panelNotice('无法连接 BitComet(' + domain + ':' + port + ')' + (e && e.message ? ':' + e.message : ''), 'error');
+ base.panelNoticeScoped($scope, '无法连接 BitComet(' + domain + ':' + port + ')' + (e && e.message ? ':' + e.message : ''), 'error');
return 'fail';
}
},
@@ -2948,8 +2935,8 @@
};
});
},
- async sendLinkToRPC(filename, link) {
- let rpc = base._rpcConfig();
+ async sendLinkToRPC(filename, link, $scope) {
+ let rpc = base._rpcConfig($scope);
if (!rpc) return 'fail';
let BDUSS = this.getBDUSS();
let url = rpc.url;
@@ -2966,10 +2953,10 @@
try {
let res = await base.post(url, rpcData, {"User-Agent": panInfo.ua}, '');
if (res.result) return 'success';
- base.panelNotice('Aria2 拒绝请求:' + ((res.error && res.error.message) || '未知错误(请检查 RPC 密钥与保存路径)'));
+ base.panelNoticeScoped($scope, 'Aria2 拒绝请求:' + ((res.error && res.error.message) || '未知错误(请检查 RPC 密钥与保存路径)'));
return 'fail';
} catch (e) {
- base.panelNotice('无法连接 RPC(' + rpc.domain + ':' + rpc.port + ')' + (e && e.message ? ':' + e.message : '') + ',请确认下载器已启动且 RPC 服务已开启');
+ base.panelNoticeScoped($scope, '无法连接 RPC(' + rpc.domain + ':' + rpc.port + ')' + (e && e.message ? ':' + e.message : '') + ',请确认下载器已启动且 RPC 服务已开启');
return 'fail';
}
},
@@ -3168,8 +3155,8 @@
raw: v,
}));
},
- async sendLinkToRPC(filename, link) {
- let rpc = base._rpcConfig();
+ async sendLinkToRPC(filename, link, $scope) {
+ let rpc = base._rpcConfig($scope);
if (!rpc) return 'fail';
let url = rpc.url;
const UA = navigator.userAgent;
@@ -3186,10 +3173,10 @@
try {
let res = await base.post(url, rpcData, {}, '');
if (res.result) return 'success';
- base.panelNotice('Aria2 拒绝请求:' + ((res.error && res.error.message) || '未知错误(请检查 RPC 密钥与保存路径)'));
+ base.panelNoticeScoped($scope, 'Aria2 拒绝请求:' + ((res.error && res.error.message) || '未知错误(请检查 RPC 密钥与保存路径)'));
return 'fail';
} catch (e) {
- base.panelNotice('无法连接 RPC(' + rpc.domain + ':' + rpc.port + ')' + (e && e.message ? ':' + e.message : '') + ',请确认下载器已启动且 RPC 服务已开启');
+ base.panelNoticeScoped($scope, '无法连接 RPC(' + rpc.domain + ':' + rpc.port + ')' + (e && e.message ? ':' + e.message : '') + ',请确认下载器已启动且 RPC 服务已开启');
return 'fail';
}
},
@@ -3379,8 +3366,8 @@
raw: v,
}));
},
- async sendLinkToRPC(filename, link) {
- let rpc = base._rpcConfig();
+ async sendLinkToRPC(filename, link, $scope) {
+ let rpc = base._rpcConfig($scope);
if (!rpc) return 'fail';
let url = rpc.url;
let rpcData = {
@@ -3396,10 +3383,10 @@
try {
let res = await base.post(url, rpcData, {}, '');
if (res.result) return 'success';
- base.panelNotice('Aria2 拒绝请求:' + ((res.error && res.error.message) || '未知错误(请检查 RPC 密钥与保存路径)'));
+ base.panelNoticeScoped($scope, 'Aria2 拒绝请求:' + ((res.error && res.error.message) || '未知错误(请检查 RPC 密钥与保存路径)'));
return 'fail';
} catch (e) {
- base.panelNotice('无法连接 RPC(' + rpc.domain + ':' + rpc.port + ')' + (e && e.message ? ':' + e.message : '') + ',请确认下载器已启动且 RPC 服务已开启');
+ base.panelNoticeScoped($scope, '无法连接 RPC(' + rpc.domain + ':' + rpc.port + ')' + (e && e.message ? ':' + e.message : '') + ',请确认下载器已启动且 RPC 服务已开启');
return 'fail';
}
},
@@ -3665,8 +3652,8 @@
raw: v,
}));
},
- async sendLinkToRPC(filename, link) {
- let rpc = base._rpcConfig();
+ async sendLinkToRPC(filename, link, $scope) {
+ let rpc = base._rpcConfig($scope);
if (!rpc) return 'fail';
let url = rpc.url;
let authCookie = this._getAuthCookie ? this._getAuthCookie() : '';
@@ -3686,10 +3673,10 @@
try {
let res = await base.post(url, rpcData, {}, '');
if (res.result) return 'success';
- base.panelNotice('Aria2 拒绝请求:' + ((res.error && res.error.message) || '未知错误(请检查 RPC 密钥与保存路径)'));
+ base.panelNoticeScoped($scope, 'Aria2 拒绝请求:' + ((res.error && res.error.message) || '未知错误(请检查 RPC 密钥与保存路径)'));
return 'fail';
} catch (e) {
- base.panelNotice('无法连接 RPC(' + rpc.domain + ':' + rpc.port + ')' + (e && e.message ? ':' + e.message : '') + ',请确认下载器已启动且 RPC 服务已开启');
+ base.panelNoticeScoped($scope, '无法连接 RPC(' + rpc.domain + ':' + rpc.port + ')' + (e && e.message ? ':' + e.message : '') + ',请确认下载器已启动且 RPC 服务已开启');
return 'fail';
}
},
@@ -3885,8 +3872,8 @@
raw: v,
}));
},
- async sendLinkToRPC(filename, link) {
- let rpc = base._rpcConfig();
+ async sendLinkToRPC(filename, link, $scope) {
+ let rpc = base._rpcConfig($scope);
if (!rpc) return 'fail';
let url = rpc.url;
let rpcData = {
@@ -3904,10 +3891,10 @@
try {
let res = await base.post(url, rpcData, {}, '');
if (res.result) return 'success';
- base.panelNotice('Aria2 拒绝请求:' + ((res.error && res.error.message) || '未知错误(请检查 RPC 密钥与保存路径)'));
+ base.panelNoticeScoped($scope, 'Aria2 拒绝请求:' + ((res.error && res.error.message) || '未知错误(请检查 RPC 密钥与保存路径)'));
return 'fail';
} catch (e) {
- base.panelNotice('无法连接 RPC(' + rpc.domain + ':' + rpc.port + ')' + (e && e.message ? ':' + e.message : '') + ',请确认下载器已启动且 RPC 服务已开启');
+ base.panelNoticeScoped($scope, '无法连接 RPC(' + rpc.domain + ':' + rpc.port + ')' + (e && e.message ? ':' + e.message : '') + ',请确认下载器已启动且 RPC 服务已开启');
return 'fail';
}
},
@@ -4096,8 +4083,8 @@
raw: v,
}));
},
- async sendLinkToRPC(filename, link) {
- let rpc = base._rpcConfig();
+ async sendLinkToRPC(filename, link, $scope) {
+ let rpc = base._rpcConfig($scope);
if (!rpc) return 'fail';
let url = rpc.url;
let rpcData = {
@@ -4113,10 +4100,10 @@
try {
let res = await base.post(url, rpcData, {}, '');
if (res.result) return 'success';
- base.panelNotice('Aria2 拒绝请求:' + ((res.error && res.error.message) || '未知错误(请检查 RPC 密钥与保存路径)'));
+ base.panelNoticeScoped($scope, 'Aria2 拒绝请求:' + ((res.error && res.error.message) || '未知错误(请检查 RPC 密钥与保存路径)'));
return 'fail';
} catch (e) {
- base.panelNotice('无法连接 RPC(' + rpc.domain + ':' + rpc.port + ')' + (e && e.message ? ':' + e.message : '') + ',请确认下载器已启动且 RPC 服务已开启');
+ base.panelNoticeScoped($scope, '无法连接 RPC(' + rpc.domain + ':' + rpc.port + ')' + (e && e.message ? ':' + e.message : '') + ',请确认下载器已启动且 RPC 服务已开启');
return 'fail';
}
},
@@ -4713,8 +4700,8 @@
});
return ids.filter(Boolean);
},
- async sendLinkToRPC(filename, link) {
- let rpc = base._rpcConfig();
+ async sendLinkToRPC(filename, link, $scope) {
+ let rpc = base._rpcConfig($scope);
if (!rpc) return 'fail';
let url = rpc.url;
let rpcData = {
@@ -4730,10 +4717,10 @@
try {
let res = await base.post(url, rpcData, {}, '');
if (res.result) return 'success';
- base.panelNotice('Aria2 拒绝请求:' + ((res.error && res.error.message) || '未知错误(请检查 RPC 密钥与保存路径)'));
+ base.panelNoticeScoped($scope, 'Aria2 拒绝请求:' + ((res.error && res.error.message) || '未知错误(请检查 RPC 密钥与保存路径)'));
return 'fail';
} catch (e) {
- base.panelNotice('无法连接 RPC(' + rpc.domain + ':' + rpc.port + ')' + (e && e.message ? ':' + e.message : '') + ',请确认下载器已启动且 RPC 服务已开启');
+ base.panelNoticeScoped($scope, '无法连接 RPC(' + rpc.domain + ':' + rpc.port + ')' + (e && e.message ? ':' + e.message : '') + ',请确认下载器已启动且 RPC 服务已开启');
return 'fail';
}
},