Skip to content

Commit

Permalink
feat: 支持完整导出和导入 Sub-Store 单条订阅数据
Browse files Browse the repository at this point in the history
  • Loading branch information
xream committed Apr 22, 2024
1 parent bafaf07 commit 6f7fe82
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sub-store",
"version": "2.14.297",
"version": "2.14.298",
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
"main": "src/main.js",
"scripts": {
Expand Down
12 changes: 11 additions & 1 deletion backend/src/restful/subscriptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,21 @@ function createSubscription(req, res) {

function getSubscription(req, res) {
let { name } = req.params;
let { raw } = req.query;
name = decodeURIComponent(name);
const allSubs = $.read(SUBS_KEY);
const sub = findByName(allSubs, name);
if (sub) {
success(res, sub);
if (raw) {
res.set('content-type', 'application/json')
.set(
'content-disposition',
`attachment; filename="${encodeURIComponent(name)}.json"`,
)
.send(JSON.stringify(sub));
} else {
success(res, sub);
}
} else {
failed(
res,
Expand Down

0 comments on commit 6f7fe82

Please sign in to comment.