From 522189bce68b62e4d1382596fb0c8bb266f7811d Mon Sep 17 00:00:00 2001 From: xianyi Date: Wed, 3 Dec 2025 15:21:06 +0800 Subject: [PATCH] =?UTF-8?q?=E9=81=BF=E5=85=8D=E9=87=8D=E5=A4=8D=E6=89=93?= =?UTF-8?q?=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/UI8/UI8.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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 = () => {