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) } };