From 59f985abce43052b7a8e87a6aacb30a3fe64af99 Mon Sep 17 00:00:00 2001 From: xream Date: Sun, 10 May 2026 22:49:18 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E7=8B=AC=E7=AB=8B=E7=9A=84=20GitHub=20API=20=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E8=B6=85=E6=97=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/package.json | 2 +- backend/src/restful/settings.js | 4 ++++ backend/src/utils/gist.js | 7 ++++--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/backend/package.json b/backend/package.json index a75c80b2..a4b7f63d 100644 --- a/backend/package.json +++ b/backend/package.json @@ -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": { diff --git a/backend/src/restful/settings.js b/backend/src/restful/settings.js index a7ef0836..61022ae1 100644 --- a/backend/src/restful/settings.js +++ b/backend/src/restful/settings.js @@ -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']; diff --git a/backend/src/utils/gist.js b/backend/src/utils/gist.js index 9a7cd4e5..3fdc580b 100644 --- a/backend/src/utils/gist.js +++ b/backend/src/utils/gist.js @@ -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) => {