From 82d103757be76b97a1418f1663a1ad1b3eb95387 Mon Sep 17 00:00:00 2001 From: meijiali <你的邮箱@xxx.com> Date: Fri, 3 Jul 2026 14:32:46 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E4=B8=8E=E8=BF=9B=E5=BA=A6=E4=BD=93=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/static/app.js | 21 +++++ app/templates/index.html | 6 +- app/templates/partials/task_rows.html | 22 +++++- app/templates/tasks/detail.html | 23 +++++- app/templating.py | 14 ++++ tests/integration/test_routes.py | 108 ++++++++++++++++++++++++++ tests/unit/test_template_filters.py | 14 +++- 7 files changed, 203 insertions(+), 5 deletions(-) diff --git a/app/static/app.js b/app/static/app.js index 97f6824..1903e0e 100644 --- a/app/static/app.js +++ b/app/static/app.js @@ -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); diff --git a/app/templates/index.html b/app/templates/index.html index ac5485e..488e3ab 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -1,4 +1,5 @@ {% extends "base.html" %} +{% set has_running_tasks = tasks | selectattr("status", "equalto", "running") | list | length > 0 %} {% block title %}任务列表 - 热榜评论分析工具{% endblock %} {% block content %}
{{ task.id }}平台:{{ task.platform | platform_label }} {{ label }}
-成功 {{ task.successful_items_count }} / 共 {{ task.total_items_count }} 条内容
+正在抓取热点数据,请稍候...