!1782 优化:添加贴图时,提示超过20MB的图片,并不添加该图片

pull/1824/head
黄诗津 3 years ago committed by ChenX
parent 243de27a85
commit bd0bc02bb3

@ -43,13 +43,20 @@ export class UploadComponent extends React.Component<IUploadProps, {}> {
{
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<void>
@ -103,7 +110,10 @@ export class UploadComponent extends React.Component<IUploadProps, {}> {
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<IUploadProps, {}> {
<div className={Classes.DIALOG_FOOTER_ACTIONS}>
<div>
{this.filesUrls.length},{FixedNotZero(this.imgSizes / 1024 / 1024, 1)}MB
</div>
</div>
<div>
<Button
text="中断添加"

Loading…
Cancel
Save