From 11015fd55bacf5e2bf84b9785903153ca44bb8a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CNaeel=E2=80=9D?= Date: Thu, 16 Jul 2026 07:01:44 +0400 Subject: [PATCH] =?UTF-8?q?fix:=20remove=20.doc=20support=20=E2=80=94=20li?= =?UTF-8?q?breoffice=20unavailable=20on=20=D0=A8=D1=82=D1=83=D1=80=D0=B2?= =?UTF-8?q?=D0=B0=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- site/static/files.js | 75 ++++++++++++++------------------------- site/templates/index.html | 2 +- 2 files changed, 27 insertions(+), 50 deletions(-) diff --git a/site/static/files.js b/site/static/files.js index 02092e3..1f44a12 100644 --- a/site/static/files.js +++ b/site/static/files.js @@ -211,59 +211,36 @@ window.toggleClassifyDetail = async function(i) { * uploadFile(file, onProgress) — загрузка одного файла на бэкенд. * * v2.0.1: fetch() вместо XHR — XHR давал ERR_CONNECTION_RESET (drhider v0.0.29) + * v2.0.2: убрана конвертация .doc (libreoffice недоступен на Штурвале) * Прогресс: без процентов (fetch не поддерживает), только статус. - * - * Особенности: - * - .doc (не .docx!) конвертируется через CONVERT_URL перед загрузкой - * - onProgress(pct) — сохранён для совместимости, вызывается с 0 и 100 - * - Возвращает Promise<ответ API> + * Возвращает Promise<ответ API> */ function uploadFile(file, onProgress, zipSource) { - // .doc → конвертация в docx (старый формат Word) - var isDoc = file.name.toLowerCase().endsWith('.doc') && !file.name.toLowerCase().endsWith('.docx'); + if (onProgress) onProgress(0); + var fd = new FormData(); + fd.append('files', file, file.name); + if (state.contractId) fd.append('contract_id', state.contractId); + fd.append('batch_id', state.batchId); + if (zipSource) fd.append('zip_source', zipSource); - function doUpload(uploadFile, uploadName) { - if (onProgress) onProgress(0); - var fd = new FormData(); - fd.append('files', uploadFile, uploadName); - if (state.contractId) fd.append('contract_id', state.contractId); - fd.append('batch_id', state.batchId); - if (zipSource) fd.append('zip_source', zipSource); - - return fetch(UPLOAD_URL + '?_=' + Date.now(), { method: 'POST', body: fd }) - .then(function(r) { - if (!r.ok) throw new Error('HTTP ' + r.status); - return r.json(); - }) - .then(function(data) { - if (data.ok) { - if (onProgress) onProgress(100); - return data; - } - throw new Error(data.error || 'Неизвестная ошибка'); - }) - .catch(function(e) { - // Перезапись fetch-ошибок в понятные сообщения - if (e.message === 'Failed to fetch' || e.name === 'TypeError') { - throw new Error('Сеть'); - } - throw e; - }); - } - - if (isDoc) { - return fetch(CONVERT_URL, { method: 'POST', body: file }) - .then(function(r) { - if (!r.ok) throw new Error('Конвертация .doc'); - return r.blob(); - }) - .then(function(blob) { - if (blob.size < 100) throw new Error('Конвертация .doc'); - return doUpload(blob, file.name.replace(/\.doc$/i, '.docx')); - }); - } else { - return doUpload(file, file.name); - } + return fetch(UPLOAD_URL + '?_=' + Date.now(), { method: 'POST', body: fd }) + .then(function(r) { + if (!r.ok) throw new Error('HTTP ' + r.status); + return r.json(); + }) + .then(function(data) { + if (data.ok) { + if (onProgress) onProgress(100); + return data; + } + throw new Error(data.error || 'Неизвестная ошибка'); + }) + .catch(function(e) { + if (e.message === 'Failed to fetch' || e.name === 'TypeError') { + throw new Error('Сеть'); + } + throw e; + }); } /** diff --git a/site/templates/index.html b/site/templates/index.html index 90f811a..30755a6 100644 --- a/site/templates/index.html +++ b/site/templates/index.html @@ -90,7 +90,7 @@ Загрузка договоров/приложений/спецификаций
- +
Порядок определяется автоматически при классификации
⚠ При совпадении имён — запрос на перезапись (OK / Отмена). Файлы из ZIP-архивов загружаются через тот же поток.