Skip to content

Commit

Permalink
fix(theme): upload component cannot preview images after exportToStri…
Browse files Browse the repository at this point in the history
…ng is enabled (#197)
  • Loading branch information
mengshang918 authored Apr 26, 2022
1 parent 2078d0f commit a02a78a
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions packages/drip-form-theme-antd/src/UploaderField/newUpload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: jiangxiaowei
* @Date: 2022-01-10 17:11:29
* @Last Modified by: jiangxiaowei
* @Last Modified time: 2022-01-28 18:20:14
* @Last Modified time: 2022-04-26 09:53:59
*/

import React, { memo, FC, useMemo, useCallback } from 'react'
Expand Down Expand Up @@ -107,7 +107,7 @@ const UploaderField: FC<UploaderFieldProps> = ({
...restProps
}) => {
// 如果是string类型,则需要处理为对象形式
const newFieldData = useMemo(() => {
const newFieldData = useMemo<Array<UploadFile>>(() => {
if (exportToString && typeof fieldData === 'string') {
return [
{
Expand All @@ -118,8 +118,18 @@ const UploaderField: FC<UploaderFieldProps> = ({
url: fieldData,
},
]
} else if (Array.isArray(fieldData)) {
return fieldData.map((item) => {
return {
name: '',
percent: 100,
status: 'done',
uid: '',
url: item,
}
})
} else {
return fieldData || []
return []
}
}, [exportToString, fieldData])

Expand Down

0 comments on commit a02a78a

Please sign in to comment.