Skip to content

Commit

Permalink
feat(uploader): 支持all
Browse files Browse the repository at this point in the history
  • Loading branch information
shuTwT committed Mar 2, 2024
1 parent 1632faf commit 585ecfb
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/components/dentry/uploader.md
Expand Up @@ -243,6 +243,7 @@ setup() {
| size-type | [是否压缩所选文件](https://developers.weixin.qq.com/miniprogram/dev/api/media/video/wx.chooseMedia.html) | Array | `['original','compressed']` |
| media-type`仅支持WEAPP` | [选择文件类型](https://developers.weixin.qq.com/miniprogram/dev/api/media/video/wx.chooseMedia.html) | Array | `['image', 'video', 'mix']` |
| max-duration`仅支持WEAPP` | 拍摄视频最长拍摄时间,单位秒。时间范围为 3s 至 60s 之间。不限制相册。 | Number | 10 |
| accept | 允许上传的文件类型 |String | `['image','media','video','all']`
| headers | 设置上传的请求头部 | object | `{}` |
| data | 附加上传的信息 formData | object | `{}` |
| xhr-state | 接口响应的成功状态(status)值 | Number | `200` |
Expand Down
4 changes: 4 additions & 0 deletions example/src/pages/demo/dentry/uploader/index.vue
Expand Up @@ -194,6 +194,10 @@ function beforeXhrUpload(UploadFile: any, options: any) {
文件类型 - 视频
</h2>
<nut-uploader :url="uploadUrl" accept="video" />
<h2 class="title">
文件类型 - 全部
</h2>
<nut-uploader :url="uploadUrl" accept="all" />
</div>
</template>

Expand Down
14 changes: 14 additions & 0 deletions packages/nutui/components/uploader/use-uploader.ts
Expand Up @@ -176,6 +176,20 @@ export function chooseFile({
fail: reject,
})
}
else if (accept === 'all') {
uni.chooseFile({
type: 'all',
// 选择数量
count: props.multiple ? (props.maximum as number) * 1 - props.fileList.length : 1,
// 可以指定是原图还是压缩图,默认二者都有
sizeType,
sourceType: props.sourceType,
success: (res) => {
resolve(formatImage(res as UniChooseFileSuccessCallbackResult))
},
fail: reject,
})
}

// #endif
})
Expand Down

0 comments on commit 585ecfb

Please sign in to comment.