Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kne/react-file",
"version": "0.1.25",
"version": "0.1.26",
"description": "提供了文件上传,文件预览,文件批量管理等功能",
"syntax": {
"esmodules": true
Expand Down
14 changes: 13 additions & 1 deletion src/components/FilePreview/OSSFilePreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <PreviewComponent {...props} className={className} url={fileUrl} />;
});

Expand Down