diff --git a/backend/package.json b/backend/package.json index 4d7ef3e79..d712e89c5 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "sub-store", - "version": "2.14.157", + "version": "2.14.158", "description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.", "main": "src/main.js", "scripts": { diff --git a/backend/src/core/proxy-utils/processors/index.js b/backend/src/core/proxy-utils/processors/index.js index edbc0b80e..f0d31984e 100644 --- a/backend/src/core/proxy-utils/processors/index.js +++ b/backend/src/core/proxy-utils/processors/index.js @@ -319,7 +319,11 @@ function ScriptOperator(script, targetPlatform, $arguments, source) { const operator = createDynamicFunction( 'operator', `async function operator(input = []) { - if (Array.isArray(input)) { + if (input?.$files || input?.$content) { + let { $content, $files } = input + ${script} + return { $content, $files } + } else { let proxies = input let list = [] for await (let $server of proxies) { @@ -327,12 +331,7 @@ function ScriptOperator(script, targetPlatform, $arguments, source) { list.push($server) } return list - } else { - let { $content, $files } = input - ${script} - return { $content, $files } } - }`, $arguments, ); @@ -689,7 +688,7 @@ async function ApplyFilter(filter, objs) { nodeErr = ''; funcErr = `执行失败 ${funcErrMsg}`; } else { - nodeErr = `执行节点快捷过滤脚本 失败 ${nodeErr}`; + nodeErr = `执行节点快捷过滤脚本 失败 ${nodeErrMsg}`; } throw new Error(`脚本过滤 ${funcErr}${nodeErr}`); } @@ -708,7 +707,9 @@ async function ApplyOperator(operator, objs) { if ( funcErrMsg.includes('$server is not defined') || funcErrMsg.includes('$content is not defined') || - funcErrMsg.includes('$files is not defined') + funcErrMsg.includes('$files is not defined') || + output?.$files || + output?.$content ) { funcErr = ''; } else { @@ -730,7 +731,7 @@ async function ApplyOperator(operator, objs) { nodeErr = ''; funcErr = `执行失败 ${funcErrMsg}`; } else { - nodeErr = `执行节点快捷脚本 失败 ${nodeErr}`; + nodeErr = `执行节点快捷脚本 失败 ${nodeErrMsg}`; } throw new Error(`脚本操作 ${funcErr}${nodeErr}`); } diff --git a/backend/src/restful/sync.js b/backend/src/restful/sync.js index b7caedca2..9fb4ef796 100644 --- a/backend/src/restful/sync.js +++ b/backend/src/restful/sync.js @@ -41,6 +41,7 @@ async function produceArtifact({ if (type === 'subscription') { const allSubs = $.read(SUBS_KEY); const sub = findByName(allSubs, name); + if (!sub) throw new Error(`找不到订阅 ${name}`); let raw; if (content && !['localFirst', 'remoteFirst'].includes(mergeSources)) { raw = content; @@ -161,6 +162,7 @@ async function produceArtifact({ const allSubs = $.read(SUBS_KEY); const allCols = $.read(COLLECTIONS_KEY); const collection = findByName(allCols, name); + if (!collection) throw new Error(`找不到组合订阅 ${name}`); const subnames = collection.subscriptions; const results = {}; const errors = {}; @@ -307,6 +309,7 @@ async function produceArtifact({ } else if (type === 'rule') { const allRules = $.read(RULES_KEY); const rule = findByName(allRules, name); + if (!rule) throw new Error(`找不到规则 ${name}`); let rules = []; for (let i = 0; i < rule.urls.length; i++) { const url = rule.urls[i];