Skip to content

Commit fc92fb3

Browse files
safe1ineclaude
andcommitted
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>
1 parent 5b00d54 commit fc92fb3

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

frontend/index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
<meta name="author" content="MonkeyCode AI" />
1313
<meta name="robots" content="index, follow" />
1414
<link rel="canonical" href="https://monkeycode-ai.com" />
15+
<!-- 必须在所有模块代码之前设置,确保 cap.js 使用本地 WASM 而非 CDN(jsdelivr.net 在国内不稳定) -->
16+
<script>window.CAP_CUSTOM_WASM_URL = location.origin + "/captcha/cap_wasm.js";</script>
1517
</head>
1618
<body>
1719
<div id="root" class="font-google-sans-code"></div>

frontend/src/main.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ dayjs.locale('zh-cn');
1414
dayjs.extend(duration);
1515
dayjs.extend(relativeTime);
1616

17-
window.CAP_CUSTOM_WASM_URL = window.location.origin + "/captcha/cap_wasm.js";
18-
1917
// 预加载字体
2018
preloadFonts().then(() => {}).catch((error) => {
2119
console.warn('字体预加载失败:', error);

frontend/src/utils/common.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,10 @@ export async function captchaChallenge(): Promise<string | null> {
306306
if (data.success) {
307307
return data.token
308308
}
309+
console.error('[captcha] solve() returned success=false', data)
309310
return null
310-
} catch {
311+
} catch (err) {
312+
console.error('[captcha] exception:', err)
311313
return null
312314
}
313315
}

0 commit comments

Comments
 (0)