feat(pdf): 支持弹窗底部自定义按钮
- 在 PdfProps 中添加 extraButtons 属性,用于传入自定义按钮内容 - 组件内新增对 extraButtons 的接收和渲染支持 - 弹窗底部按钮列表中合并渲染 extraButtons 内容实现扩展功能1.0
parent
fab9c9380d
commit
bc4df96c51
|
|
@ -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<PdfProps>;
|
||||
|
|
|
|||
|
|
@ -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 ? "退出全屏" : "全屏"}
|
||||
</Button>,
|
||||
<Button key="download" type="primary" onClick={onDownloadFile}>下载</Button>,
|
||||
...(extraButtons || []),
|
||||
]}
|
||||
>
|
||||
{renderPdfContent()}
|
||||
|
|
|
|||
Loading…
Reference in New Issue