mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2025-06-04 11:13:59 +08:00
feat: 若设置 $options._res.headers, 拉取文件时将设置自定义响应头
This commit is contained in:
parent
532be2ff8c
commit
e4f646af0c
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "sub-store",
|
||||
"version": "2.19.55",
|
||||
"version": "2.19.56",
|
||||
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.",
|
||||
"main": "src/main.js",
|
||||
"scripts": {
|
||||
|
@ -150,6 +150,7 @@ async function getFile(req, res) {
|
||||
proxy,
|
||||
noCache,
|
||||
produceType,
|
||||
all: true,
|
||||
});
|
||||
|
||||
try {
|
||||
@ -184,9 +185,15 @@ async function getFile(req, res) {
|
||||
)}`,
|
||||
);
|
||||
}
|
||||
res.set('Content-Type', 'text/plain; charset=utf-8').send(
|
||||
output ?? '',
|
||||
);
|
||||
res.set('Content-Type', 'text/plain; charset=utf-8');
|
||||
if (output?.$options?._res?.headers) {
|
||||
Object.entries(output.$options._res.headers).forEach(
|
||||
([key, value]) => {
|
||||
res.set(key, value);
|
||||
},
|
||||
);
|
||||
}
|
||||
res.send(output?.$content ?? '');
|
||||
} catch (err) {
|
||||
$.notify(
|
||||
`🌍 Sub-Store 下载文件失败`,
|
||||
|
@ -40,6 +40,7 @@ async function produceArtifact({
|
||||
$options,
|
||||
proxy,
|
||||
noCache,
|
||||
all,
|
||||
}) {
|
||||
platform = platform || 'JSON';
|
||||
|
||||
@ -595,7 +596,7 @@ async function produceArtifact({
|
||||
)
|
||||
: { $content: filesContent, $files: files, $options };
|
||||
|
||||
return processed?.$content ?? '';
|
||||
return (all ? processed : processed?.$content) ?? '';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -59,6 +59,15 @@ function operator(proxies = [], targetPlatform, context) {
|
||||
// }
|
||||
// console.log($options)
|
||||
|
||||
// 若设置 $options._res.headers
|
||||
// 则会在输出文件时设置响应头, 例如:
|
||||
|
||||
// $options._res = {
|
||||
// headers: {
|
||||
// 'X-Custom': '1'
|
||||
// }
|
||||
// }
|
||||
|
||||
// targetPlatform 为输出的目标平台
|
||||
|
||||
// lodash
|
||||
|
Loading…
x
Reference in New Issue
Block a user