处理身份证读取错误时恢复 UI 状态并添加用户提示
This commit is contained in:
@@ -70,6 +70,14 @@ const U1: React.FC = () => {
|
|||||||
window.electronAPI.onIdCardError((e: any) => {
|
window.electronAPI.onIdCardError((e: any) => {
|
||||||
console.error("[idcard-error]", e.payload);
|
console.error("[idcard-error]", e.payload);
|
||||||
window.electronAPI.log("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 () => {
|
return () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user