|
|
|
@ -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="中断添加"
|
|
|
|
|