mirror of
https://github.com/sub-store-org/Sub-Store.git
synced 2026-12-06 11:20:07 +00:00
feat: Gist 备份选项
This commit is contained in:
3 files changed
+17
-5
No files matched your search
@@ -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": {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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}`);
|
||||
|
||||
Reference in new issue
Block a user