feat: 忽略失败的远程选择支持开启通知(前端 >= 2.15.17)

This commit is contained in:
xream 2025-04-21 19:28:58 +08:00
parent 3b85063f73
commit 95f181351a
No known key found for this signature in database
GPG Key ID: 1D2C5225471789F9
3 changed files with 157 additions and 74 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "sub-store", "name": "sub-store",
"version": "2.19.30", "version": "2.19.31",
"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": {

View File

@ -47,15 +47,22 @@ async function previewFile(req, res) {
}), }),
); );
if ( if (Object.keys(errors).length > 0) {
!file.ignoreFailedRemoteFile && if (!file.ignoreFailedRemoteFile) {
Object.keys(errors).length > 0
) {
throw new Error( throw new Error(
`文件 ${file.name} 的远程文件 ${Object.keys( `文件 ${file.name} 的远程文件 ${Object.keys(
errors, errors,
).join(', ')} 发生错误, 请查看日志`, ).join(', ')} 发生错误, 请查看日志`,
); );
} else if (file.ignoreFailedRemoteFile === 'enabled') {
$.notify(
`🌍 Sub-Store 预览文件失败`,
`${file.name}`,
`远程文件 ${Object.keys(errors).join(
', ',
)} 发生错误, 请查看日志`,
);
}
} }
if (file.mergeSources === 'localFirst') { if (file.mergeSources === 'localFirst') {
content.unshift(file.content); content.unshift(file.content);
@ -136,12 +143,22 @@ async function compareSub(req, res) {
}), }),
); );
if (!sub.ignoreFailedRemoteSub && Object.keys(errors).length > 0) { if (Object.keys(errors).length > 0) {
if (!sub.ignoreFailedRemoteSub) {
throw new Error( throw new Error(
`订阅 ${sub.name} 的远程订阅 ${Object.keys(errors).join( `订阅 ${sub.name} 的远程订阅 ${Object.keys(errors).join(
', ', ', ',
)} 发生错误, 请查看日志`, )} 发生错误, 请查看日志`,
); );
} else if (sub.ignoreFailedRemoteSub === 'enabled') {
$.notify(
`🌍 Sub-Store 预览订阅失败`,
`${sub.name}`,
`远程订阅 ${Object.keys(errors).join(
', ',
)} 发生错误, 请查看日志`,
);
}
} }
if (sub.mergeSources === 'localFirst') { if (sub.mergeSources === 'localFirst') {
content.unshift(sub.content); content.unshift(sub.content);
@ -244,15 +261,25 @@ async function compareCollection(req, res) {
} }
}), }),
); );
if (
!sub.ignoreFailedRemoteSub && if (Object.keys(errors).length > 0) {
Object.keys(errors).length > 0 if (!sub.ignoreFailedRemoteSub) {
) {
throw new Error( throw new Error(
`订阅 ${sub.name} 的远程订阅 ${Object.keys( `订阅 ${sub.name} 的远程订阅 ${Object.keys(
errors, errors,
).join(', ')} 发生错误, 请查看日志`, ).join(', ')} 发生错误, 请查看日志`,
); );
} else if (
sub.ignoreFailedRemoteSub === 'enabled'
) {
$.notify(
`🌍 Sub-Store 预览订阅失败`,
`${sub.name}`,
`远程订阅 ${Object.keys(errors).join(
', ',
)} 发生错误, 请查看日志`,
);
}
} }
if (sub.mergeSources === 'localFirst') { if (sub.mergeSources === 'localFirst') {
raw.unshift(sub.content); raw.unshift(sub.content);
@ -289,15 +316,23 @@ async function compareCollection(req, res) {
} }
}), }),
); );
if (
!collection.ignoreFailedRemoteSub && if (Object.keys(errors).length > 0) {
Object.keys(errors).length > 0 if (!collection.ignoreFailedRemoteSub) {
) {
throw new Error( throw new Error(
`组合订阅 ${collection.name} 的子订阅 ${Object.keys( `组合订阅 ${collection.name} 的子订阅 ${Object.keys(
errors, errors,
).join(', ')} 发生错误, 请查看日志`, ).join(', ')} 发生错误, 请查看日志`,
); );
} else if (collection.ignoreFailedRemoteSub === 'enabled') {
$.notify(
`🌍 Sub-Store 预览组合订阅失败`,
`${collection.name}`,
`子订阅 ${Object.keys(errors).join(
', ',
)} 发生错误, 请查看日志`,
);
}
} }
// merge proxies with the original order // merge proxies with the original order
const original = Array.prototype.concat.apply( const original = Array.prototype.concat.apply(

View File

@ -89,12 +89,23 @@ async function produceArtifact({
if (ignoreFailedRemoteSub != null && ignoreFailedRemoteSub !== '') { if (ignoreFailedRemoteSub != null && ignoreFailedRemoteSub !== '') {
subIgnoreFailedRemoteSub = ignoreFailedRemoteSub; subIgnoreFailedRemoteSub = ignoreFailedRemoteSub;
} }
if (!subIgnoreFailedRemoteSub && Object.keys(errors).length > 0) {
if (Object.keys(errors).length > 0) {
if (!subIgnoreFailedRemoteSub) {
throw new Error( throw new Error(
`订阅 ${sub.name} 的远程订阅 ${Object.keys(errors).join( `订阅 ${sub.name} 的远程订阅 ${Object.keys(errors).join(
', ', ', ',
)} 发生错误, 请查看日志`, )} 发生错误, 请查看日志`,
); );
} else if (subIgnoreFailedRemoteSub === 'enabled') {
$.notify(
`🌍 Sub-Store 处理订阅失败`,
`${sub.name}`,
`远程订阅 ${Object.keys(errors).join(
', ',
)} 发生错误, 请查看日志`,
);
}
} }
if (mergeSources === 'localFirst') { if (mergeSources === 'localFirst') {
raw.unshift(content); raw.unshift(content);
@ -138,12 +149,23 @@ async function produceArtifact({
if (ignoreFailedRemoteSub != null && ignoreFailedRemoteSub !== '') { if (ignoreFailedRemoteSub != null && ignoreFailedRemoteSub !== '') {
subIgnoreFailedRemoteSub = ignoreFailedRemoteSub; subIgnoreFailedRemoteSub = ignoreFailedRemoteSub;
} }
if (!subIgnoreFailedRemoteSub && Object.keys(errors).length > 0) {
if (Object.keys(errors).length > 0) {
if (!subIgnoreFailedRemoteSub) {
throw new Error( throw new Error(
`订阅 ${sub.name} 的远程订阅 ${Object.keys(errors).join( `订阅 ${sub.name} 的远程订阅 ${Object.keys(errors).join(
', ', ', ',
)} 发生错误, 请查看日志`, )} 发生错误, 请查看日志`,
); );
} else if (subIgnoreFailedRemoteSub === 'enabled') {
$.notify(
`🌍 Sub-Store 处理订阅失败`,
`${sub.name}`,
`远程订阅 ${Object.keys(errors).join(
', ',
)} 发生错误, 请查看日志`,
);
}
} }
if (sub.mergeSources === 'localFirst') { if (sub.mergeSources === 'localFirst') {
raw.unshift(sub.content); raw.unshift(sub.content);
@ -264,15 +286,25 @@ async function produceArtifact({
} }
}), }),
); );
if (
!sub.ignoreFailedRemoteSub && if (Object.keys(errors).length > 0) {
Object.keys(errors).length > 0 if (!sub.ignoreFailedRemoteSub) {
) {
throw new Error( throw new Error(
`订阅 ${sub.name} 的远程订阅 ${Object.keys( `订阅 ${sub.name} 的远程订阅 ${Object.keys(
errors, errors,
).join(', ')} 发生错误, 请查看日志`, ).join(', ')} 发生错误, 请查看日志`,
); );
} else if (
sub.ignoreFailedRemoteSub === 'enabled'
) {
$.notify(
`🌍 Sub-Store 处理订阅失败`,
`${sub.name}`,
`远程订阅 ${Object.keys(errors).join(
', ',
)} 发生错误, 请查看日志`,
);
}
} }
if (sub.mergeSources === 'localFirst') { if (sub.mergeSources === 'localFirst') {
raw.unshift(sub.content); raw.unshift(sub.content);
@ -327,16 +359,24 @@ async function produceArtifact({
if (ignoreFailedRemoteSub != null && ignoreFailedRemoteSub !== '') { if (ignoreFailedRemoteSub != null && ignoreFailedRemoteSub !== '') {
collectionIgnoreFailedRemoteSub = ignoreFailedRemoteSub; collectionIgnoreFailedRemoteSub = ignoreFailedRemoteSub;
} }
if (
!collectionIgnoreFailedRemoteSub && if (Object.keys(errors).length > 0) {
Object.keys(errors).length > 0 if (!collectionIgnoreFailedRemoteSub) {
) {
throw new Error( throw new Error(
`组合订阅 ${name} 中的子订阅 ${Object.keys(errors).join( `组合订阅 ${collection.name} 的子订阅 ${Object.keys(
errors,
).join(', ')} 发生错误, 请查看日志`,
);
} else if (collectionIgnoreFailedRemoteSub === 'enabled') {
$.notify(
`🌍 Sub-Store 处理组合订阅失败`,
`${collection.name}`,
`子订阅 ${Object.keys(errors).join(
', ', ', ',
)} 发生错误, 请查看日志`, )} 发生错误, 请查看日志`,
); );
} }
}
// merge proxies with the original order // merge proxies with the original order
let proxies = Array.prototype.concat.apply( let proxies = Array.prototype.concat.apply(
@ -505,15 +545,23 @@ async function produceArtifact({
) { ) {
fileIgnoreFailedRemoteFile = ignoreFailedRemoteFile; fileIgnoreFailedRemoteFile = ignoreFailedRemoteFile;
} }
if (
!fileIgnoreFailedRemoteFile && if (Object.keys(errors).length > 0) {
Object.keys(errors).length > 0 if (!fileIgnoreFailedRemoteFile) {
) {
throw new Error( throw new Error(
`文件 ${file.name} 的远程文件 ${Object.keys( `文件 ${file.name} 的远程文件 ${Object.keys(
errors, errors,
).join(', ')} 发生错误, 请查看日志`, ).join(', ')} 发生错误, 请查看日志`,
); );
} else if (fileIgnoreFailedRemoteFile === 'enabled') {
$.notify(
`🌍 Sub-Store 处理文件失败`,
`${file.name}`,
`远程文件 ${Object.keys(errors).join(
', ',
)} 发生错误, 请查看日志`,
);
}
} }
if (file.mergeSources === 'localFirst') { if (file.mergeSources === 'localFirst') {
raw.unshift(file.content); raw.unshift(file.content);