处理身份证读取错误时恢复 UI 状态并添加用户提示

This commit is contained in:
yuchenglong
2025-11-20 15:23:39 +08:00
parent e1fa80e4eb
commit fde534e0fe

View File

@@ -70,6 +70,14 @@ const U1: React.FC = () => {
window.electronAPI.onIdCardError((e: any) => {
console.error("[idcard-error]", e.payload);
window.electronAPI.log("error", `[idcard-error] ${e.payload}`);
// 发生错误时立即恢复 UI 状态
if (timerRef.current) {
clearTimeout(timerRef.current);
timerRef.current = null;
}
setReading(false);
window.electronAPI.stopIdCardListen().catch(() => {});
alert(`读取身份证失败: ${e.payload}`);
});
return () => {