feat: 下载文件名增加前后缀

This commit is contained in:
xream 2025-02-14 15:39:13 +08:00
parent f9d120bac3
commit 5058662651
No known key found for this signature in database
GPG Key ID: 1D2C5225471789F9
5 changed files with 49 additions and 5 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "sub-store", "name": "sub-store",
"version": "2.16.40", "version": "2.16.41",
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.", "description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.",
"main": "src/main.js", "main": "src/main.js",
"scripts": { "scripts": {

View File

@ -59,7 +59,18 @@ function getCollection(req, res) {
res.set('content-type', 'application/json') res.set('content-type', 'application/json')
.set( .set(
'content-disposition', 'content-disposition',
`attachment; filename="${encodeURIComponent(name)}.json"`, `attachment; filename="${encodeURIComponent(
`sub-store_collection_${name}_${new Date()
.toLocaleString('zh-CN', {
year: 'numeric',
day: 'numeric',
month: 'numeric',
hour: 'numeric',
minute: 'numeric',
second: 'numeric',
})
.replace(/\D/g, '')}.json`,
)}"`,
) )
.send(JSON.stringify(collection)); .send(JSON.stringify(collection));
} else { } else {

View File

@ -209,7 +209,18 @@ function getWholeFile(req, res) {
res.set('content-type', 'application/json') res.set('content-type', 'application/json')
.set( .set(
'content-disposition', 'content-disposition',
`attachment; filename="${encodeURIComponent(name)}.json"`, `attachment; filename="${encodeURIComponent(
`sub-store_file_${name}_${new Date()
.toLocaleString('zh-CN', {
year: 'numeric',
day: 'numeric',
month: 'numeric',
hour: 'numeric',
minute: 'numeric',
second: 'numeric',
})
.replace(/\D/g, '')}.json`,
)}"`,
) )
.send(JSON.stringify(file)); .send(JSON.stringify(file));
} else { } else {

View File

@ -27,7 +27,18 @@ export default function register($app) {
res.set('content-type', 'application/json') res.set('content-type', 'application/json')
.set( .set(
'content-disposition', 'content-disposition',
'attachment; filename="sub-store.json"', `attachment; filename="${encodeURIComponent(
`sub-store_data_${new Date()
.toLocaleString('zh-CN', {
year: 'numeric',
day: 'numeric',
month: 'numeric',
hour: 'numeric',
minute: 'numeric',
second: 'numeric',
})
.replace(/\D/g, '')}.json`,
)}"`,
) )
.send( .send(
$.env.isNode $.env.isNode

View File

@ -264,7 +264,18 @@ function getSubscription(req, res) {
res.set('content-type', 'application/json') res.set('content-type', 'application/json')
.set( .set(
'content-disposition', 'content-disposition',
`attachment; filename="${encodeURIComponent(name)}.json"`, `attachment; filename="${encodeURIComponent(
`sub-store_subscription_${name}_${new Date()
.toLocaleString('zh-CN', {
year: 'numeric',
day: 'numeric',
month: 'numeric',
hour: 'numeric',
minute: 'numeric',
second: 'numeric',
})
.replace(/\D/g, '')}.json`,
)}"`,
) )
.send(JSON.stringify(sub)); .send(JSON.stringify(sub));
} else { } else {