From 178e51bbb8aec875e6e7ab53945edd413c98efa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Sun, 18 Jan 2026 14:34:08 +0800 Subject: [PATCH] Reduce mirror timeouts and use fast mirror cache Decreased default and test timeouts for mirrors to improve responsiveness. Updated logic in getAllGitHubTags and getWorkflowRunsFromHtml to use cached fast mirror lists instead of static lists for better performance. --- packages/napcat-common/src/mirror.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/napcat-common/src/mirror.ts b/packages/napcat-common/src/mirror.ts index 6899124b..4112de79 100644 --- a/packages/napcat-common/src/mirror.ts +++ b/packages/napcat-common/src/mirror.ts @@ -133,7 +133,7 @@ const defaultConfig: MirrorConfig = { apiMirrors: GITHUB_API_MIRRORS, rawMirrors: GITHUB_RAW_MIRRORS, nightlyLinkMirrors: NIGHTLY_LINK_MIRRORS, - timeout: 10000, // 10秒超时,平衡速度和可靠性 + timeout: 5000, // 5秒超时,平衡速度和可靠性 enabled: true, customMirror: undefined, }; @@ -257,7 +257,7 @@ export async function getFastMirrors (forceRefresh: boolean = false): Promise { // 开始镜像测速 - const timeout = 8000; // 测速超时 8 秒 + const timeout = 3000; // 测速超时 3 秒 // 并行测试所有镜像 const mirrors = currentConfig.fileMirrors.filter(m => m); @@ -821,8 +821,8 @@ export async function getAllGitHubTags (owner: string, repo: string, mirror?: st // 如果指定了镜像,只使用该镜像 mirrors = [mirror]; } else { - // 否则使用 auto 逻辑 - mirrors = ['', ...currentConfig.fileMirrors.filter(m => m)]; + // 否则使用 auto 逻辑,利用缓存的快速镜像列表 + mirrors = await getFastMirrors(); } // 并行请求 @@ -907,7 +907,8 @@ async function getWorkflowRunsFromHtml ( if (mirror) { mirrors = [mirror]; } else { - mirrors = ['', ...currentConfig.fileMirrors.filter(m => m)]; + // 使用缓存的快速镜像列表 + mirrors = await getFastMirrors(); } for (const mirrorItem of mirrors) {