fix: Téléchargement direct des fichiers .txt dans documents comptables

This commit is contained in:
odentas 2025-12-10 15:23:31 +01:00
parent 2b6a926c64
commit f26b41c525

View file

@ -464,7 +464,21 @@ function SectionComptables() {
if (docsWithUrls) {
const docWithUrl = docsWithUrls.find(d => d.id === item.id)
if (docWithUrl?.url) {
window.open(docWithUrl.url, '_blank')
// Vérifier si c'est un fichier .txt
const isTxtFile = item.title.toLowerCase().endsWith('.txt')
if (isTxtFile) {
// Forcer le téléchargement pour les fichiers .txt
const link = document.createElement('a')
link.href = docWithUrl.url
link.download = item.title
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
} else {
// Ouvrir dans un nouvel onglet pour les autres fichiers (PDF, etc.)
window.open(docWithUrl.url, '_blank')
}
return
}
}