From 2ad890d4741b756609066d6bafeda74f9d4b8a7f Mon Sep 17 00:00:00 2001 From: lizijiee <562949697@qq.com> Date: Fri, 22 Mar 2024 00:48:48 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=8B=96=E6=8B=BD?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/home/aside/comp/Upload.vue | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/views/home/aside/comp/Upload.vue b/src/views/home/aside/comp/Upload.vue index f723701..bc619ef 100644 --- a/src/views/home/aside/comp/Upload.vue +++ b/src/views/home/aside/comp/Upload.vue @@ -73,20 +73,14 @@ const handleDragLeave = (e) => { }; // 停止拖拽时触发 -const handleDrop = (e) => { +const handleDrop = async (e) => { e.preventDefault(); // 阻止默认事件 const files = e.dataTransfer.files; - const draggedElement = e.dataTransfer.getData('text/plain'); - if (files.length === 0) { - fetch(draggedElement) - .then(res => res.blob()) - .then(async blob => { - const file = new File([blob], String(new Date().getTime()) + '.jpg', { type: 'image/jpeg' }); - const result = await upload({ file: file as any }) - const imgUrl = getImgUrl(result.data) - figureUrl.value = imgUrl - emit('update:value', result.data) - }); + if( files[0] ){ + const result = await upload({ file: files[0] as any }) + const imgUrl = getImgUrl(result.data) + figureUrl.value = imgUrl + emit('update:value', result.data) } };