Files
hereconnect/apps/frontend/src/components/manage/DownloadImageButton.vue
T
ti 11bba7a275
Main daploy / deploy (push) Successful in 43s
move * to apps/frontend
2024-11-21 01:15:06 +02:00

55 lines
1.0 KiB
Vue

<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>