v0.0.49: индикатор распаковки архивов, разделение фаз (загрузка/обработка), таймауты SSE на ingress 1800с
Deploy drhider / validate (push) Canceled after 0s
Deploy drhider / validate (push) Canceled after 0s
This commit is contained in:
+1
-1
@@ -20,7 +20,7 @@ if _sys_path_root not in sys.path:
|
||||
sys.path.insert(0, _sys_path_root)
|
||||
|
||||
# Версия приложения (меняется при изменениях)
|
||||
VERSION = "0.0.48"
|
||||
VERSION = "0.0.49"
|
||||
|
||||
|
||||
def create_app():
|
||||
|
||||
+28
-12
@@ -343,16 +343,31 @@ function addFileWithDedup(file) {
|
||||
|
||||
fi.addEventListener('change', async () => {
|
||||
const incoming = Array.from(fi.files);
|
||||
for (const f of incoming) {
|
||||
if (f.name.toLowerCase().endsWith('.zip')) {
|
||||
try {
|
||||
const nested = await listZipFiles(f);
|
||||
nested.forEach(x => addFileWithDedup(x));
|
||||
} catch (err) {
|
||||
addFileWithDedup(f); // не удалось распаковать — добавить zip как есть
|
||||
const hasZip = incoming.some(f => f.name.toLowerCase().endsWith('.zip'));
|
||||
if (hasZip) {
|
||||
// Распаковка архивов может занять время — показать индикатор
|
||||
document.body.style.cursor = 'wait';
|
||||
st.className = 'status progress';
|
||||
st.textContent = 'Разбираю архивы…';
|
||||
}
|
||||
try {
|
||||
for (const f of incoming) {
|
||||
if (f.name.toLowerCase().endsWith('.zip')) {
|
||||
try {
|
||||
const nested = await listZipFiles(f);
|
||||
nested.forEach(x => addFileWithDedup(x));
|
||||
} catch (err) {
|
||||
addFileWithDedup(f); // не удалось распаковать — добавить zip как есть
|
||||
}
|
||||
} else {
|
||||
addFileWithDedup(f);
|
||||
}
|
||||
} else {
|
||||
addFileWithDedup(f);
|
||||
}
|
||||
} finally {
|
||||
if (hasZip) {
|
||||
document.body.style.cursor = '';
|
||||
st.className = '';
|
||||
st.textContent = '';
|
||||
}
|
||||
}
|
||||
const d = new DataTransfer();
|
||||
@@ -383,7 +398,7 @@ async function uploadFiles() {
|
||||
for (let i = 0; i < total; i++) {
|
||||
const f = files[i], n = i + 1;
|
||||
st.className = 'status progress';
|
||||
st.textContent = 'Загрузка ' + n + '/' + total + ': ' + f.name;
|
||||
st.textContent = 'Загрузка (этап 1/2) ' + n + '/' + total + ': ' + f.name;
|
||||
try {
|
||||
const t0 = performance.now();
|
||||
await new Promise((resolve, reject) => {
|
||||
@@ -431,15 +446,16 @@ async function uploadFiles() {
|
||||
}
|
||||
|
||||
// Фаза 2: обработка (SSE — прогресс по каждому файлу)
|
||||
// Сброс загрузочных статусов — теперь этап обработки
|
||||
for (let i = 0; i < total; i++) ss(i, '<span style="color:#2563eb">⏳</span>');
|
||||
const fileTimers = {}; // idx -> performance.now()
|
||||
const fileIntervals = {}; // idx -> setInterval id
|
||||
st.className = 'status progress';
|
||||
st.textContent = 'Обработка...';
|
||||
st.textContent = 'Обработка (этап 2/2)…';
|
||||
const t0 = performance.now();
|
||||
const ptimer = setInterval(() => {
|
||||
const sec = Math.round((performance.now() - t0) / 1000);
|
||||
st.textContent = 'Обработка... ' + sec + 'с';
|
||||
st.textContent = 'Обработка (этап 2/2)… ' + sec + 'с';
|
||||
}, 1000);
|
||||
|
||||
// Крупный live-блок «Идёт обработка» с тикающим таймером
|
||||
|
||||
Reference in New Issue
Block a user