feat(preview): 增加弹窗底部额外按钮支持
- 三个预览组件(Excel、Pdf、Word)添加了extraButtons属性 - extraButtons支持传入自定义React节点,扩展弹窗底部操作按钮 - 类型定义中将style属性改为CSSProperties以增强类型安全 - 弹窗中渲染extraButtons内容,增强功能拓展性2.0
parent
ef2ab172c8
commit
69692d89a5
|
|
@ -1,4 +1,4 @@
|
||||||
import type { FC } from "react";
|
import type { CSSProperties, FC, ReactNode } from "react";
|
||||||
|
|
||||||
export interface ExcelProps {
|
export interface ExcelProps {
|
||||||
/** 是否显示弹窗 */
|
/** 是否显示弹窗 */
|
||||||
|
|
@ -13,8 +13,10 @@ export interface ExcelProps {
|
||||||
inline?: boolean;
|
inline?: boolean;
|
||||||
/** 弹窗标题 */
|
/** 弹窗标题 */
|
||||||
title?: string;
|
title?: string;
|
||||||
/** 内容样式 */
|
/** 内联模式下的样式 */
|
||||||
style?: Record<string, any>;
|
style?: CSSProperties;
|
||||||
|
/** 弹窗底部额外的按钮 */
|
||||||
|
extraButtons?: ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
declare const Excel: FC<ExcelProps>;
|
declare const Excel: FC<ExcelProps>;
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ function Excel(props) {
|
||||||
inline = false,
|
inline = false,
|
||||||
title = "Excel预览",
|
title = "Excel预览",
|
||||||
style = {},
|
style = {},
|
||||||
|
extraButtons,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
const containerRef = useRef(null);
|
const containerRef = useRef(null);
|
||||||
|
|
@ -121,6 +122,7 @@ function Excel(props) {
|
||||||
关闭
|
关闭
|
||||||
</Button>,
|
</Button>,
|
||||||
<Button key="download" type="primary" onClick={onDownloadFile}>下载</Button>,
|
<Button key="download" type="primary" onClick={onDownloadFile}>下载</Button>,
|
||||||
|
...(extraButtons || []),
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
{renderExcelContent()}
|
{renderExcelContent()}
|
||||||
|
|
|
||||||
|
|
@ -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()}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import type { FC } from "react";
|
import type { CSSProperties, FC, ReactNode } from "react";
|
||||||
|
|
||||||
export interface WordProps {
|
export interface WordProps {
|
||||||
/** 是否显示弹窗 */
|
/** 是否显示弹窗 */
|
||||||
|
|
@ -13,8 +13,10 @@ export interface WordProps {
|
||||||
inline?: boolean;
|
inline?: boolean;
|
||||||
/** 弹窗标题 */
|
/** 弹窗标题 */
|
||||||
title?: string;
|
title?: string;
|
||||||
/** 内容样式 */
|
/** 内联模式下的样式 */
|
||||||
style?: Record<string, any>;
|
style?: CSSProperties;
|
||||||
|
/** 弹窗底部额外的按钮 */
|
||||||
|
extraButtons?: ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
declare const Word: FC<WordProps>;
|
declare const Word: FC<WordProps>;
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ function Word(props) {
|
||||||
inline = false,
|
inline = false,
|
||||||
title = "Word预览",
|
title = "Word预览",
|
||||||
style = {},
|
style = {},
|
||||||
|
extraButtons,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
const contentRef = useRef(null);
|
const contentRef = useRef(null);
|
||||||
|
|
@ -114,6 +115,7 @@ function Word(props) {
|
||||||
关闭
|
关闭
|
||||||
</Button>,
|
</Button>,
|
||||||
<Button key="download" type="primary" onClick={onDownloadFile}>下载</Button>,
|
<Button key="download" type="primary" onClick={onDownloadFile}>下载</Button>,
|
||||||
|
...(extraButtons || []),
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
{renderWordContent()}
|
{renderWordContent()}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue