fix:剪切板上传图片

This commit is contained in:
李亮亮 2024-01-16 10:38:09 +08:00
parent 18c3060e54
commit 94c13cf1ef
1 changed files with 19 additions and 16 deletions

View File

@ -121,12 +121,12 @@ const clearInput = () => {
}
const clipboardUpload = () => {
const clipboardContents = await navigator.clipboard.read();
navigator.clipboard.read().then(clipboardContents => {
for (const item of clipboardContents) {
if (!item.types.includes("image/png")) {
throw new Error("剪切板中不是图片!");
}
const blob = await item.getType("image/png");
item.getType("image/png").then(blob => {
const file = new File([blob], "clipboard.png", {
type: "image/png",
});
@ -137,7 +137,10 @@ const clipboardUpload = () => {
tmpSrc: URL.createObjectURL(file)
}
]
});
}
});
}
const appendConvertedImages = async (files: FileList | null | undefined) => {