更新 sub-store.js 兼容 node 服务端

This commit is contained in:
dompling
2021-10-18 09:17:48 +08:00
parent 046b70a561
commit bcfcd6d91d
3 changed files with 13 additions and 6 deletions

8
backend/sub-store.js Normal file → Executable file
View File

@@ -823,8 +823,8 @@ function service() {
const settings = $.read(SETTINGS_KEY);
settings.syncTime = new Date().getTime();
$.write(settings, SETTINGS_KEY);
content = $.read("#sub-store");
if($.env.isNode) content = JSON.stringify($.cache,null,` `)
$.info(`上传备份中...`);
await gist.upload({filename: GIST_BACKUP_FILE_NAME, content});
break;
@@ -833,6 +833,12 @@ function service() {
content = await gist.download(GIST_BACKUP_FILE_NAME);
// restore settings
$.write(content, "#sub-store");
if($.env.isNode){
content = JSON.parse(content)
Object.keys(content).forEach(key=>{
$.write(content[key],key)
})
}
break;
}
res.json({

File diff suppressed because one or more lines are too long