fix: DrHider — better JS error handling, progress messages, timeout
Deploy contracts-flask / validate (push) Successful in 0s
Deploy contracts-flask / validate (push) Successful in 0s
This commit is contained in:
@@ -121,16 +121,21 @@ function render() {
|
||||
BTN.onclick = async () => {
|
||||
if (!files.length) return;
|
||||
BTN.disabled = true;
|
||||
setStatus('progress', '⏳ Обработка...');
|
||||
setStatus('progress', '⏳ Отправка на сервер...');
|
||||
const fd = new FormData(); files.forEach(f => fd.append('files', f));
|
||||
try {
|
||||
const r = await fetch('/api/drhider', { method:'POST', body:fd });
|
||||
if (!r.ok) throw new Error(await r.text());
|
||||
setStatus('progress', '⏳ Обработка (может занять до минуты)...');
|
||||
const r = await fetch('/api/drhider', { method:'POST', body:fd, signal:AbortSignal.timeout(300000) });
|
||||
if (!r.ok) {
|
||||
const txt = await r.text();
|
||||
throw new Error(txt);
|
||||
}
|
||||
const blob = await r.blob();
|
||||
const a = document.createElement('a'); a.href = URL.createObjectURL(blob); a.download = 'drhider_output.zip'; a.click();
|
||||
setStatus('done', '✅ Готово! ZIP скачан.');
|
||||
} catch(e) {
|
||||
setStatus('error', '❌ ' + e.message);
|
||||
setStatus('error', '❌ ' + (e.name === 'TimeoutError' ? 'Сервер не ответил за 5 минут' : e.message || 'Неизвестная ошибка'));
|
||||
console.error('DrHider error:', e);
|
||||
}
|
||||
BTN.disabled = false;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user