From fc92fb337cb90a71c2c71af07573da51563ee470 Mon Sep 17 00:00:00 2001 From: Monster <389264167@qq.com> Date: Tue, 24 Mar 2026 14:47:48 +0800 Subject: [PATCH] =?UTF-8?q?fix(captcha):=20=E4=BF=AE=E5=A4=8D=20WebView=20?= =?UTF-8?q?=E9=87=8C=20cap.js=20WASM=20=E8=B5=B0=20CDN=20=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E9=AA=8C=E8=AF=81=E7=A0=81=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit cap.js 模块级代码早于 main.tsx body 执行,此时 window.CAP_CUSTOM_WASM_URL 还未赋值,导致 cap.js 使用 cdn.jsdelivr.net(国内不稳定)。 将赋值移到 index.html 的内联 script,确保在所有模块代码之前执行。 同时删除 main.tsx 中的重复赋值,并为 captchaChallenge 加上错误日志。 Co-Authored-By: Claude Sonnet 4.6 --- frontend/index.html | 2 ++ frontend/src/main.tsx | 2 -- frontend/src/utils/common.tsx | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/frontend/index.html b/frontend/index.html index 0977657f..973cb220 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -12,6 +12,8 @@ + +
diff --git a/frontend/src/main.tsx b/frontend/src/main.tsx index 0872601c..d52d3a89 100644 --- a/frontend/src/main.tsx +++ b/frontend/src/main.tsx @@ -14,8 +14,6 @@ dayjs.locale('zh-cn'); dayjs.extend(duration); dayjs.extend(relativeTime); -window.CAP_CUSTOM_WASM_URL = window.location.origin + "/captcha/cap_wasm.js"; - // 预加载字体 preloadFonts().then(() => {}).catch((error) => { console.warn('字体预加载失败:', error); diff --git a/frontend/src/utils/common.tsx b/frontend/src/utils/common.tsx index cf3cd9b6..d30321c6 100644 --- a/frontend/src/utils/common.tsx +++ b/frontend/src/utils/common.tsx @@ -306,8 +306,10 @@ export async function captchaChallenge(): Promise { if (data.success) { return data.token } + console.error('[captcha] solve() returned success=false', data) return null - } catch { + } catch (err) { + console.error('[captcha] exception:', err) return null } }