From 2cd30dfe6812802682b1b1351f142ae8deef3d5b Mon Sep 17 00:00:00 2001 From: xream Date: Wed, 26 Feb 2025 18:50:11 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=86=85=E5=AE=B9=E6=97=A0=E5=8F=98?= =?UTF-8?q?=E5=8C=96=E6=97=B6=20=E4=B8=8D=E8=BF=9B=E8=A1=8C=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0;=20=E5=A2=9E=E5=8A=A0=20gist=20=E6=95=B0=E9=87=8F?= =?UTF-8?q?=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/restful/miscs.js | 15 +++++++++++++++ backend/src/utils/gist.js | 1 + 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/backend/package.json b/backend/package.json index 109a6dd..c82e184 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "sub-store", - "version": "2.16.55", + "version": "2.16.56", "description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.", "main": "src/main.js", "scripts": { diff --git a/backend/src/restful/miscs.js b/backend/src/restful/miscs.js index ea650a5..7d521d9 100644 --- a/backend/src/restful/miscs.js +++ b/backend/src/restful/miscs.js @@ -109,6 +109,21 @@ async function gistBackupAction(action) { const updated = settings.syncTime; switch (action) { case 'upload': + try { + content = $.read('#sub-store'); + if ($.env.isNode) content = JSON.stringify($.cache, null, ` `); + $.info(`下载备份, 与本地内容对比...`); + const onlineContent = await gist.download( + GIST_BACKUP_FILE_NAME, + ); + if (onlineContent === content) { + $.info(`内容一致, 无需上传备份`); + return; + } + } catch (error) { + $.error(`${error.message ?? error}`); + } + // update syncTime settings.syncTime = new Date().getTime(); $.write(settings, SETTINGS_KEY); diff --git a/backend/src/utils/gist.js b/backend/src/utils/gist.js index a6736d7..6949628 100644 --- a/backend/src/utils/gist.js +++ b/backend/src/utils/gist.js @@ -118,6 +118,7 @@ export default class Gist { .get('/gists?per_page=100&page=1') .then((response) => { const gists = JSON.parse(response.body); + $.info(`获取到当前 GitHub 用户的 gist: ${gists.length} 个`); for (let g of gists) { if (g.description === this.key) { return g;