mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2025-08-10 11:28:59 +08:00
feat: 快捷脚本支持 await; 脚本操作支持 produceArtifact
This commit is contained in:
parent
3aacd26b79
commit
164ae9a7a8
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "sub-store",
|
||||
"version": "2.14.148",
|
||||
"version": "2.14.149",
|
||||
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
|
||||
"main": "src/main.js",
|
||||
"scripts": {
|
||||
|
@ -7,6 +7,8 @@ import lodash from 'lodash';
|
||||
import $ from '@/core/app';
|
||||
import { hex_md5 } from '@/vendor/md5';
|
||||
import { ProxyUtils } from '@/core/proxy-utils';
|
||||
import { produceArtifact } from '@/restful/sync';
|
||||
|
||||
import env from '@/utils/env';
|
||||
import { getFlowHeaders, parseFlowHeaders, flowTransfer } from '@/utils/flow';
|
||||
|
||||
@ -319,11 +321,12 @@ function ScriptOperator(script, targetPlatform, $arguments, source) {
|
||||
`async function operator(input = []) {
|
||||
let proxies
|
||||
if (Array.isArray(input)) {
|
||||
proxies = input
|
||||
return proxies.map(($server = {}) => {
|
||||
let list = []
|
||||
for await (let $server of input) {
|
||||
${script}
|
||||
return $server
|
||||
})
|
||||
list.push($server)
|
||||
}
|
||||
return list
|
||||
} else {
|
||||
let { $content, $files } = input
|
||||
${script}
|
||||
@ -783,6 +786,7 @@ function createDynamicFunction(name, script, $arguments) {
|
||||
'ProxyUtils',
|
||||
'scriptResourceCache',
|
||||
'flowUtils',
|
||||
'produceArtifact',
|
||||
`${script}\n return ${name}`,
|
||||
)(
|
||||
$arguments,
|
||||
@ -797,6 +801,7 @@ function createDynamicFunction(name, script, $arguments) {
|
||||
ProxyUtils,
|
||||
scriptResourceCache,
|
||||
flowUtils,
|
||||
produceArtifact,
|
||||
);
|
||||
} else {
|
||||
return new Function(
|
||||
@ -806,8 +811,17 @@ function createDynamicFunction(name, script, $arguments) {
|
||||
'ProxyUtils',
|
||||
'scriptResourceCache',
|
||||
'flowUtils',
|
||||
'produceArtifact',
|
||||
|
||||
`${script}\n return ${name}`,
|
||||
)($arguments, $, lodash, ProxyUtils, scriptResourceCache, flowUtils);
|
||||
)(
|
||||
$arguments,
|
||||
$,
|
||||
lodash,
|
||||
ProxyUtils,
|
||||
scriptResourceCache,
|
||||
flowUtils,
|
||||
produceArtifact,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user