From b1e7bdcd90366d448485caf4ed20bbc2ac6a761e Mon Sep 17 00:00:00 2001 From: From-wh Date: Sun, 25 Jun 2023 18:26:33 +0800 Subject: [PATCH] =?UTF-8?q?improve:=20=E5=9B=BE=E7=89=87=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E5=A4=A7=E5=B0=8F=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- template/admin/src/pages/app/upload/index.vue | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/template/admin/src/pages/app/upload/index.vue b/template/admin/src/pages/app/upload/index.vue index fbee4de99..091f2edb1 100644 --- a/template/admin/src/pages/app/upload/index.vue +++ b/template/admin/src/pages/app/upload/index.vue @@ -77,9 +77,13 @@ export default { }); this.imgList.splice(index, 1); this.$nextTick((e) => { - this.imgList.map((e) => { - this.allSize += e.raw.size; - }); + if (this.imgList.length) { + this.imgList.map((e) => { + this.allSize += e.raw.size; + }); + } else { + this.allSize = 0; + } }); }, @@ -118,14 +122,20 @@ export default { return new Blob([u8arr], { type: mime }); }, fileChange(file, fileList) { - compressImg(file.raw).then((res) => { - if (fileList.length) fileList[fileList.length - 1].raw = res; + if (file.size >= 2097152) { + compressImg(file.raw).then((res) => { + if (fileList.length) fileList[fileList.length - 1].raw = res; + this.imgList = fileList; + this.imgList.map((e) => { + this.allSize += e.raw.size; + }); + }); + } else { this.imgList = fileList; this.imgList.map((e) => { - console.log(e); this.allSize += e.raw.size; }); - }); + } }, loadData(item, callback) { getCategoryListApi({ @@ -167,7 +177,7 @@ export default { font-size: 18px; right: 1px; top: 1px; - color: red; + color: #999; } .img-box { display: flex;