feat: 修复弹窗失败问题

This commit is contained in:
zdl
2025-10-16 16:08:43 +08:00
parent 081eb3c5c3
commit 52bec7ce8a
3 changed files with 33 additions and 14 deletions

View File

@@ -18,6 +18,18 @@ export default function VerificationCodeInput({
colorScheme = "green",
isRequired = true
}) {
// 包装 onSendCode确保所有错误都被捕获防止被 ErrorBoundary 捕获
const handleSendCode = async () => {
try {
if (onSendCode) {
await onSendCode();
}
} catch (error) {
// 错误已经在父组件处理,这里只需要防止未捕获的 Promise rejection
console.error('Send code error (caught in VerificationCodeInput):', error);
}
};
return (
<FormControl isRequired={isRequired} isInvalid={!!error}>
<HStack>
@@ -30,7 +42,7 @@ export default function VerificationCodeInput({
/>
<Button
colorScheme={colorScheme}
onClick={onSendCode}
onClick={handleSendCode}
isDisabled={countdown > 0 || isLoading}
isLoading={isSending}
minW="120px"