feat: 支持配置独立的 GitHub API 请求超时

This commit is contained in:
xream committed 2026-05-10 22:49:18 +08:00
1 parent 506d8c3213
commit 59f985abce
3 files changed
+9 -4

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "sub-store",
"version": "2.22.25",
"version": "2.22.26",
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.",
"main": "src/main.js",
"scripts": {
+4
View File
@@ -67,6 +67,7 @@ async function updateSettings(req, res) {
};
[
'defaultTimeout',
'githubApiTimeout',
'cacheThreshold',
'resourceCacheTtl',
'headersCacheTtl',
@@ -117,6 +118,7 @@ export async function updateAvatar() {
syncPlatform,
githubProxy,
githubApiUrl,
githubApiTimeout,
} = settings;
if (username) {
if (syncPlatform === 'gitlab') {
@@ -130,6 +132,7 @@ export async function updateAvatar() {
'User-Agent':
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.141 Safari/537.36',
},
timeout: githubApiTimeout || 10000,
})
.then((resp) => JSON.parse(resp.body));
settings.avatarUrl = data[0]['avatar_url'].replace(
@@ -157,6 +160,7 @@ export async function updateAvatar() {
'User-Agent':
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.141 Safari/537.36',
},
timeout: githubApiTimeout || 10000,
})
.then((resp) => JSON.parse(resp.body));
settings.avatarUrl = data['avatar_url'];
+4 -3
View File
@@ -36,10 +36,11 @@ export default class Gist {
const { isStash, isLoon, isShadowRocket, isQX } = ENV();
const {
defaultProxy,
defaultTimeout: timeout,
githubApiTimeout,
githubProxy,
githubApiUrl,
} = $.read(SETTINGS_KEY);
const githubApiRequestTimeout = githubApiTimeout || 10000;
const githubGistBaseURL = getGithubGistBaseURL({
githubApiUrl,
githubProxy,
@@ -75,7 +76,7 @@ export default class Gist {
...(isLoon && proxy ? { node: proxy } : {}),
...(isQX && proxy ? { opts: { policy: proxy } } : {}),
...(proxy ? getPolicyDescriptor(proxy) : {}),
timeout: timeout || 8000,
timeout: githubApiRequestTimeout,
events: {
onResponse: (resp) => {
@@ -125,7 +126,7 @@ export default class Gist {
...(isLoon && proxy ? { node: proxy } : {}),
...(isQX && proxy ? { opts: { policy: proxy } } : {}),
...(proxy ? getPolicyDescriptor(proxy) : {}),
timeout: timeout || 8000,
timeout: githubApiRequestTimeout,
events: {
onResponse: (resp) => {