避免重复打印

This commit is contained in:
xianyi
2025-12-03 15:21:06 +08:00
parent 0bbfba0284
commit 522189bce6

View File

@@ -284,6 +284,12 @@ const UI8: React.FC = () => {
// 打印PDF功能
const handleConfirm = useCallback(async () => {
// 避免重复点击导致多次打印
if (isPrinting) {
window.electronAPI?.log("warn", "[UI8] 检测到重复打印点击,已忽略");
return;
}
if (!window.electronAPI?.printPdf) {
const errorMsg = "打印功能不可用,请在 Electron 环境中运行";
window.electronAPI?.log("error", errorMsg);
@@ -357,7 +363,7 @@ const UI8: React.FC = () => {
} finally {
setIsPrinting(false);
}
}, [originPdfUrls, pdfFiles, printers.length, selectedPrinter, navigate]);
}, [originPdfUrls, pdfFiles, printers.length, selectedPrinter, navigate, isPrinting]);
const handlePageCountUpdate = useCallback((index: number, numPages: number) => {
window.electronAPI?.log("info", `[UI8] PDF渲染成功 (index=${index}),共 ${numPages}`);
@@ -462,6 +468,7 @@ const UI8: React.FC = () => {
<ConfirmButton
text={isPrinting ? "打印中..." : "打印导检单"}
onClick={handleConfirm}
disabled={isPrinting}
/>
</div>
</div>