diff --git a/package.json b/package.json index fd3d775..4794be8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@kne/react-file", - "version": "0.1.25", + "version": "0.1.26", "description": "提供了文件上传,文件预览,文件批量管理等功能", "syntax": { "esmodules": true diff --git a/src/components/FilePreview/OSSFilePreview.js b/src/components/FilePreview/OSSFilePreview.js index 4262fd7..0831cf6 100644 --- a/src/components/FilePreview/OSSFilePreview.js +++ b/src/components/FilePreview/OSSFilePreview.js @@ -3,9 +3,21 @@ import withOSSFile from '../../hocs/withOSSFile'; import { typeFormatComponent } from './typeFormat'; import useStaticUrl from '../../common/useStaticUrl'; -const OSSFilePreview = withOSSFile(({ data, id, staticUrl: staticUrlProps, className, fetchApi, filename, ...props }) => { +const OSSFilePreview = withOSSFile(({ data, id, staticUrl: staticUrlProps, className, fetchApi, filename, render, ...props }) => { const fileUrl = useStaticUrl({ staticUrl: staticUrlProps, url: data }); const PreviewComponent = (data && typeFormatComponent(data)) || (filename && typeFormatComponent(filename)); + if (typeof render === 'function') { + return render({ + data, + id, + staticUrl: staticUrlProps, + className, + fetchApi, + filename, + url: fileUrl, + component: PreviewComponent + }); + } return ; });