fix: 修复拖拽上传文件逻辑

bak
lizijiee 1 year ago
parent 8543258c89
commit 2ad890d474

@ -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 })
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)
});
}
};
</script>

Loading…
Cancel
Save