feat: 优化任务状态与进度体验
This commit is contained in:
@@ -91,6 +91,27 @@ function pollTaskDetailStatus(taskId) {
|
||||
window.setTimeout(poll, intervalMs);
|
||||
}
|
||||
|
||||
function pollTaskListStatus() {
|
||||
const tableBody = document.querySelector("[data-task-list-auto-poll='true']");
|
||||
if (!tableBody) return;
|
||||
|
||||
const intervalMs = 5000;
|
||||
const poll = async () => {
|
||||
try {
|
||||
const resp = await fetch("/api/tasks", { cache: "no-store" });
|
||||
if (!resp.ok) return;
|
||||
const tasks = await resp.json();
|
||||
const hasRunningTask = tasks.some((task) => task.status === "running");
|
||||
window.location.reload();
|
||||
if (!hasRunningTask) return;
|
||||
} catch (_error) {
|
||||
return;
|
||||
}
|
||||
window.setTimeout(poll, intervalMs);
|
||||
};
|
||||
window.setTimeout(poll, intervalMs);
|
||||
}
|
||||
|
||||
async function downloadExport(url, defaultFilename, event) {
|
||||
if (event) event.preventDefault();
|
||||
const resp = await fetch(url);
|
||||
|
||||
Reference in New Issue
Block a user