From b472769132abc008937f9f58d498fec631b596dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9E=E4=BB=99=E9=83=BD=E6=B2=A1=E7=94=A8?= <615206459@qq.com> Date: Thu, 18 Jul 2024 16:53:41 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=20cl-upload=20=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E8=BF=9B=E5=BA=A6=E4=B8=A2=E5=A4=B1=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/upload/components/upload.vue | 4 ++++ src/plugins/upload/hooks/index.ts | 12 ++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/plugins/upload/components/upload.vue b/src/plugins/upload/components/upload.vue index f9f1b85..bf297b3 100644 --- a/src/plugins/upload/components/upload.vue +++ b/src/plugins/upload/components/upload.vue @@ -490,6 +490,10 @@ defineExpose({ &__file { width: 100%; + + &-btn { + width: fit-content; + } } &__list { diff --git a/src/plugins/upload/hooks/index.ts b/src/plugins/upload/hooks/index.ts index 1ddcd8c..0563e07 100644 --- a/src/plugins/upload/hooks/index.ts +++ b/src/plugins/upload/hooks/index.ts @@ -66,6 +66,9 @@ export function useUpload() { // 文件 fd.append("file", file); + // 上传进度 + let progress = 0; + // 上传 await service .request({ @@ -78,16 +81,17 @@ export function useUpload() { timeout: 600000, data: fd, onUploadProgress(e: AxiosProgressEvent) { - const progress = e.total - ? Math.floor((e.loaded / e.total) * 100) - : 0; - + progress = e.total ? Math.floor((e.loaded / e.total) * 100) : 0; onProgress?.(progress); }, proxy: isLocal, NProgress: false }) .then((res) => { + if (progress != 100) { + onProgress?.(100); + } + key = encodeURIComponent(key); let url = "";