From 80c68b8e497593fa18d1b1f6b42dbe57481a55a7 Mon Sep 17 00:00:00 2001 From: zhengkunwang <31820853+zhengkunwang223@users.noreply.github.com> Date: Mon, 13 Nov 2023 16:52:08 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E9=83=A8=E5=88=86?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=B8=8D=E8=83=BD=E4=B8=8A=E4=BC=A0=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=20(#2933)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../host/file-management/upload/index.vue | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/frontend/src/views/host/file-management/upload/index.vue b/frontend/src/views/host/file-management/upload/index.vue index b2e9a4fe4..6390d3157 100644 --- a/frontend/src/views/host/file-management/upload/index.vue +++ b/frontend/src/views/host/file-management/upload/index.vue @@ -127,14 +127,18 @@ const removeFile = (index: number) => { }; const fileOnChange = (_uploadFile: UploadFile, uploadFiles: UploadFiles) => { - uploaderFiles.value = uploadFiles; - const reader = new FileReader(); - reader.readAsDataURL(_uploadFile.raw); - reader.onload = async () => {}; - reader.onerror = () => { - uploaderFiles.value = uploaderFiles.value.filter((file) => file.uid !== _uploadFile.uid); - MsgError(i18n.global.t('file.typeErrOrEmpty', [_uploadFile.name])); - }; + if (_uploadFile.size == 64 || _uploadFile.size == 0) { + uploaderFiles.value = uploadFiles; + const reader = new FileReader(); + reader.readAsDataURL(_uploadFile.raw); + reader.onload = async () => {}; + reader.onerror = () => { + uploaderFiles.value = uploaderFiles.value.filter((file) => file.uid !== _uploadFile.uid); + MsgError(i18n.global.t('file.typeErrOrEmpty', [_uploadFile.name])); + }; + } else { + uploaderFiles.value = uploadFiles; + } }; const clearFiles = () => { @@ -162,7 +166,7 @@ const submit = async () => { const fileSize = file.size; uploadHelper.value = i18n.global.t('file.fileUploadStart', [file.name]); - if (fileSize <= 1024 * 1024 * 50) { + if (fileSize <= 1024 * 1024 * 10) { const formData = new FormData(); formData.append('file', file.raw); if (file.raw.webkitRelativePath != '') { @@ -174,7 +178,7 @@ const submit = async () => { success++; uploaderFiles.value[i].status = 'success'; } else { - const CHUNK_SIZE = 1024 * 1024 * 20; // 10MB + const CHUNK_SIZE = 1024 * 1024 * 10; const chunkCount = Math.ceil(fileSize / CHUNK_SIZE); let uploadedChunkCount = 0; for (let c = 0; c < chunkCount; c++) {