Skip to content

Commit 9569068

Browse files
committed
feat: Gist 备份选项
1 parent 94c820e commit 9569068

3 files changed

Lines changed: 17 additions & 5 deletions

File tree

backend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sub-store",
3-
"version": "2.20.6",
3+
"version": "2.20.7",
44
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.",
55
"main": "src/main.js",
66
"scripts": {

backend/src/restful/miscs.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,18 @@ async function gistBackupAction(action, keep, encode) {
142142
let content;
143143
const settings = $.read(SETTINGS_KEY);
144144
const updated = settings.syncTime;
145+
146+
const encoding = encode || settings.gistUpload || 'base64';
147+
$.info(
148+
`Gist backup action: ${action}, keep: ${keep}, encode: ${encode}, settings encode: ${settings.gistUpload}, final encoding: ${encoding}`,
149+
);
145150
switch (action) {
146151
case 'upload':
147152
try {
148153
content = $.read('#sub-store');
149154
content = content ? JSON.parse(content) : {};
150155
if ($.env.isNode) content = JSON.parse(JSON.stringify($.cache));
151-
if (encode === 'plaintext') {
156+
if (encoding === 'plaintext') {
152157
content.settings.gistToken =
153158
'恢复后请重新设置 GitHub Token';
154159
content = JSON.stringify(content, null, ` `);
@@ -176,7 +181,7 @@ async function gistBackupAction(action, keep, encode) {
176181
content = $.read('#sub-store');
177182
content = content ? JSON.parse(content) : {};
178183
if ($.env.isNode) content = JSON.parse(JSON.stringify($.cache));
179-
if (encode === 'plaintext') {
184+
if (encoding === 'plaintext') {
180185
content.settings.gistToken = '恢复后请重新设置 GitHub Token';
181186
content = JSON.stringify(content, null, ` `);
182187
} else {

backend/src/restful/settings.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,15 @@ async function updateSettings(req, res) {
4343
...req.body,
4444
};
4545
$.write(newSettings, SETTINGS_KEY);
46-
await updateAvatar();
47-
await updateArtifactStore();
46+
if (
47+
req.body.githubUser ||
48+
req.body.gistToken ||
49+
req.body.githubProxy ||
50+
req.body.defaultProxy
51+
) {
52+
await updateAvatar();
53+
await updateArtifactStore();
54+
}
4855
success(res, newSettings);
4956
} catch (e) {
5057
$.error(`Failed to update settings: ${e.message ?? e}`);

0 commit comments

Comments
 (0)