From 9cfb6e972c4f0deceabf98d686dd524e82e42cd4 Mon Sep 17 00:00:00 2001 From: "Alex.hxy" <1872591453@qq.com> Date: Mon, 30 Dec 2024 16:37:48 +0800 Subject: [PATCH] feat(uploader): suppport chooseMedia in web (#2902) * feat: suppport chooseMedia in web * feat: suppport chooseMedia in web --- src/packages/uploader/doc.taro.md | 6 +++--- src/packages/uploader/uploader.taro.tsx | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/packages/uploader/doc.taro.md b/src/packages/uploader/doc.taro.md index 70a118afb2..e81a597d50 100644 --- a/src/packages/uploader/doc.taro.md +++ b/src/packages/uploader/doc.taro.md @@ -156,10 +156,10 @@ app.post('/upload', upload.single('file'), (req, res) => { | maxCount | 文件上传数量限制 | `number` \| `string` | `1` | | fit | 图片填充模式 | `contain` \| `cover` \| `fill` \| `none` \| `scale-down` | `cover` | | sourceType | [选择文件的来源]("https://developers.weixin.qq.com/miniprogram/dev/api/media/video/wx.chooseMedia.html") | `Array` | `['album','camera']` | -| camera`仅支持WEAPP` | 仅在 `source-type` 为 `camera` 时生效,使用前置或后置摄像头 | `String` | `back` | +| camera | 仅在 `source-type` 为 `camera` 时生效,使用前置或后置摄像头 | `String` | `back` | | sizeType | [是否压缩所选文件]("https://developers.weixin.qq.com/miniprogram/dev/api/media/video/wx.chooseMedia.html") | `Array` | `['original','compressed']` | -| mediaType`仅支持WEAPP` | [选择文件类型]("https://developers.weixin.qq.com/miniprogram/dev/api/media/video/wx.chooseMedia.html") | `Array` | `['image', 'video', 'mix']` | -| maxDuration`仅支持WEAPP` | 拍摄视频最长拍摄时间,单位秒。时间范围为 3s 至 60s 之间。不限制相册。 | `number` | `10` | +| mediaType | [选择文件类型]("https://developers.weixin.qq.com/miniprogram/dev/api/media/video/wx.chooseMedia.html") | `Array` | `['image', 'video', 'mix']` | +| maxDuration | 拍摄视频最长拍摄时间,单位秒。时间范围为 3s 至 60s 之间。不限制相册。 | `number` | `10` | | headers | 设置上传的请求头部 | `object` | `{}` | | data | 附加上传的信息 formData | `object` | `{}` | | uploadIcon | 上传区域图标名称 | `ReactNode` | `-` | diff --git a/src/packages/uploader/uploader.taro.tsx b/src/packages/uploader/uploader.taro.tsx index 36630813c3..9d8413a864 100644 --- a/src/packages/uploader/uploader.taro.tsx +++ b/src/packages/uploader/uploader.taro.tsx @@ -260,7 +260,7 @@ const InternalUploader: ForwardRefRenderFunction< document.body.appendChild(obj) } } - if ((getEnv() === 'WEAPP' || getEnv() === 'JD') && chooseMedia) { + if (['WEAPP', 'JD', 'WEB'].includes(getEnv()) && chooseMedia) { // 其余端全部使用 chooseImage API chooseMedia({ count: multiple ? (maxCount as number) * 1 - fileList.length : 1,