From bd0bc02bb3cc1615cd22a0abb255ed9cdb20f381 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E8=AF=97=E6=B4=A5?= <2723065175@qq.com> Date: Fri, 18 Feb 2022 05:58:28 +0000 Subject: [PATCH] =?UTF-8?q?!1782=20=E4=BC=98=E5=8C=96:=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E8=B4=B4=E5=9B=BE=E6=97=B6,=E6=8F=90=E7=A4=BA=E8=B6=85?= =?UTF-8?q?=E8=BF=8720MB=E7=9A=84=E5=9B=BE=E7=89=87,=E5=B9=B6=E4=B8=8D?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=AF=A5=E5=9B=BE=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/UI/Components/SourceManage/UploadCom.tsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/UI/Components/SourceManage/UploadCom.tsx b/src/UI/Components/SourceManage/UploadCom.tsx index cfcec5d5e..30f3c126b 100644 --- a/src/UI/Components/SourceManage/UploadCom.tsx +++ b/src/UI/Components/SourceManage/UploadCom.tsx @@ -43,13 +43,20 @@ export class UploadComponent extends React.Component { { if (this.isEndUpload) break; + if (file.size / 1024 / 1024 > 20) + { + let name = file.name.slice(0, file.name.lastIndexOf(".")); + alert("图片 " + name + " 大小超过20MB,无法上传"); + this.uploadInput.value = ""; + continue; + } this.files.push(file); this.imgSizes += file.size; this.fileReader.readAsDataURL(file); await this.Wait(); this.processValue = this.processValue + step; } - this.processValue = files.length > 0 ? 1.1 : -1; + this.processValue = this.files.length > 0 ? 1.1 : -1; }; private Wait(): Promise @@ -103,7 +110,10 @@ export class UploadComponent extends React.Component { private handleDelete = (i: number) => { this.filesUrls.splice(i, 1); + this.imgSizes -= (this.files[i] as File).size; this.files.splice(i, 1); + if (this.files.length === 0) + this.processValue = -1; this.uploadInput.value = ""; }; private handleClose = () => @@ -206,7 +216,7 @@ export class UploadComponent extends React.Component {
共{this.filesUrls.length}张图片,大小{FixedNotZero(this.imgSizes / 1024 / 1024, 1)}MB -
+