fix: Téléchargement direct des fichiers .txt dans documents comptables
This commit is contained in:
parent
2b6a926c64
commit
f26b41c525
1 changed files with 15 additions and 1 deletions
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue