mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2025-08-14 12:15:56 +08:00
fix: 文件类型为 mihomo 配置时, 不应处理本地或远程内容字段
This commit is contained in:
parent
6d3d6fa1b3
commit
8fc755ff02
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "sub-store",
|
"name": "sub-store",
|
||||||
"version": "2.16.43",
|
"version": "2.16.44",
|
||||||
"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": {
|
||||||
|
@ -15,7 +15,8 @@ export default function register($app) {
|
|||||||
async function previewFile(req, res) {
|
async function previewFile(req, res) {
|
||||||
try {
|
try {
|
||||||
const file = req.body;
|
const file = req.body;
|
||||||
let content;
|
let content = '';
|
||||||
|
if (file.type !== 'mihomoProfile') {
|
||||||
if (
|
if (
|
||||||
file.source === 'local' &&
|
file.source === 'local' &&
|
||||||
!['localFirst', 'remoteFirst'].includes(file.mergeSources)
|
!['localFirst', 'remoteFirst'].includes(file.mergeSources)
|
||||||
@ -46,9 +47,9 @@ async function previewFile(req, res) {
|
|||||||
Object.keys(errors).length > 0
|
Object.keys(errors).length > 0
|
||||||
) {
|
) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`文件 ${file.name} 的远程文件 ${Object.keys(errors).join(
|
`文件 ${file.name} 的远程文件 ${Object.keys(
|
||||||
', ',
|
errors,
|
||||||
)} 发生错误, 请查看日志`,
|
).join(', ')} 发生错误, 请查看日志`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (file.mergeSources === 'localFirst') {
|
if (file.mergeSources === 'localFirst') {
|
||||||
@ -57,6 +58,7 @@ async function previewFile(req, res) {
|
|||||||
content.push(file.content);
|
content.push(file.content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// parse proxies
|
// parse proxies
|
||||||
const files = (Array.isArray(content) ? content : [content]).flat();
|
const files = (Array.isArray(content) ? content : [content]).flat();
|
||||||
let filesContent = files
|
let filesContent = files
|
||||||
|
@ -410,8 +410,13 @@ async function produceArtifact({
|
|||||||
const allFiles = $.read(FILES_KEY);
|
const allFiles = $.read(FILES_KEY);
|
||||||
const file = findByName(allFiles, name);
|
const file = findByName(allFiles, name);
|
||||||
if (!file) throw new Error(`找不到文件 ${name}`);
|
if (!file) throw new Error(`找不到文件 ${name}`);
|
||||||
let raw;
|
let raw = '';
|
||||||
if (content && !['localFirst', 'remoteFirst'].includes(mergeSources)) {
|
console.log(file);
|
||||||
|
if (file.type !== 'mihomoProfile') {
|
||||||
|
if (
|
||||||
|
content &&
|
||||||
|
!['localFirst', 'remoteFirst'].includes(mergeSources)
|
||||||
|
) {
|
||||||
raw = content;
|
raw = content;
|
||||||
} else if (url) {
|
} else if (url) {
|
||||||
const errors = {};
|
const errors = {};
|
||||||
@ -447,11 +452,14 @@ async function produceArtifact({
|
|||||||
) {
|
) {
|
||||||
fileIgnoreFailedRemoteFile = ignoreFailedRemoteFile;
|
fileIgnoreFailedRemoteFile = ignoreFailedRemoteFile;
|
||||||
}
|
}
|
||||||
if (!fileIgnoreFailedRemoteFile && Object.keys(errors).length > 0) {
|
if (
|
||||||
|
!fileIgnoreFailedRemoteFile &&
|
||||||
|
Object.keys(errors).length > 0
|
||||||
|
) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`文件 ${file.name} 的远程文件 ${Object.keys(errors).join(
|
`文件 ${file.name} 的远程文件 ${Object.keys(
|
||||||
', ',
|
errors,
|
||||||
)} 发生错误, 请查看日志`,
|
).join(', ')} 发生错误, 请查看日志`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (mergeSources === 'localFirst') {
|
if (mergeSources === 'localFirst') {
|
||||||
@ -498,11 +506,14 @@ async function produceArtifact({
|
|||||||
) {
|
) {
|
||||||
fileIgnoreFailedRemoteFile = ignoreFailedRemoteFile;
|
fileIgnoreFailedRemoteFile = ignoreFailedRemoteFile;
|
||||||
}
|
}
|
||||||
if (!fileIgnoreFailedRemoteFile && Object.keys(errors).length > 0) {
|
if (
|
||||||
|
!fileIgnoreFailedRemoteFile &&
|
||||||
|
Object.keys(errors).length > 0
|
||||||
|
) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`文件 ${file.name} 的远程文件 ${Object.keys(errors).join(
|
`文件 ${file.name} 的远程文件 ${Object.keys(
|
||||||
', ',
|
errors,
|
||||||
)} 发生错误, 请查看日志`,
|
).join(', ')} 发生错误, 请查看日志`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (file.mergeSources === 'localFirst') {
|
if (file.mergeSources === 'localFirst') {
|
||||||
@ -511,6 +522,7 @@ async function produceArtifact({
|
|||||||
raw.push(file.content);
|
raw.push(file.content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
const files = (Array.isArray(raw) ? raw : [raw]).flat();
|
const files = (Array.isArray(raw) ? raw : [raw]).flat();
|
||||||
let filesContent = files
|
let filesContent = files
|
||||||
.filter((i) => i != null && i !== '')
|
.filter((i) => i != null && i !== '')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user