From dc52a4ddcd06e6d6444bc082549508f5fd4df74a Mon Sep 17 00:00:00 2001 From: helang Date: Sun, 18 Jun 2023 13:26:05 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix(=E5=9B=BE=E7=89=87=E5=8E=8B=E7=BC=A9):?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E5=A4=84=E7=90=86+=E9=87=8D=E5=A4=8DID?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../helang-compress/helang-compress.vue | 32 ++++++++++++------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/uniapp-extend/components/helang-compress/helang-compress.vue b/uniapp-extend/components/helang-compress/helang-compress.vue index 77fbd58..474d105 100644 --- a/uniapp-extend/components/helang-compress/helang-compress.vue +++ b/uniapp-extend/components/helang-compress/helang-compress.vue @@ -1,6 +1,6 @@ @@ -12,8 +12,17 @@ canvasSize: { width: 0, height: 0 - } + }, + canvasId:"" + } + }, + mounted() { + if(!uni || !uni._helang_compress_canvas){ + uni._helang_compress_canvas = 1; + }else{ + uni._helang_compress_canvas++; } + this.canvasId = `compress-canvas${uni._helang_compress_canvas}`; }, methods: { // 压缩 @@ -62,7 +71,7 @@ // Vue.nextTick 回调在 App 有异常,则使用 setTimeout 等待DOM更新 setTimeout(() => { - const ctx = uni.createCanvasContext('compress-canvas', this); + const ctx = uni.createCanvasContext(this.canvasId, this); ctx.clearRect(0,0,width, height) ctx.drawImage(info.path, 0, 0, width, height); ctx.draw(false, () => { @@ -73,7 +82,7 @@ height: height, destWidth: width, destHeight: height, - canvasId: 'compress-canvas', + canvasId: this.canvasId, fileType: params.fileType || 'png', quality: params.quality || 0.9, success: (res) => { @@ -120,13 +129,8 @@ return new Promise((resolve, reject)=>{ // 开始 let start = async ()=>{ - params.progress && params.progress({ - done, - fail, - count:waitList.length - }); // 等待图片压缩方法返回 - let path = await next(); + let path = await next().catch(()=>null); if(path){ done++; paths.push(path); @@ -134,6 +138,12 @@ fail++; } + params.progress && params.progress({ + done, + fail, + count:waitList.length + }); + index++; // 压缩完成 if(index >= waitList.length){ -- Gitee From b30d1b5a7cddc5d9c7b93fa1276bd5aee6c6de07 Mon Sep 17 00:00:00 2001 From: helang Date: Sun, 18 Jun 2023 13:29:29 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix(=E8=AF=B4=E6=98=8E=E6=96=87=E6=A1=A3):V?= =?UTF-8?q?ue=E7=89=88=E6=9C=AC=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 510d7d1..0defb3b 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,12 @@ ### H5版在线体验 ![H5版在线体验二维码](https://mydarling.gitee.io/uniapp-extend/static/qrcode_h5.png "H5版在线体验二维码") +#### Vue版本兼容 + +Vue2 | Vue3 +-- | -- +√ | 未测试 + #### 安装 * 下载项目 导入 HBuilderX 即可运行体验 -- Gitee