Skip to content

Commit

Permalink
fix: manual focus
Browse files Browse the repository at this point in the history
  • Loading branch information
yjl9903 committed Feb 1, 2024
1 parent 677884e commit 8cda2fe
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions components/TokutenItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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<Blob>(image, { responseType: 'blob' });
// 手动 focus
if (!document.hasFocus()) {
document.body.focus();
}
await clipboard.write([
new clipboard.ClipboardItem({
[blob.type]: blob
Expand Down

0 comments on commit 8cda2fe

Please sign in to comment.