mirror of
https://github.com/sub-store-org/Sub-Store.git
synced 2025-08-10 00:52:40 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8a417d9852 | ||
|
|
ebff520499 |
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "sub-store",
|
||||
"version": "2.19.87",
|
||||
"version": "2.19.89",
|
||||
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.",
|
||||
"main": "src/main.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -41,10 +41,30 @@ export default function register($app) {
|
||||
);
|
||||
})
|
||||
.post((req, res) => {
|
||||
const { content } = req.body;
|
||||
$.write(content, '#sub-store');
|
||||
let { content } = req.body;
|
||||
try {
|
||||
content = JSON.parse(Base64.decode(content));
|
||||
if (Object.keys(content.settings).length === 0) {
|
||||
throw new Error('备份文件应该至少包含 settings 字段');
|
||||
}
|
||||
} catch (err) {
|
||||
try {
|
||||
content = JSON.parse(content);
|
||||
if (Object.keys(content.settings).length === 0) {
|
||||
throw new Error('备份文件应该至少包含 settings 字段');
|
||||
}
|
||||
} catch (err) {
|
||||
$.error(
|
||||
`备份文件校验失败, 无法还原\nReason: ${
|
||||
err.message ?? err
|
||||
}`,
|
||||
);
|
||||
throw new Error('备份文件校验失败, 无法还原');
|
||||
}
|
||||
}
|
||||
$.write(JSON.stringify(content, null, ` `), '#sub-store');
|
||||
if ($.env.isNode) {
|
||||
$.cache = JSON.parse(content);
|
||||
$.cache = content;
|
||||
$.persistCache();
|
||||
}
|
||||
migrate();
|
||||
|
||||
21
backend/src/vendor/open-api.js
vendored
21
backend/src/vendor/open-api.js
vendored
@@ -9,6 +9,7 @@ const isShadowRocket = 'undefined' !== typeof $rocket;
|
||||
const isEgern = 'object' == typeof egern;
|
||||
const isLanceX = 'undefined' != typeof $native;
|
||||
const isGUIforCores = typeof $Plugins !== 'undefined';
|
||||
import { Base64 } from 'js-base64';
|
||||
|
||||
function isPlainObject(obj) {
|
||||
return (
|
||||
@@ -120,13 +121,23 @@ export class OpenAPI {
|
||||
if (this.node.fs.existsSync(fpath)) {
|
||||
try {
|
||||
this.cache = JSON.parse(
|
||||
this.node.fs.readFileSync(`${fpath}`),
|
||||
this.node.fs.readFileSync(`${fpath}`, 'utf-8'),
|
||||
);
|
||||
} catch (e) {
|
||||
this.node.fs.copyFileSync(fpath, backupPath);
|
||||
this.error(
|
||||
`Failed to parse ${fpath}: ${e.message}. Backup created at ${backupPath}`,
|
||||
);
|
||||
try {
|
||||
const str = Base64.decode(
|
||||
this.node.fs.readFileSync(`${fpath}`, 'utf-8'),
|
||||
);
|
||||
this.cache = JSON.parse(str);
|
||||
this.node.fs.writeFileSync(fpath, str, {
|
||||
flag: 'w',
|
||||
});
|
||||
} catch (e) {
|
||||
this.node.fs.copyFileSync(fpath, backupPath);
|
||||
this.error(
|
||||
`Failed to parse ${fpath}: ${e.message}. Backup created at ${backupPath}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isPlainObject(this.cache)) {
|
||||
|
||||
1
backend/sub-store_1752902525508.json
Normal file
1
backend/sub-store_1752902525508.json
Normal file
File diff suppressed because one or more lines are too long
1
backend/sub-store_1752902571053.json
Normal file
1
backend/sub-store_1752902571053.json
Normal file
File diff suppressed because one or more lines are too long
1
backend/sub-store_1752902602701.json
Normal file
1
backend/sub-store_1752902602701.json
Normal file
File diff suppressed because one or more lines are too long
1
backend/sub-store_1752902651631.json
Normal file
1
backend/sub-store_1752902651631.json
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user