fix(captcha): 修复 WebView 里 cap.js WASM 走 CDN 导致验证码失败

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 <noreply@anthropic.com>
This commit is contained in:
MonsterandClaude Sonnet 4.6 committed 2026-03-24 14:47:48 +08:00
1 parent 5b00d54a92
commit fc92fb337c
3 files changed
+5 -3

No files matched your search

+2
View File
@@ -12,6 +12,8 @@
<meta name="author" content="MonkeyCode AI" />
<meta name="robots" content="index, follow" />
<link rel="canonical" href="https://monkeycode-ai.com" />
<!-- 必须在所有模块代码之前设置,确保 cap.js 使用本地 WASM 而非 CDN(jsdelivr.net 在国内不稳定) -->
<script>window.CAP_CUSTOM_WASM_URL = location.origin + "/captcha/cap_wasm.js";</script>
</head>
<body>
<div id="root" class="font-google-sans-code"></div>
-2
View File
@@ -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);
+3 -1
View File
@@ -306,8 +306,10 @@ export async function captchaChallenge(): Promise<string | null> {
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
}
}