Browse Source
fix: requestClient.upload会将vbenform中value为undefined的值转为字符串undefined’提… (#6300)
* fix: requestClient.upload会将vbenform中value为undefined的值转为字符串undefined’提交给后台保存
* fix: requestClient.upload会将vbenform中value为undefined的值转为字符串'undefined’提交给后台保存
pull/5500/head
zhang
1 year ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with
4 additions and
2 deletions
-
packages/effects/request/src/request-client/modules/uploader.ts
|
|
@ -1,6 +1,8 @@ |
|
|
import type { RequestClient } from '../request-client'; |
|
|
import type { RequestClient } from '../request-client'; |
|
|
import type { RequestClientConfig } from '../types'; |
|
|
import type { RequestClientConfig } from '../types'; |
|
|
|
|
|
|
|
|
|
|
|
import { isUndefined } from '@vben/utils'; |
|
|
|
|
|
|
|
|
class FileUploader { |
|
|
class FileUploader { |
|
|
private client: RequestClient; |
|
|
private client: RequestClient; |
|
|
|
|
|
|
|
|
@ -18,10 +20,10 @@ class FileUploader { |
|
|
Object.entries(data).forEach(([key, value]) => { |
|
|
Object.entries(data).forEach(([key, value]) => { |
|
|
if (Array.isArray(value)) { |
|
|
if (Array.isArray(value)) { |
|
|
value.forEach((item, index) => { |
|
|
value.forEach((item, index) => { |
|
|
formData.append(`${key}[${index}]`, item); |
|
|
!isUndefined(item) && formData.append(`${key}[${index}]`, item); |
|
|
}); |
|
|
}); |
|
|
} else { |
|
|
} else { |
|
|
formData.append(key, value); |
|
|
!isUndefined(value) && formData.append(key, value); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|