feat: add download button for QR code in dashboard links

This commit is contained in:
MinerAle 2025-02-24 21:00:47 +01:00
parent 3e9f3bb02d
commit c4626101d5

View file

@ -1,4 +1,6 @@
<script setup>
import { Button } from '#components'
import { Download } from 'lucide-vue-next'
import QRCodeStyling from 'qr-code-styling'
const props = defineProps({
@ -68,14 +70,27 @@ const options = {
const qrCode = new QRCodeStyling(options)
const qrCodeEl = ref(null)
function downloadQRCode() {
qrCode.download({
extension: 'png',
name: `qr-${props.data}`,
})
}
onMounted(() => {
qrCode.append(qrCodeEl.value)
})
</script>
<template>
<div
ref="qrCodeEl"
:data-text="data"
/>
<div class="flex flex-col items-center gap-4">
<div
ref="qrCodeEl"
:data-text="data"
/>
<Button variant="outline" @click="downloadQRCode">
<Download class="w-4 h-4 mr-2" />
Download QR Code
</Button>
</div>
</template>