From 2586c29746a5b9a105072986b9c88bd60ceec96c Mon Sep 17 00:00:00 2001 From: xream Date: Tue, 23 Apr 2024 09:28:39 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=A4=84=E7=90=86=E6=89=8B=E5=8A=A8?= =?UTF-8?q?=E5=88=A0=E9=99=A4=20Gist=20=E4=B9=8B=E5=90=8E,=20Sub-Store=20?= =?UTF-8?q?=E4=BE=A7=E9=87=8D=E6=96=B0=E5=90=8C=E6=AD=A5=E7=9A=84=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/package.json | 2 +- backend/src/restful/artifacts.js | 20 +++++++++++++++++++- backend/src/utils/gist.js | 6 +++--- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/backend/package.json b/backend/package.json index 63b779105..0b1b6c855 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "sub-store", - "version": "2.14.298", + "version": "2.14.299", "description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.", "main": "src/main.js", "scripts": { diff --git a/backend/src/restful/artifacts.js b/backend/src/restful/artifacts.js index ef6a74067..e4626a382 100644 --- a/backend/src/restful/artifacts.js +++ b/backend/src/restful/artifacts.js @@ -253,7 +253,25 @@ async function syncToGist(files) { key: ARTIFACT_REPOSITORY_KEY, syncPlatform, }); - return manager.upload(files); + const res = await manager.upload(files); + let body = {}; + try { + body = JSON.parse(res.body); + // eslint-disable-next-line no-empty + } catch (e) {} + + const url = body?.html_url ?? body?.web_url; + const settings = $.read(SETTINGS_KEY); + if (url) { + $.log(`同步 Gist 后, 找到 Sub-Store Gist: ${url}`); + settings.artifactStore = url; + settings.artifactStoreStatus = 'VALID'; + } else { + $.error(`同步 Gist 后, 找不到 Sub-Store Gist`); + settings.artifactStoreStatus = 'NOT FOUND'; + } + $.write(settings, SETTINGS_KEY); + return res; } export { syncToGist }; diff --git a/backend/src/utils/gist.js b/backend/src/utils/gist.js index 20e4cd10a..78b107508 100644 --- a/backend/src/utils/gist.js +++ b/backend/src/utils/gist.js @@ -135,9 +135,9 @@ export default class Gist { } } }); - console.log(`result`, result); - console.log(`files`, files); - console.log(`actions`, actions); + // console.log(`result`, result); + // console.log(`files`, files); + // console.log(`actions`, actions); if (this.syncPlatform === 'gitlab') { if (Object.keys(result).length === 0) {