From 2e7a456fee5abc3f0c48c03d14b392dbd2a75018 Mon Sep 17 00:00:00 2001 From: xsx <825657193@qq.com> Date: Sun, 23 Jun 2024 23:13:50 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=8B=8D=E7=85=A7=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/bx/implatform/contant/Constant.java | 4 ++-- .../service/thirdparty/FileService.java | 4 ++-- .../components/image-upload/image-upload.vue | 23 ++++--------------- 3 files changed, 9 insertions(+), 22 deletions(-) diff --git a/im-platform/src/main/java/com/bx/implatform/contant/Constant.java b/im-platform/src/main/java/com/bx/implatform/contant/Constant.java index af18830..6d23dfc 100644 --- a/im-platform/src/main/java/com/bx/implatform/contant/Constant.java +++ b/im-platform/src/main/java/com/bx/implatform/contant/Constant.java @@ -8,11 +8,11 @@ public final class Constant { /** * 最大图片上传大小 */ - public static final long MAX_IMAGE_SIZE = 5 * 1024 * 1024; + public static final long MAX_IMAGE_SIZE = 20 * 1024 * 1024; /** * 最大上传文件大小 */ - public static final long MAX_FILE_SIZE = 10 * 1024 * 1024; + public static final long MAX_FILE_SIZE = 20 * 1024 * 1024; /** * 群聊最大人数 */ diff --git a/im-platform/src/main/java/com/bx/implatform/service/thirdparty/FileService.java b/im-platform/src/main/java/com/bx/implatform/service/thirdparty/FileService.java index 91935d9..b727425 100644 --- a/im-platform/src/main/java/com/bx/implatform/service/thirdparty/FileService.java +++ b/im-platform/src/main/java/com/bx/implatform/service/thirdparty/FileService.java @@ -59,7 +59,7 @@ public class FileService { Long userId = SessionContext.getSession().getUserId(); // 大小校验 if (file.getSize() > Constant.MAX_FILE_SIZE) { - throw new GlobalException(ResultCode.PROGRAM_ERROR, "文件大小不能超过10M"); + throw new GlobalException(ResultCode.PROGRAM_ERROR, "文件大小不能超过20M"); } // 上传 String fileName = minioUtil.upload(bucketName, filePath, file); @@ -76,7 +76,7 @@ public class FileService { Long userId = SessionContext.getSession().getUserId(); // 大小校验 if (file.getSize() > Constant.MAX_IMAGE_SIZE) { - throw new GlobalException(ResultCode.PROGRAM_ERROR, "图片大小不能超过5M"); + throw new GlobalException(ResultCode.PROGRAM_ERROR, "图片大小不能超过20M"); } // 图片格式校验 if (!FileUtil.isImage(file.getOriginalFilename())) { diff --git a/im-uniapp/components/image-upload/image-upload.vue b/im-uniapp/components/image-upload/image-upload.vue index 09e41a9..de625c3 100644 --- a/im-uniapp/components/image-upload/image-upload.vue +++ b/im-uniapp/components/image-upload/image-upload.vue @@ -50,13 +50,7 @@ sizeType: ['original'], //original 原图,compressed 压缩图,默认二者都有 success: (res) => { res.tempFiles.forEach((file) => { - // 校验大小 - if (this.maxSize && file.size > this.maxSize) { - this.$message.error(`文件大小不能超过 ${this.fileSizeStr}!`); - this.$emit("fail", file); - return; - } - + console.log("文件:",file) if (!this.onBefore || this.onBefore(file)) { // 调用上传图片的接口 this.uploadImage(file); @@ -76,6 +70,10 @@ success: (res) => { let data = JSON.parse(res.data); if(data.code != 200){ + uni.showToast({ + icon: "none", + title: data.message, + }) this.onError && this.onError(file, data); }else{ this.onSuccess && this.onSuccess(file, data); @@ -87,17 +85,6 @@ } }) } - }, - computed: { - fileSizeStr() { - if (this.maxSize > 1024 * 1024) { - return Math.round(this.maxSize / 1024 / 1024) + "M"; - } - if (this.maxSize > 1024) { - return Math.round(this.maxSize / 1024) + "KB"; - } - return this.maxSize + "B"; - } } }