feat: Gist 备份选项

This commit is contained in:
xream committed 2025-08-19 16:54:32 +08:00
1 parent 94c820e4ad
commit 9569068b23
3 files changed
+17 -5

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "sub-store",
"version": "2.20.6",
"version": "2.20.7",
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.",
"main": "src/main.js",
"scripts": {
+7 -2
View File
@@ -142,13 +142,18 @@ async function gistBackupAction(action, keep, encode) {
let content;
const settings = $.read(SETTINGS_KEY);
const updated = settings.syncTime;
const encoding = encode || settings.gistUpload || 'base64';
$.info(
`Gist backup action: ${action}, keep: ${keep}, encode: ${encode}, settings encode: ${settings.gistUpload}, final encoding: ${encoding}`,
);
switch (action) {
case 'upload':
try {
content = $.read('#sub-store');
content = content ? JSON.parse(content) : {};
if ($.env.isNode) content = JSON.parse(JSON.stringify($.cache));
if (encode === 'plaintext') {
if (encoding === 'plaintext') {
content.settings.gistToken =
'恢复后请重新设置 GitHub Token';
content = JSON.stringify(content, null, ` `);
@@ -176,7 +181,7 @@ async function gistBackupAction(action, keep, encode) {
content = $.read('#sub-store');
content = content ? JSON.parse(content) : {};
if ($.env.isNode) content = JSON.parse(JSON.stringify($.cache));
if (encode === 'plaintext') {
if (encoding === 'plaintext') {
content.settings.gistToken = '恢复后请重新设置 GitHub Token';
content = JSON.stringify(content, null, ` `);
} else {
+9 -2
View File
@@ -43,8 +43,15 @@ async function updateSettings(req, res) {
...req.body,
};
$.write(newSettings, SETTINGS_KEY);
await updateAvatar();
await updateArtifactStore();
if (
req.body.githubUser ||
req.body.gistToken ||
req.body.githubProxy ||
req.body.defaultProxy
) {
await updateAvatar();
await updateArtifactStore();
}
success(res, newSettings);
} catch (e) {
$.error(`Failed to update settings: ${e.message ?? e}`);