From d3de0a6fff9ea94ab3c7f5b49cad56dad5d3c0b7 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 22 九月 2022 17:36:24 +0800 Subject: [PATCH] 2022-09-22 --- src/tabviews/zshare/fileupload/index.jsx | 14 +++++++++++++- 1 files changed, 13 insertions(+), 1 deletions(-) diff --git a/src/tabviews/zshare/fileupload/index.jsx b/src/tabviews/zshare/fileupload/index.jsx index 54d9727..cb0be7b 100644 --- a/src/tabviews/zshare/fileupload/index.jsx +++ b/src/tabviews/zshare/fileupload/index.jsx @@ -24,6 +24,7 @@ compress: 'false', fileType: 'text', showprogress: false, + maxSize: 0, filelist: [] } @@ -89,6 +90,7 @@ filelist, compress, limit: config.limit || 2, + maxSize: config.maxSize || 0, maxFile: maxFile, fileType: config.fileType || 'text' }) @@ -218,7 +220,7 @@ } beforeUpload = (file) => { - const { accepts, compress, limit, rduri } = this.state + const { accepts, compress, limit, rduri, maxSize } = this.state if (accepts && file.name) { let pass = false @@ -235,6 +237,16 @@ return false } } + if (maxSize) { + let fileSize = file.size / 1024 / 1024 + + if (fileSize > maxSize) { + setTimeout(() => { + this.onFail(`鏂囦欢澶у皬涓嶅彲瓒呰繃${maxSize}M`) + }, 10) + return false + } + } this.setState({ showprogress: true, -- Gitblit v1.8.0