From 507e37021c7501ae3fa2483ae25f13ba01c697ef Mon Sep 17 00:00:00 2001 From: xream Date: Sun, 16 Mar 2025 15:48:47 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E6=9B=B4=E5=A4=9A?= =?UTF-8?q?=E7=9A=84=E5=90=8C=E6=AD=A5=E9=85=8D=E7=BD=AE=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/package.json | 2 +- backend/src/products/cron-sync-artifacts.js | 9 +++++++++ backend/src/restful/settings.js | 8 ++++++-- backend/src/restful/sync.js | 9 +++++++++ backend/src/utils/gist.js | 2 +- 5 files changed, 26 insertions(+), 4 deletions(-) diff --git a/backend/package.json b/backend/package.json index 8487beb..a53b5e9 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "sub-store", - "version": "2.18.5", + "version": "2.18.6", "description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.", "main": "src/main.js", "scripts": { diff --git a/backend/src/products/cron-sync-artifacts.js b/backend/src/products/cron-sync-artifacts.js index 004440e..e1eac64 100644 --- a/backend/src/products/cron-sync-artifacts.js +++ b/backend/src/products/cron-sync-artifacts.js @@ -89,8 +89,10 @@ async function doSync() { const allSubs = $.read(SUBS_KEY); const allCols = $.read(COLLECTIONS_KEY); const subNames = []; + let enabledCount = 0; allArtifacts.map((artifact) => { if (artifact.sync && artifact.source) { + enabledCount++; if (artifact.type === 'subscription') { const subName = artifact.source; const sub = findByName(allSubs, subName); @@ -111,6 +113,13 @@ async function doSync() { } }); + if (enabledCount === 0) { + $.info( + `需同步的配置: ${enabledCount}, 总数: ${allArtifacts.length}`, + ); + return; + } + if (subNames.length > 0) { await Promise.all( subNames.map(async (subName) => { diff --git a/backend/src/restful/settings.js b/backend/src/restful/settings.js index c880e43..fa623da 100644 --- a/backend/src/restful/settings.js +++ b/backend/src/restful/settings.js @@ -134,11 +134,15 @@ export async function updateArtifactStore() { settings.artifactStore = url; settings.artifactStoreStatus = 'VALID'; } else { - $.error(`找不到 Sub-Store Gist`); + $.error(`找不到 Sub-Store Gist (${ARTIFACT_REPOSITORY_KEY})`); settings.artifactStoreStatus = 'NOT FOUND'; } } catch (err) { - $.error(`查找 Sub-Store Gist 时发生错误: ${err.message ?? err}`); + $.error( + `查找 Sub-Store Gist (${ARTIFACT_REPOSITORY_KEY}) 时发生错误: ${ + err.message ?? err + }`, + ); settings.artifactStoreStatus = 'ERROR'; } $.write(settings, SETTINGS_KEY); diff --git a/backend/src/restful/sync.js b/backend/src/restful/sync.js index 90ff712..c82d7bf 100644 --- a/backend/src/restful/sync.js +++ b/backend/src/restful/sync.js @@ -556,8 +556,10 @@ async function syncArtifacts() { const allSubs = $.read(SUBS_KEY); const allCols = $.read(COLLECTIONS_KEY); const subNames = []; + let enabledCount = 0; allArtifacts.map((artifact) => { if (artifact.sync && artifact.source) { + enabledCount++; if (artifact.type === 'subscription') { const subName = artifact.source; const sub = findByName(allSubs, subName); @@ -578,6 +580,13 @@ async function syncArtifacts() { } }); + if (enabledCount === 0) { + $.info( + `需同步的配置: ${enabledCount}, 总数: ${allArtifacts.length}`, + ); + return; + } + if (subNames.length > 0) { await Promise.all( subNames.map(async (subName) => { diff --git a/backend/src/utils/gist.js b/backend/src/utils/gist.js index 6949628..0aeba25 100644 --- a/backend/src/utils/gist.js +++ b/backend/src/utils/gist.js @@ -280,7 +280,7 @@ export default class Gist { return Promise.reject(err); } } else { - return Promise.reject('找不到 Sub-Store Gist'); + return Promise.reject(`找不到 Sub-Store Gist (${this.key})`); } } }