feat(ui): download button

This commit is contained in:
Pihkaal
2024-09-30 15:51:29 +02:00
parent fafbc9253e
commit 85a83a8e5e

28
app.vue
View File

@@ -19,6 +19,16 @@ const updateQRCode = async () => {
qrCode.value = canvas.value.toDataURL(`image/${format.value}`);
};
const downloadQRCode = () => {
const link = document.createElement("a");
link.href = qrCode.value;
link.download = "qrcode.png";
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
};
</script>
<template>
@@ -35,5 +45,23 @@ const updateQRCode = async () => {
<canvas ref="canvas" class="hidden" />
<img :src="qrCode" />
<UButton
icon="i-heroicons-arrow-down-tray"
size="sm"
color="primary"
variant="solid"
label="Download"
:trailing="false"
@click="downloadQRCode"
/>
<UButton
icon="i-heroicons-clipboard-document"
size="sm"
color="primary"
variant="solid"
label="Copy to clipboard"
:trailing="false"
/>
</div>
</template>