2025-12-10 14:54:12 +01:00
|
|
|
<template>
|
|
|
|
|
<k-box>
|
|
|
|
|
<k-button
|
|
|
|
|
theme="positive"
|
|
|
|
|
icon="download"
|
|
|
|
|
:disabled="loading"
|
|
|
|
|
@click="exportEpub"
|
|
|
|
|
>
|
|
|
|
|
Exporter en EPUB
|
|
|
|
|
</k-button>
|
|
|
|
|
|
|
|
|
|
<k-text v-if="loading">Génération en cours…</k-text>
|
|
|
|
|
<k-text v-if="error" theme="negative">{{ error }}</k-text>
|
|
|
|
|
</k-box>
|
|
|
|
|
</template>
|
|
|
|
|
|
2026-02-09 15:36:00 +01:00
|
|
|
<!-- <script>
|
2025-12-10 14:54:12 +01:00
|
|
|
export default {
|
|
|
|
|
props: {
|
|
|
|
|
pageId: String
|
|
|
|
|
},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
loading: false,
|
|
|
|
|
error: null,
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
async exportEpub() {
|
|
|
|
|
this.loading = true;
|
|
|
|
|
this.error = null;
|
2026-02-09 15:36:00 +01:00
|
|
|
|
2025-12-10 14:54:12 +01:00
|
|
|
try {
|
|
|
|
|
const response = await this.$api.post(`epub-export/${this.pageId}`);
|
|
|
|
|
const blob = await response.blob()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Télécharger le fichier
|
|
|
|
|
const url = window.URL.createObjectURL(blob)
|
|
|
|
|
const a = document.createElement('a')
|
|
|
|
|
a.href = url
|
|
|
|
|
a.download = this.pageId + '.epub'
|
|
|
|
|
a.click()
|
|
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
this.error = "Erreur : " + e.message
|
|
|
|
|
} finally {
|
|
|
|
|
this.loading = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-02-09 15:36:00 +01:00
|
|
|
</script> -->
|
|
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
|
import { ref } from 'vue'
|
|
|
|
|
|
|
|
|
|
// Props
|
|
|
|
|
const { pageId } = defineProps({
|
|
|
|
|
pageId: String
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// State
|
|
|
|
|
const loading = ref(false)
|
|
|
|
|
const error = ref(null)
|
|
|
|
|
|
|
|
|
|
// Methods
|
|
|
|
|
async function exportEpub() {
|
|
|
|
|
loading.value = true
|
|
|
|
|
error.value = null
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
// Appel API
|
|
|
|
|
const response = await $api.post(`epub-export/${pageId}`)
|
|
|
|
|
const blob = await response.blob()
|
|
|
|
|
|
|
|
|
|
// Création du téléchargement
|
|
|
|
|
const url = window.URL.createObjectURL(blob)
|
|
|
|
|
const a = document.createElement('a')
|
|
|
|
|
a.href = url
|
|
|
|
|
a.download = pageId + '.epub'
|
|
|
|
|
a.click()
|
|
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
error.value = 'Erreur : ' + e.message
|
|
|
|
|
} finally {
|
|
|
|
|
loading.value = false
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-12-10 14:54:12 +01:00
|
|
|
</script>
|
2026-02-09 15:36:00 +01:00
|
|
|
|