From 89d4daa49829242ae3009e9cc3e847694677736f Mon Sep 17 00:00:00 2001 From: Linzp Date: Wed, 22 Oct 2025 17:19:44 +0800 Subject: [PATCH] =?UTF-8?q?printbutton=E6=B7=BB=E5=8A=A0onBeforePrint?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/components/PrintButton/index.js | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 4794be8..f461610 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@kne/react-file", - "version": "0.1.26", + "version": "0.1.27", "description": "提供了文件上传,文件预览,文件批量管理等功能", "syntax": { "esmodules": true diff --git a/src/components/PrintButton/index.js b/src/components/PrintButton/index.js index d8917be..e5042a8 100644 --- a/src/components/PrintButton/index.js +++ b/src/components/PrintButton/index.js @@ -2,13 +2,14 @@ import React, { useState } from 'react'; import { Button } from 'antd'; import { useReactToPrint } from 'react-to-print'; -const PrintButton = ({ content, onSuccess, onError, printProps, contentRef, ...props }) => { +const PrintButton = ({ content, onSuccess, onError, onBeforePrint, printProps, contentRef, ...props }) => { const [isLoading, setIsLoading] = useState(false); const handler = useReactToPrint({ contentRef, bodyClass: document.body.getAttribute('class'), - onBeforePrint: async () => { + onBeforePrint: async (...args) => { setIsLoading(true); + onBeforePrint && (await onBeforePrint(...args)); }, onPrintError: (...args) => { setIsLoading(false);