wow
This commit is contained in:
parent
68bb75b1c8
commit
fa35d5c305
3 changed files with 46 additions and 20 deletions
|
|
@ -214,17 +214,19 @@ export default function App() {
|
|||
|
||||
async function copyImage(photo: GalleryPhoto) {
|
||||
try {
|
||||
if (typeof ClipboardItem !== "undefined" && navigator.clipboard?.write) {
|
||||
const response = await fetch(photo.src, { cache: "no-store" });
|
||||
const blob = await response.blob();
|
||||
await navigator.clipboard.write([new ClipboardItem({ [blob.type || "image/png"]: blob })]);
|
||||
} else if (navigator.clipboard?.writeText) {
|
||||
await navigator.clipboard.writeText(photo.src);
|
||||
}
|
||||
} catch {
|
||||
if (navigator.clipboard?.writeText) {
|
||||
await navigator.clipboard.writeText(photo.src);
|
||||
}
|
||||
const response = await fetch(photo.src);
|
||||
if (!response.ok) throw new Error("Failed to fetch image");
|
||||
|
||||
const blob = await response.blob();
|
||||
const clipboardItem = new ClipboardItem({
|
||||
[blob.type]: blob
|
||||
});
|
||||
|
||||
await navigator.clipboard.write([clipboardItem]);
|
||||
alert("이미지가 클립보드에 복사되었습니다!");
|
||||
} catch (error) {
|
||||
console.error("Failed to copy image:", error);
|
||||
alert("이미지 복사에 실패했습니다. 브라우저 호환성 문제일 수 있습니다.");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue