extract DownloadImageButton.vue
Main daploy / deploy (push) Successful in 46s

This commit is contained in:
2024-11-19 21:34:11 +02:00
parent 663f6ac1ab
commit dfbea6ea91
3 changed files with 62 additions and 22 deletions
@@ -0,0 +1,54 @@
<template>
<Button
:label
icon="pi pi-download"
class="p-button-sm p-button-outlined"
:disabled="!svgUrl"
@click="downloadPng"
/>
</template>
<script setup lang="ts">
import { downloadImage } from '@/utils/images/downloadImage'
const props = defineProps({
svgUrl: {
type: String,
required: true,
},
filename: {
type: String,
required: true,
},
width: {
type: Number,
required: true,
},
label: {
type: String, // Название кнопки, которое будет отображаться пользователю
required: true,
},
type: {
type: String,
required: true,
},
})
async function downloadPng() {
if (!props.svgUrl) {
console.error('SVG URL не предоставлен')
return
}
try {
await downloadImage({
type: props.type,
filename: `${props.filename}.png`,
width: props.width,
url: props.svgUrl,
})
} catch (err) {
console.error('Ошибка скачивания PNG:', err)
}
}
</script>