From 33a7e55a716f7ea47f7ccbec1d70998fcea9e6aa Mon Sep 17 00:00:00 2001 From: masicheng <297876926@qq.com> Date: Thu, 27 Apr 2023 15:46:42 +0800 Subject: [PATCH] fix(Uploader): replace wx.chooseImage with wx.chooseMedia --- packages/uploader/utils.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/uploader/utils.ts b/packages/uploader/utils.ts index c4a2678e..2eef8269 100644 --- a/packages/uploader/utils.ts +++ b/packages/uploader/utils.ts @@ -45,13 +45,13 @@ export function isVideoFile(item: File): boolean { } function formatImage( - res: WechatMiniprogram.ChooseImageSuccessCallbackResult + res: WechatMiniprogram.ChooseMediaSuccessCallbackResult ): File[] { return res.tempFiles.map((item) => ({ ...pickExclude(item, ['path']), type: 'image', - url: item.path, - thumb: item.path, + url: item.tempFilePath, + thumb: item.tempFilePath, })); } @@ -101,10 +101,13 @@ export function chooseFile({ return new Promise((resolve, reject) => { switch (accept) { case 'image': - wx.chooseImage({ + wx.chooseMedia({ count: multiple ? Math.min(maxCount, 9) : 1, + mediaType: ['image'], sourceType: capture, + maxDuration, sizeType, + camera, success: (res) => resolve(formatImage(res)), fail: reject, });