Skip to content

Commit

Permalink
fix: copy img
Browse files Browse the repository at this point in the history
  • Loading branch information
YunYouJun committed Feb 4, 2024
1 parent c3dee85 commit ab45f60
Show file tree
Hide file tree
Showing 2 changed files with 1,395 additions and 1,751 deletions.
14 changes: 7 additions & 7 deletions components/SpringFestivalCouplets.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,17 @@ defineProps<{
const app = useAppStore()
const sfcContainer = ref<HTMLElement | null>(null)
/**
* Download image
*/
async function download() {
const container = document.getElementById('spring-festival-container')
if (!container)
if (!sfcContainer.value)
return
// const url = await screenShotToBase64(container)
const url = await toPng(container, {
const url = await toPng(sfcContainer.value, {
includeQueryParams: true,
})
Expand All @@ -34,12 +35,11 @@ async function download() {
* Copy image to clipboard
*/
async function copyImg() {
const container = document.getElementById('girid-container')
if (!container)
if (!sfcContainer.value)
return
// const url = await screenShotToBase64(container)
const blob = await toBlob(container, {
const blob = await toBlob(sfcContainer.value, {
includeQueryParams: true,
})
Expand All @@ -60,7 +60,7 @@ async function shareLink() {
</script>

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

0 comments on commit ab45f60

Please sign in to comment.