Skip to content

Commit ab45f60

Browse files
committed
fix: copy img
1 parent c3dee85 commit ab45f60

File tree

2 files changed

+1395
-1751
lines changed

2 files changed

+1395
-1751
lines changed

components/SpringFestivalCouplets.vue

+7-7
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,17 @@ defineProps<{
1313
1414
const app = useAppStore()
1515
16+
const sfcContainer = ref<HTMLElement | null>(null)
17+
1618
/**
1719
* Download image
1820
*/
1921
async function download() {
20-
const container = document.getElementById('spring-festival-container')
21-
if (!container)
22+
if (!sfcContainer.value)
2223
return
2324
// const url = await screenShotToBase64(container)
2425
25-
const url = await toPng(container, {
26+
const url = await toPng(sfcContainer.value, {
2627
includeQueryParams: true,
2728
})
2829
@@ -34,12 +35,11 @@ async function download() {
3435
* Copy image to clipboard
3536
*/
3637
async function copyImg() {
37-
const container = document.getElementById('girid-container')
38-
if (!container)
38+
if (!sfcContainer.value)
3939
return
4040
// const url = await screenShotToBase64(container)
4141
42-
const blob = await toBlob(container, {
42+
const blob = await toBlob(sfcContainer.value, {
4343
includeQueryParams: true,
4444
})
4545
@@ -60,7 +60,7 @@ async function shareLink() {
6060
</script>
6161

6262
<template>
63-
<div id="spring-festival-container" flex="col" class="font-zmx spring-festival-container">
63+
<div id="spring-festival-container" ref="sfcContainer" flex="col" class="font-zmx spring-festival-container">
6464
<div class="font-zmx m-auto bg-#ff0000 p-2" w="50" text="4xl black">
6565
{{ coupletsData['横批'] }}
6666
</div>

0 commit comments

Comments
 (0)