feat: 单条订阅和文件支持链接参数 produceType raw, 此时返回原始数据的数组

This commit is contained in:
xream 2025-05-17 20:22:24 +08:00
parent af9a2c86c1
commit 1d12dc55bd
No known key found for this signature in database
GPG Key ID: 1D2C5225471789F9
3 changed files with 13 additions and 1 deletions

View File

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

View File

@ -64,6 +64,7 @@ async function getFile(req, res) {
ignoreFailedRemoteFile,
proxy,
noCache,
produceType,
} = req.query;
let $options = {
_req: {
@ -128,6 +129,10 @@ async function getFile(req, res) {
if (noCache) {
$.info(`指定不使用缓存: ${noCache}`);
}
if (produceType) {
produceType = decodeURIComponent(produceType);
$.info(`指定生产类型: ${produceType}`);
}
const allFiles = $.read(FILES_KEY);
const file = findByName(allFiles, name);
@ -144,6 +149,7 @@ async function getFile(req, res) {
$options,
proxy,
noCache,
produceType,
});
try {

View File

@ -173,6 +173,9 @@ async function produceArtifact({
raw.push(sub.content);
}
}
if (produceType === 'raw') {
return (Array.isArray(raw) ? raw : [raw]).flat();
}
// parse proxies
let proxies = (Array.isArray(raw) ? raw : [raw])
.map((i) => ProxyUtils.parse(i))
@ -570,6 +573,9 @@ async function produceArtifact({
}
}
}
if (produceType === 'raw') {
return (Array.isArray(raw) ? raw : [raw]).flat();
}
const files = (Array.isArray(raw) ? raw : [raw]).flat();
let filesContent = files
.filter((i) => i != null && i !== '')