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 {
|
export interface PdfProps {
|
||||||
/** pdf 文件地址 */
|
/** pdf 文件地址 */
|
||||||
|
|
@ -15,6 +15,8 @@ export interface PdfProps {
|
||||||
inline?: boolean;
|
inline?: boolean;
|
||||||
/** 内联模式下的样式 */
|
/** 内联模式下的样式 */
|
||||||
style?: CSSProperties;
|
style?: CSSProperties;
|
||||||
|
/** 弹窗底部额外的按钮 */
|
||||||
|
extraButtons?: ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
declare const Pdf: FC<PdfProps>;
|
declare const Pdf: FC<PdfProps>;
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ function Pdf(props) {
|
||||||
inline = false,
|
inline = false,
|
||||||
title = "PDF预览",
|
title = "PDF预览",
|
||||||
style = {},
|
style = {},
|
||||||
|
extraButtons,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
const fileUrl = getFileUrl();
|
const fileUrl = getFileUrl();
|
||||||
|
|
@ -117,6 +118,7 @@ function Pdf(props) {
|
||||||
{isFullscreen ? "退出全屏" : "全屏"}
|
{isFullscreen ? "退出全屏" : "全屏"}
|
||||||
</Button>,
|
</Button>,
|
||||||
<Button key="download" type="primary" onClick={onDownloadFile}>下载</Button>,
|
<Button key="download" type="primary" onClick={onDownloadFile}>下载</Button>,
|
||||||
|
...(extraButtons || []),
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
{renderPdfContent()}
|
{renderPdfContent()}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue