From 8cda2fe8b168d775405485a0eaa932c03d7a312b Mon Sep 17 00:00:00 2001 From: XLor Date: Thu, 1 Feb 2024 21:44:58 +0800 Subject: [PATCH] fix: manual focus --- components/TokutenItem.vue | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/components/TokutenItem.vue b/components/TokutenItem.vue index 477d5d3..0b478c2 100644 --- a/components/TokutenItem.vue +++ b/components/TokutenItem.vue @@ -38,12 +38,15 @@ async function downloadImage() { async function copyImage() { try { - // 手动 focus - document.body.focus(); // 转换成 png const image = img(props.data.image, { format: 'png' }); console.log(`复制图片:`, image); const blob = await $fetch(image, { responseType: 'blob' }); + + // 手动 focus + if (!document.hasFocus()) { + document.body.focus(); + } await clipboard.write([ new clipboard.ClipboardItem({ [blob.type]: blob