feat: 订阅刷新按钮逻辑调整为无缓存刷新订阅和流量

This commit is contained in:
xream 2024-11-10 01:22:48 +08:00
parent 772f431887
commit cc58a5541e
No known key found for this signature in database
GPG Key ID: 1D2C5225471789F9
4 changed files with 27 additions and 3 deletions

View File

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

View File

@ -75,6 +75,7 @@ async function downloadSubscription(req, res) {
includeUnsupportedProxy,
resultFormat,
proxy,
noCache,
} = req.query;
let $options = {};
if (req.query.$options) {
@ -131,6 +132,10 @@ async function downloadSubscription(req, res) {
$.info(`手动指定了 target 为 SurgeMac, 将使用 Mihomo External`);
}
if (noCache) {
$.info(`指定不使用缓存: ${noCache}`);
}
const allSubs = $.read(SUBS_KEY);
const sub = findByName(allSubs, name);
if (sub) {
@ -151,6 +156,7 @@ async function downloadSubscription(req, res) {
},
$options,
proxy,
noCache,
});
if (
@ -283,6 +289,7 @@ async function downloadCollection(req, res) {
includeUnsupportedProxy,
resultFormat,
proxy,
noCache,
} = req.query;
let $options = {};
@ -325,6 +332,9 @@ async function downloadCollection(req, res) {
if (useMihomoExternal) {
$.info(`手动指定了 target 为 SurgeMac, 将使用 Mihomo External`);
}
if (noCache) {
$.info(`指定不使用缓存: ${noCache}`);
}
if (collection) {
try {
@ -340,6 +350,7 @@ async function downloadCollection(req, res) {
},
$options,
proxy,
noCache,
});
// forward flow header from the first subscription in this collection

View File

@ -39,6 +39,7 @@ async function produceArtifact({
awaitCustomCache,
$options,
proxy,
noCache,
}) {
platform = platform || 'JSON';
@ -72,6 +73,7 @@ async function produceArtifact({
proxy || sub.proxy,
undefined,
awaitCustomCache,
noCache,
);
} catch (err) {
errors[url] = err;
@ -119,6 +121,7 @@ async function produceArtifact({
proxy || sub.proxy,
undefined,
awaitCustomCache,
noCache,
);
} catch (err) {
errors[url] = err;
@ -237,6 +240,9 @@ async function produceArtifact({
proxy ||
sub.proxy ||
collection.proxy,
undefined,
undefined,
noCache,
);
} catch (err) {
errors[url] = err;
@ -410,6 +416,9 @@ async function produceArtifact({
ua || file.ua,
undefined,
file.proxy || proxy,
undefined,
undefined,
noCache,
);
} catch (err) {
errors[url] = err;
@ -458,6 +467,9 @@ async function produceArtifact({
ua || file.ua,
undefined,
file.proxy || proxy,
undefined,
undefined,
noCache,
);
} catch (err) {
errors[url] = err;

View File

@ -21,6 +21,7 @@ export default async function download(
customProxy,
skipCustomCache,
awaitCustomCache,
noCache,
) {
let $arguments = {};
let url = rawUrl.replace(/#noFlow$/, '');
@ -65,7 +66,7 @@ export default async function download(
if (customCacheKey && !skipCustomCache) {
const customCached = $.read(customCacheKey);
const cached = resourceCache.get(id);
if (!$arguments?.noCache && cached) {
if (!noCache && !$arguments?.noCache && cached) {
$.info(
`乐观缓存: URL ${url}\n存在有效的常规缓存\n使用常规缓存以避免重复请求`,
);
@ -149,7 +150,7 @@ export default async function download(
// try to find in app cache
const cached = resourceCache.get(id);
if (!$arguments?.noCache && cached) {
if (!noCache && !$arguments?.noCache && cached) {
$.info(`使用缓存: ${url}`);
result = cached;
if (customCacheKey) {