mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2025-08-15 21:55:55 +08:00
fix: mihomo 覆写可以多次使用
This commit is contained in:
parent
41034ceb46
commit
1b4c046b75
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "sub-store",
|
"name": "sub-store",
|
||||||
"version": "2.16.58",
|
"version": "2.16.59",
|
||||||
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.",
|
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.",
|
||||||
"main": "src/main.js",
|
"main": "src/main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -366,12 +366,20 @@ function ScriptOperator(script, targetPlatform, $arguments, source, $options) {
|
|||||||
if (output?.$file?.type === 'mihomoProfile') {
|
if (output?.$file?.type === 'mihomoProfile') {
|
||||||
try {
|
try {
|
||||||
let patch = YAML.safeLoad(script);
|
let patch = YAML.safeLoad(script);
|
||||||
|
let config;
|
||||||
|
if (output?.$content) {
|
||||||
|
try {
|
||||||
|
config = YAML.safeLoad(output?.$content);
|
||||||
|
} catch (e) {
|
||||||
|
$.error(e.message ?? e);
|
||||||
|
}
|
||||||
|
}
|
||||||
// if (typeof patch !== 'object') patch = {};
|
// if (typeof patch !== 'object') patch = {};
|
||||||
if (typeof patch !== 'object')
|
if (typeof patch !== 'object')
|
||||||
throw new Error('patch is not an object');
|
throw new Error('patch is not an object');
|
||||||
output.$content = ProxyUtils.yaml.safeDump(
|
output.$content = ProxyUtils.yaml.safeDump(
|
||||||
deepMerge(
|
deepMerge(
|
||||||
{
|
config || {
|
||||||
proxies: await produceArtifact({
|
proxies: await produceArtifact({
|
||||||
type:
|
type:
|
||||||
output?.$file?.sourceType ||
|
output?.$file?.sourceType ||
|
||||||
@ -414,7 +422,15 @@ function ScriptOperator(script, targetPlatform, $arguments, source, $options) {
|
|||||||
if($file.type === 'mihomoProfile') {
|
if($file.type === 'mihomoProfile') {
|
||||||
${script}
|
${script}
|
||||||
if(typeof main === 'function') {
|
if(typeof main === 'function') {
|
||||||
const config = {
|
let config;
|
||||||
|
if ($content) {
|
||||||
|
try {
|
||||||
|
config = ProxyUtils.yaml.safeLoad($content);
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e.message ?? e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$content = ProxyUtils.yaml.safeDump(await main(config || {
|
||||||
proxies: await produceArtifact({
|
proxies: await produceArtifact({
|
||||||
type: $file.sourceType || 'collection',
|
type: $file.sourceType || 'collection',
|
||||||
name: $file.sourceName,
|
name: $file.sourceName,
|
||||||
@ -424,8 +440,7 @@ function ScriptOperator(script, targetPlatform, $arguments, source, $options) {
|
|||||||
'delete-underscore-fields': true
|
'delete-underscore-fields': true
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
}
|
}))
|
||||||
$content = ProxyUtils.yaml.safeDump(await main(config))
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
${script}
|
${script}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user