feat: 支持订阅参数 url 同时支持单条本地节点内容, 支持多一级路由指定输出目标

This commit is contained in:
xream 2024-12-29 21:03:52 +08:00
parent 278beae99a
commit 7e2109dc68
No known key found for this signature in database
GPG Key ID: 1D2C5225471789F9
2 changed files with 15 additions and 5 deletions

View File

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

View File

@ -18,6 +18,11 @@ export default function register($app) {
$app.get('/download/collection/:name', downloadCollection);
$app.get('/download/:name', downloadSubscription);
$app.get('/download/:name/:target', async (req, res) => {
req.query.target = req.params.target;
$.info(`使用路由指定目标: ${req.params.target}`);
await downloadSubscription(req, res);
});
$app.get(
'/download/collection/:name/api/v1/server/details',
async (req, res) => {
@ -98,6 +103,14 @@ async function downloadSubscription(req, res) {
if (url) {
url = decodeURIComponent(url);
$.info(`指定远程订阅 URL: ${url}`);
if (!/^https?:\/\//.test(url)) {
content = url;
$.info(`URL 不是链接,视为本地订阅`);
}
}
if (content) {
content = decodeURIComponent(content);
$.info(`指定本地订阅: ${content}`);
}
if (proxy) {
proxy = decodeURIComponent(proxy);
@ -107,10 +120,7 @@ async function downloadSubscription(req, res) {
ua = decodeURIComponent(ua);
$.info(`指定远程订阅 User-Agent: ${ua}`);
}
if (content) {
content = decodeURIComponent(content);
$.info(`指定本地订阅: ${content}`);
}
if (mergeSources) {
mergeSources = decodeURIComponent(mergeSources);
$.info(`指定合并来源: ${mergeSources}`);