Skip to content

Commit 59f985a

Browse files
committed
feat: 支持配置独立的 GitHub API 请求超时
1 parent 506d8c3 commit 59f985a

3 files changed

Lines changed: 9 additions & 4 deletions

File tree

backend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sub-store",
3-
"version": "2.22.25",
3+
"version": "2.22.26",
44
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.",
55
"main": "src/main.js",
66
"scripts": {

backend/src/restful/settings.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ async function updateSettings(req, res) {
6767
};
6868
[
6969
'defaultTimeout',
70+
'githubApiTimeout',
7071
'cacheThreshold',
7172
'resourceCacheTtl',
7273
'headersCacheTtl',
@@ -117,6 +118,7 @@ export async function updateAvatar() {
117118
syncPlatform,
118119
githubProxy,
119120
githubApiUrl,
121+
githubApiTimeout,
120122
} = settings;
121123
if (username) {
122124
if (syncPlatform === 'gitlab') {
@@ -130,6 +132,7 @@ export async function updateAvatar() {
130132
'User-Agent':
131133
'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',
132134
},
135+
timeout: githubApiTimeout || 10000,
133136
})
134137
.then((resp) => JSON.parse(resp.body));
135138
settings.avatarUrl = data[0]['avatar_url'].replace(
@@ -157,6 +160,7 @@ export async function updateAvatar() {
157160
'User-Agent':
158161
'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',
159162
},
163+
timeout: githubApiTimeout || 10000,
160164
})
161165
.then((resp) => JSON.parse(resp.body));
162166
settings.avatarUrl = data['avatar_url'];

backend/src/utils/gist.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,11 @@ export default class Gist {
3636
const { isStash, isLoon, isShadowRocket, isQX } = ENV();
3737
const {
3838
defaultProxy,
39-
defaultTimeout: timeout,
39+
githubApiTimeout,
4040
githubProxy,
4141
githubApiUrl,
4242
} = $.read(SETTINGS_KEY);
43+
const githubApiRequestTimeout = githubApiTimeout || 10000;
4344
const githubGistBaseURL = getGithubGistBaseURL({
4445
githubApiUrl,
4546
githubProxy,
@@ -75,7 +76,7 @@ export default class Gist {
7576
...(isLoon && proxy ? { node: proxy } : {}),
7677
...(isQX && proxy ? { opts: { policy: proxy } } : {}),
7778
...(proxy ? getPolicyDescriptor(proxy) : {}),
78-
timeout: timeout || 8000,
79+
timeout: githubApiRequestTimeout,
7980

8081
events: {
8182
onResponse: (resp) => {
@@ -125,7 +126,7 @@ export default class Gist {
125126
...(isLoon && proxy ? { node: proxy } : {}),
126127
...(isQX && proxy ? { opts: { policy: proxy } } : {}),
127128
...(proxy ? getPolicyDescriptor(proxy) : {}),
128-
timeout: timeout || 8000,
129+
timeout: githubApiRequestTimeout,
129130

130131
events: {
131132
onResponse: (resp) => {

0 commit comments

Comments
 (0)