Merge pull request #61 from dompling/master

更新 sub-store.js 兼容 node 服务端
This commit is contained in:
Peng-YM 2021-10-24 14:26:38 +08:00 committed by GitHub
commit 4d1c9a49ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 53 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); const settings = $.read(SETTINGS_KEY);
settings.syncTime = new Date().getTime(); settings.syncTime = new Date().getTime();
$.write(settings, SETTINGS_KEY); $.write(settings, SETTINGS_KEY);
content = $.read("#sub-store"); content = $.read("#sub-store");
if($.env.isNode) content = JSON.stringify($.cache,null,` `)
$.info(`上传备份中...`); $.info(`上传备份中...`);
await gist.upload({filename: GIST_BACKUP_FILE_NAME, content}); await gist.upload({filename: GIST_BACKUP_FILE_NAME, content});
break; break;
@ -833,6 +833,12 @@ function service() {
content = await gist.download(GIST_BACKUP_FILE_NAME); content = await gist.download(GIST_BACKUP_FILE_NAME);
// restore settings // restore settings
$.write(content, "#sub-store"); $.write(content, "#sub-store");
if($.env.isNode){
content = JSON.parse(content)
Object.keys(content).forEach(key=>{
$.write(content[key],key)
})
}
break; break;
} }
res.json({ res.json({

File diff suppressed because one or more lines are too long

40
nginx/front.conf Normal file
View File

@ -0,0 +1,40 @@
upstream api {
server 0.0.0.0:3000;
}
server {
listen 6080;
# allow 127.0.0.1;
# allow 0.0.0.0;
# deny all;
gzip on;
gzip_static on;
gzip_types text/plain application/json application/javascript application/x-javascript text/css application/xml text/javascript;
gzip_proxied any;
gzip_vary on;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.0;
location / {
root /Sub-Store/web/dist;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
location /api {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://api;
}
location /download {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://api;
}
}

View File

@ -1,3 +1,4 @@
const DEBUG = process.env.NODE_ENV === "development"; const DEBUG = process.env.NODE_ENV === 'development';
// export const BACKEND_BASE = DEBUG ? `http://localhost:3000` : `https://sub.store`; const domain = process.env.DOMIAN || 'https://sub.store';
export const BACKEND_BASE = DEBUG ? `https://sub.store:9999` : `https://sub.store`; export const BACKEND_BASE = DEBUG ? `http://localhost:3000` : domain;
// export const BACKEND_BASE = DEBUG ? `https://sub.store:9999` : `https://sub.store`;