修复编辑状态,file无法下载的问题 (#1792)

This commit is contained in:
RickCole 2021-04-13 15:00:43 +08:00 committed by GitHub
parent 13137dd8ad
commit 80df81a631
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -312,12 +312,14 @@ export default class FileControl extends React.Component<FileProps, FileState> {
? find(files, item => (item as FileValue).value === value)
: undefined;
const valueField = props.valueField || 'value';
const urlField = props.urlField || 'url';
const nameField = props.nameField || 'name';
return value
? value instanceof File
? {
state: 'ready',
[valueField]: value,
[urlField]: value,
[nameField]: value.name,
id: guid()
}
@ -326,6 +328,7 @@ export default class FileControl extends React.Component<FileProps, FileState> {
? {
state: file && file.state ? file.state : 'init',
[valueField]: value,
[urlField]: value,
[nameField]:
(file && file.name) ||
(/^data:/.test(value)