diff --git a/backend/static/app.js b/backend/static/app.js index 9b652a8..bf6d794 100644 --- a/backend/static/app.js +++ b/backend/static/app.js @@ -232,7 +232,7 @@ class TranscriptionApp { const isMd = file.ext === '.md'; const isDocx = file.ext === '.docx'; const icon = isMd ? '📝' : isDocx ? '📄' : '📎'; - const clickable = isMd ? 'clickable' : ''; + const clickable = isMd || isDocx ? 'clickable' : ''; return `
@@ -360,11 +360,30 @@ class TranscriptionApp { } else if (ext === '.docx') { viewer.innerHTML = `
-

Для просмотра DOCX скачайте файл:

- ⬇️ Скачать ${this.escapeHtml(path)} +

Скачивание DOCX...

`; + // Принудительное скачивание через Blob (браузер не блокирует) + try { + const resp = await fetch(`/api/files/download?path=${encodeURIComponent(path)}`); + if (!resp.ok) throw new Error('Download failed'); + const blob = await resp.blob(); + const url = URL.createObjectURL(blob); + const a = document.createElement('a'); + a.href = url; + a.download = path.split('/').pop(); + document.body.appendChild(a); + a.click(); + a.remove(); + URL.revokeObjectURL(url); + viewer.innerHTML = ` +
+

✅ Файл скачан: ${this.escapeHtml(path)}

+
+ `; + } catch (err) { + viewer.innerHTML = `
Ошибка скачивания: ${this.escapeHtml(err.message)}
`; + } } }