fix: Form开启trimValues时会将File字段错误转换问题 (#5162)

This commit is contained in:
RUNZE LU 2022-08-17 17:05:31 +08:00 committed by GitHub
parent 8ca2a10b4a
commit f93d002c28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1350,10 +1350,32 @@ export function chainEvents(props: any, schema: any) {
return ret;
}
export function mapObject(value: any, fn: Function): any {
export function mapObject(
value: any,
fn: Function,
skipFn?: (value: any) => boolean
): any {
// 如果value值满足skipFn条件则不做map操作
skipFn =
skipFn && typeof skipFn === 'function'
? skipFn
: (value: any): boolean => {
// File类型处理之后会变成plain object
if (value instanceof File) {
return true;
}
return false;
};
if (!!skipFn(value)) {
return value;
}
if (Array.isArray(value)) {
return value.map(item => mapObject(item, fn));
}
if (isObject(value)) {
let tmpValue = {...value};
Object.keys(tmpValue).forEach(key => {