You've already forked DataMate
feat(file-preview): 增加PDF文件预览功能并优化预览逻辑
- 引入统一的文件预览工具函数和类型定义 - 添加PDF文件类型的识别和预览支持 - 使用iframe实现PDF文件在线预览 - 重构文件预览逻辑,统一处理不同文件类型的预览 - 优化文本内容预览的长度截取机制 - 更新预览按钮加载状态显示 - 统一预览窗口的最大高度配置 - 修改API调用路径为专门的预览接口
This commit is contained in:
@@ -330,13 +330,21 @@ export default function Overview({
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex">
|
||||
<Button
|
||||
size="small"
|
||||
type="link"
|
||||
onClick={() => handleDownloadFile(record)}
|
||||
>
|
||||
return (
|
||||
<div className="flex">
|
||||
<Button
|
||||
size="small"
|
||||
type="link"
|
||||
loading={previewLoading && previewFileName === record.fileName}
|
||||
onClick={() => handlePreviewFile(record)}
|
||||
>
|
||||
预览
|
||||
</Button>
|
||||
<Button
|
||||
size="small"
|
||||
type="link"
|
||||
onClick={() => handleDownloadFile(record)}
|
||||
>
|
||||
下载
|
||||
</Button>
|
||||
<Button
|
||||
@@ -549,6 +557,13 @@ export default function Overview({
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
{previewFileType === "pdf" && (
|
||||
<iframe
|
||||
src={previewMediaUrl}
|
||||
title={previewFileName || "PDF 预览"}
|
||||
style={{ width: "100%", height: `${PREVIEW_MAX_HEIGHT}px`, border: "none" }}
|
||||
/>
|
||||
)}
|
||||
{previewFileType === "video" && (
|
||||
<div style={{ textAlign: "center" }}>
|
||||
<video
|
||||
|
||||
Reference in New Issue
Block a user