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