Commit 3994a761 authored by 郭阔's avatar 郭阔

feat(panel): homepage shows in-progress harvests

栏目列表 now surfaces running harvests: top banner (⟳ 正在采集: <sources>,
browsers stay open until finish), per-row 运行中 badge above 最近运行,
and 30s auto-refresh while any harvest is active — previously an
in-flight run was invisible until its .last.log landed.
parent 910157b6
......@@ -563,6 +563,7 @@ def _active_harvests():
@require_auth
def index():
sources = get_source_list()
active = set(_active_harvests())
# 合并已安装但未建调度的技能源(可通过开关开启,开启时自动错峰创建调度)
scheduled = {s["source"] for s in sources}
for row in pl.source_rows(LOG_DIR):
......@@ -613,7 +614,7 @@ def index():
else:
flash(f"每日汇总失败 (exit {digest_status['rc']})\n{digest_status['stdout']}\n{digest_status['stderr']}", "error")
return render_template("index.html", sources=sources,
return render_template("index.html", sources=sources, active=active,
digest_props=digest_props, digest_run_time=digest_run_time,
digest_status=digest_status, auto_refresh=auto_refresh,
default_provider=default_provider,
......
{% extends "base.html" %}
{% block title %}News Harvester — 栏目列表{% endblock %}
{% block extra_head %}
{% if auto_refresh %}
<meta http-equiv="refresh" content="10">
{% if auto_refresh or active %}
<meta http-equiv="refresh" content="{{ 10 if auto_refresh else 30 }}">
{% endif %}
<style>
.switch{width:44px;height:24px;border-radius:12px;border:1px solid #2a2d37;background:#3a3d47;position:relative;cursor:pointer;padding:0;transition:background .15s}
......@@ -32,6 +32,12 @@
</div>
<h1>栏目列表 <span style="font-size:14px;color:#666">({{ sources|length }} 个)</span></h1>
{% if active %}
<div class="flash" style="border-color:#2ea043">
⟳ 正在采集:{% for a in active|sort %}<strong>{{ a }}</strong>{{ ", " if not loop.last }}{% endfor %}
<span style="color:#888;font-size:12px">(结束前浏览器保持打开属正常;页面每 30 秒自动刷新)</span>
</div>
{% endif %}
<div class="table-wrap">
<table>
<thead>
......@@ -96,6 +102,9 @@
<span style="color:#666;font-size:12px">下次</span> <span style="color:#e8c34a;font-weight:600">{{ s.next }}</span>
</td>
<td>
{% if s.source in active %}
<span class="badge active">⟳ 运行中</span><br>
{% endif %}
{% if s.log %}
{% set status_text = s.log.get('status', '') %}
{{ s.log.mtime }}{% if status_text and '成功' not in status_text and '失败' not in status_text %} · {{ status_text }}{% endif %}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment