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

This commit is contained in:
dompling
2021-10-18 09:17:48 +08:00
parent 638b510c7a
commit dbe107681d
3 changed files with 13 additions and 6 deletions
Regular → Executable
+7 -1
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({
+2 -2
View File
File diff suppressed because one or more lines are too long
+4 -3
View File
@@ -1,3 +1,4 @@
const DEBUG = process.env.NODE_ENV === "development";
// export const BACKEND_BASE = DEBUG ? `http://localhost:3000` : `https://sub.store`;
export const BACKEND_BASE = DEBUG ? `https://sub.store:9999` : `https://sub.store`;
const DEBUG = process.env.NODE_ENV === 'development';
const domain = process.env.DOMIAN || 'https://sub.store';
export const BACKEND_BASE = DEBUG ? `http://localhost:3000` : domain;
// export const BACKEND_BASE = DEBUG ? `https://sub.store:9999` : `https://sub.store`;