fix: update frontend
This commit is contained in:
@@ -785,24 +785,24 @@
|
||||
else if (status === 'cancelled') showToast('已取消');
|
||||
}
|
||||
|
||||
function verifyTerminalTaskStatus(taskId, expectedStatus) {
|
||||
return fetch('/api/brand/tasks/' + taskId, {
|
||||
credentials: 'include',
|
||||
headers: withUidHeaders({ 'X-Requested-With': 'XMLHttpRequest' })
|
||||
})
|
||||
.then(function(r) { return r.json(); })
|
||||
.then(function(res) {
|
||||
if (!res.success || !res.task) return null;
|
||||
var actualStatus = (res.task.status || '').toLowerCase();
|
||||
if (actualStatus === 'success' || actualStatus === 'failed' || actualStatus === 'cancelled') {
|
||||
return actualStatus;
|
||||
}
|
||||
return null;
|
||||
})
|
||||
.catch(function() { return null; });
|
||||
}
|
||||
|
||||
function pollRunTask(taskId) {
|
||||
function verifyTerminalTaskStatus(taskId, expectedStatus) {
|
||||
return fetch('/api/brand/tasks/' + taskId, {
|
||||
credentials: 'include',
|
||||
headers: withUidHeaders({ 'X-Requested-With': 'XMLHttpRequest' })
|
||||
})
|
||||
.then(function(r) { return r.json(); })
|
||||
.then(function(res) {
|
||||
if (!res.success || !res.task) return null;
|
||||
var actualStatus = (res.task.status || '').toLowerCase();
|
||||
if (actualStatus === 'success' || actualStatus === 'failed' || actualStatus === 'cancelled') {
|
||||
return actualStatus;
|
||||
}
|
||||
return null;
|
||||
})
|
||||
.catch(function() { return null; });
|
||||
}
|
||||
|
||||
function pollRunTask(taskId) {
|
||||
pollTaskId = taskId;
|
||||
var runProgressFill = document.getElementById('runProgressFill');
|
||||
var runProgressText = document.getElementById('runProgressText');
|
||||
@@ -865,18 +865,18 @@
|
||||
break;
|
||||
}
|
||||
} catch (err) {}
|
||||
}
|
||||
|
||||
if (terminalStatus) {
|
||||
var verifiedStatus = await verifyTerminalTaskStatus(taskId, terminalStatus);
|
||||
if (verifiedStatus) {
|
||||
try { runTaskEventAbortController.abort(); } catch (e2) {}
|
||||
runTaskEventAbortController = null;
|
||||
onRunTaskFinished(verifiedStatus);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (terminalStatus) {
|
||||
var verifiedStatus = await verifyTerminalTaskStatus(taskId, terminalStatus);
|
||||
if (verifiedStatus) {
|
||||
try { runTaskEventAbortController.abort(); } catch (e2) {}
|
||||
runTaskEventAbortController = null;
|
||||
onRunTaskFinished(verifiedStatus);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (err) {}
|
||||
})();
|
||||
|
||||
@@ -938,7 +938,7 @@
|
||||
});
|
||||
}
|
||||
tick();
|
||||
pollTimer = setInterval(tick, 3000);
|
||||
pollTimer = setInterval(tick, 3000);
|
||||
}
|
||||
|
||||
document.getElementById('btnRun').onclick = function() {
|
||||
@@ -1148,11 +1148,11 @@
|
||||
});
|
||||
|
||||
loadTasks();
|
||||
setInterval(function() {
|
||||
if (cachedTasks.some(function(t) { return (t.status || '').toLowerCase() === 'running'; })) {
|
||||
loadTasks();
|
||||
}
|
||||
}, 3000);
|
||||
setInterval(function() {
|
||||
if (cachedTasks.some(function(t) { return (t.status || '').toLowerCase() === 'running'; })) {
|
||||
loadTasks();
|
||||
}
|
||||
}, 3000);
|
||||
|
||||
if (window.addEventListener) {
|
||||
window.addEventListener('pywebviewready', function() {
|
||||
|
||||
Reference in New Issue
Block a user