From 94c13cf1ef72af71ff943b46161e703de181894b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E4=BA=AE=E4=BA=AE?= Date: Tue, 16 Jan 2024 10:38:09 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E5=89=AA=E5=88=87=E6=9D=BF=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E5=9B=BE=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/UploadImages.vue | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/src/views/UploadImages.vue b/src/views/UploadImages.vue index aa50b1e..439d3e8 100644 --- a/src/views/UploadImages.vue +++ b/src/views/UploadImages.vue @@ -121,23 +121,26 @@ const clearInput = () => { } const clipboardUpload = () => { - const clipboardContents = await navigator.clipboard.read(); - for (const item of clipboardContents) { - if (!item.types.includes("image/png")) { - throw new Error("剪切板中不是图片!"); - } - const blob = await item.getType("image/png"); - const file = new File([blob], "clipboard.png", { - type: "image/png", - }); - convertedImages.value = [ - ...convertedImages.value, - { - file, - tmpSrc: URL.createObjectURL(file) + navigator.clipboard.read().then(clipboardContents => { + for (const item of clipboardContents) { + if (!item.types.includes("image/png")) { + throw new Error("剪切板中不是图片!"); } - ] - } + item.getType("image/png").then(blob => { + const file = new File([blob], "clipboard.png", { + type: "image/png", + }); + convertedImages.value = [ + ...convertedImages.value, + { + file, + tmpSrc: URL.createObjectURL(file) + } + ] + }); + } + }); + } const appendConvertedImages = async (files: FileList | null | undefined) => {