From 69692d89a5191569556f0942a8f513418335d4a6 Mon Sep 17 00:00:00 2001 From: LiuJiaNan <15703339975@163.com> Date: Thu, 27 Aug 2026 08:55:27 +0800 Subject: [PATCH] =?UTF-8?q?feat(preview):=20=E5=A2=9E=E5=8A=A0=E5=BC=B9?= =?UTF-8?q?=E7=AA=97=E5=BA=95=E9=83=A8=E9=A2=9D=E5=A4=96=E6=8C=89=E9=92=AE?= =?UTF-8?q?=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 三个预览组件(Excel、Pdf、Word)添加了extraButtons属性 - extraButtons支持传入自定义React节点,扩展弹窗底部操作按钮 - 类型定义中将style属性改为CSSProperties以增强类型安全 - 弹窗中渲染extraButtons内容,增强功能拓展性 --- src/components/Excel/index.d.ts | 8 +++++--- src/components/Excel/index.js | 2 ++ src/components/Pdf/index.d.ts | 4 +++- src/components/Pdf/index.js | 2 ++ src/components/Word/index.d.ts | 8 +++++--- src/components/Word/index.js | 2 ++ 6 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/components/Excel/index.d.ts b/src/components/Excel/index.d.ts index cbf0ba7..d571263 100644 --- a/src/components/Excel/index.d.ts +++ b/src/components/Excel/index.d.ts @@ -1,4 +1,4 @@ -import type { FC } from "react"; +import type { CSSProperties, FC, ReactNode } from "react"; export interface ExcelProps { /** 是否显示弹窗 */ @@ -13,8 +13,10 @@ export interface ExcelProps { inline?: boolean; /** 弹窗标题 */ title?: string; - /** 内容样式 */ - style?: Record; + /** 内联模式下的样式 */ + style?: CSSProperties; + /** 弹窗底部额外的按钮 */ + extraButtons?: ReactNode; } declare const Excel: FC; diff --git a/src/components/Excel/index.js b/src/components/Excel/index.js index 8a76d52..9efaf80 100644 --- a/src/components/Excel/index.js +++ b/src/components/Excel/index.js @@ -19,6 +19,7 @@ function Excel(props) { inline = false, title = "Excel预览", style = {}, + extraButtons, } = props; const containerRef = useRef(null); @@ -121,6 +122,7 @@ function Excel(props) { 关闭 , , + ...(extraButtons || []), ]} > {renderExcelContent()} diff --git a/src/components/Pdf/index.d.ts b/src/components/Pdf/index.d.ts index ac549ac..cb8cc2c 100644 --- a/src/components/Pdf/index.d.ts +++ b/src/components/Pdf/index.d.ts @@ -1,4 +1,4 @@ -import type { CSSProperties, FC } from "react"; +import type { CSSProperties, FC, ReactNode } from "react"; export interface PdfProps { /** pdf 文件地址 */ @@ -15,6 +15,8 @@ export interface PdfProps { inline?: boolean; /** 内联模式下的样式 */ style?: CSSProperties; + /** 弹窗底部额外的按钮 */ + extraButtons?: ReactNode; } declare const Pdf: FC; diff --git a/src/components/Pdf/index.js b/src/components/Pdf/index.js index c6defba..8d987f4 100644 --- a/src/components/Pdf/index.js +++ b/src/components/Pdf/index.js @@ -20,6 +20,7 @@ function Pdf(props) { inline = false, title = "PDF预览", style = {}, + extraButtons, } = props; const fileUrl = getFileUrl(); @@ -117,6 +118,7 @@ function Pdf(props) { {isFullscreen ? "退出全屏" : "全屏"} , , + ...(extraButtons || []), ]} > {renderPdfContent()} diff --git a/src/components/Word/index.d.ts b/src/components/Word/index.d.ts index 008ed4e..4612518 100644 --- a/src/components/Word/index.d.ts +++ b/src/components/Word/index.d.ts @@ -1,4 +1,4 @@ -import type { FC } from "react"; +import type { CSSProperties, FC, ReactNode } from "react"; export interface WordProps { /** 是否显示弹窗 */ @@ -13,8 +13,10 @@ export interface WordProps { inline?: boolean; /** 弹窗标题 */ title?: string; - /** 内容样式 */ - style?: Record; + /** 内联模式下的样式 */ + style?: CSSProperties; + /** 弹窗底部额外的按钮 */ + extraButtons?: ReactNode; } declare const Word: FC; diff --git a/src/components/Word/index.js b/src/components/Word/index.js index ef85414..033b52c 100644 --- a/src/components/Word/index.js +++ b/src/components/Word/index.js @@ -16,6 +16,7 @@ function Word(props) { inline = false, title = "Word预览", style = {}, + extraButtons, } = props; const contentRef = useRef(null); @@ -114,6 +115,7 @@ function Word(props) { 关闭 , , + ...(extraButtons || []), ]} > {renderWordContent()}