Skip to content

Commit 1b4c046

Browse files
committed
fix: mihomo 覆写可以多次使用
1 parent 41034ce commit 1b4c046

2 files changed

Lines changed: 20 additions & 5 deletions

File tree

backend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sub-store",
3-
"version": "2.16.58",
3+
"version": "2.16.59",
44
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.",
55
"main": "src/main.js",
66
"scripts": {

backend/src/core/proxy-utils/processors/index.js

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -366,12 +366,20 @@ function ScriptOperator(script, targetPlatform, $arguments, source, $options) {
366366
if (output?.$file?.type === 'mihomoProfile') {
367367
try {
368368
let patch = YAML.safeLoad(script);
369+
let config;
370+
if (output?.$content) {
371+
try {
372+
config = YAML.safeLoad(output?.$content);
373+
} catch (e) {
374+
$.error(e.message ?? e);
375+
}
376+
}
369377
// if (typeof patch !== 'object') patch = {};
370378
if (typeof patch !== 'object')
371379
throw new Error('patch is not an object');
372380
output.$content = ProxyUtils.yaml.safeDump(
373381
deepMerge(
374-
{
382+
config || {
375383
proxies: await produceArtifact({
376384
type:
377385
output?.$file?.sourceType ||
@@ -414,7 +422,15 @@ function ScriptOperator(script, targetPlatform, $arguments, source, $options) {
414422
if($file.type === 'mihomoProfile') {
415423
${script}
416424
if(typeof main === 'function') {
417-
const config = {
425+
let config;
426+
if ($content) {
427+
try {
428+
config = ProxyUtils.yaml.safeLoad($content);
429+
} catch (e) {
430+
console.log(e.message ?? e);
431+
}
432+
}
433+
$content = ProxyUtils.yaml.safeDump(await main(config || {
418434
proxies: await produceArtifact({
419435
type: $file.sourceType || 'collection',
420436
name: $file.sourceName,
@@ -424,8 +440,7 @@ function ScriptOperator(script, targetPlatform, $arguments, source, $options) {
424440
'delete-underscore-fields': true
425441
}
426442
}),
427-
}
428-
$content = ProxyUtils.yaml.safeDump(await main(config))
443+
}))
429444
}
430445
} else {
431446
${script}

0 commit comments

Comments
 (0)