Skip to content

Commit

Permalink
feat(Upload): add capture props
Browse files Browse the repository at this point in the history
  • Loading branch information
anlyyao committed Nov 19, 2024
1 parent e1e69d4 commit c4233c1
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 0 deletions.
Binary file modified db/TDesign.db
Binary file not shown.
5 changes: 5 additions & 0 deletions packages/products/tdesign-mobile-vue/src/upload/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ export default {
beforeUpload: {
type: Function as PropType<TdUploadProps['beforeUpload']>,
},
/** 图片选取模式,可选值为 camera (直接调起摄像头) */
capture: {
type: String,
default: '',
},
/** 上传请求所需的额外字段,默认字段有 `file`,表示文件信息。可以添加额外的文件名字段,如:`{file_name: "custom-file-name.txt"}`。`autoUpload=true` 时有效。也可以使用 `formatRequest` 完全自定义上传请求的字段 */
data: {
type: Object as PropType<TdUploadProps['data']>,
Expand Down
5 changes: 5 additions & 0 deletions packages/products/tdesign-mobile-vue/src/upload/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ export interface TdUploadProps<T extends UploadFile = UploadFile> {
* 如果是自动上传模式 `autoUpload=true`,表示单个文件上传之前的钩子函数,若函数返回值为 `false` 则表示不上传当前文件。<br/>如果是非自动上传模式 `autoUpload=false`,函数返回值为 `false` 时表示从上传文件中剔除当前文件
*/
beforeUpload?: (file: UploadFile) => boolean | Promise<boolean>;
/**
* 图片选取模式,可选值为 camera (直接调起摄像头)
* @default ''
*/
capture?: string;
/**
* 上传请求所需的额外字段,默认字段有 `file`,表示文件信息。可以添加额外的文件名字段,如:`{file_name: "custom-file-name.txt"}`。`autoUpload=true` 时有效。也可以使用 `formatRequest` 完全自定义上传请求的字段
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ addContent | String / Slot / Function | - | Typescript:`string \| TNode`。[se
allowUploadDuplicateFile | Boolean | false | allow to upload duplicate name files | N
autoUpload | Boolean | true | post upload request automatically after files being selected | N
beforeUpload | Function | - | stop one of files to upload。Typescript:`(file: UploadFile) => boolean \| Promise<boolean>` | N
capture | String | - | \- | N
data | Object | - | extra request data of uploading. `formatRequest` can redefine all request data。Typescript:`Record<string, any> \| ((files: UploadFile[]) => Record<string, any>)` | N
disabled | Boolean | undefined | make upload to be disabled | N
files | Array | [] | `v-model:files` is supported。Typescript:`Array<T>` | N
Expand Down
1 change: 1 addition & 0 deletions packages/products/tdesign-mobile-vue/src/upload/upload.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ addContent | String / Slot / Function | - | 添加按钮内容。值为空,使
allowUploadDuplicateFile | Boolean | false | 是否允许重复上传相同文件名的文件 | N
autoUpload | Boolean | true | 是否在选择文件后自动发起请求上传文件 | N
beforeUpload | Function | - | 如果是自动上传模式 `autoUpload=true`,表示单个文件上传之前的钩子函数,若函数返回值为 `false` 则表示不上传当前文件。<br/>如果是非自动上传模式 `autoUpload=false`,函数返回值为 `false` 时表示从上传文件中剔除当前文件。TS 类型:`(file: UploadFile) => boolean \| Promise<boolean>` | N
capture | String | - | 图片选取模式,可选值为 camera (直接调起摄像头) | N
data | Object | - | 上传请求所需的额外字段,默认字段有 `file`,表示文件信息。可以添加额外的文件名字段,如:`{file_name: "custom-file-name.txt"}``autoUpload=true` 时有效。也可以使用 `formatRequest` 完全自定义上传请求的字段。TS 类型:`Record<string, any> \| ((files: UploadFile[]) => Record<string, any>)` | N
disabled | Boolean | undefined | 是否禁用组件 | N
files | Array | [] | 已上传文件列表,同 `value`。TS 类型:`UploadFile`。支持语法糖 `v-model:files`。TS 类型:`Array<T>` | N
Expand Down
39 changes: 39 additions & 0 deletions packages/scripts/api.json
Original file line number Diff line number Diff line change
Expand Up @@ -135340,6 +135340,45 @@
"TNode"
]
},
{
"id": 1732004595,
"platform_framework": [
"8",
"16"
],
"component": "Upload",
"field_category": 1,
"field_name": "capture",
"field_type": [
"1"
],
"field_default_value": "",
"field_enum": "",
"field_desc_zh": "图片选取模式,可选值为 camera (直接调起摄像头)",
"field_desc_en": null,
"field_required": 0,
"event_input": "",
"create_time": "2024-11-19 08:23:15",
"update_time": "2024-11-19 08:23:15",
"event_output": null,
"custom_field_type": null,
"syntactic_sugar": null,
"readonly": 1,
"html_attribute": 0,
"trigger_elements": "",
"deprecated": 0,
"version": "",
"test_description": null,
"support_default_value": 0,
"field_category_text": "Props",
"platform_framework_text": [
"Vue(Mobile)",
"React(Mobile)"
],
"field_type_text": [
"String"
]
},
{
"id": 1169,
"platform_framework": [
Expand Down

0 comments on commit c4233c1

Please sign in to comment.