diff --git a/src/pages/UI8/UI8.tsx b/src/pages/UI8/UI8.tsx index dfeed05..1a9bfb7 100644 --- a/src/pages/UI8/UI8.tsx +++ b/src/pages/UI8/UI8.tsx @@ -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 = () => {