feat: 正式成果并入任务清单并限制成果页列表高度

This commit is contained in:
nixevol
2026-09-16 17:27:33 +08:00
parent 28f3eb877a
commit 6fdc613bac
4 changed files with 60 additions and 43 deletions
+12 -10
View File
@@ -1,17 +1,26 @@
import json
from pathlib import Path
import streamlit as st
from toolbox.tasks import ROOT, list_tasks, ACTIVE
from toolbox.validation import SOURCES
def _result_zip_count(tasks):
total = 0
for task in tasks:
directory = Path(task["output"])
if not directory.exists():
continue
total += sum(1 for path in directory.glob("*.zip") if path.is_file())
return total
def render():
st.markdown("## MarketGrid 工具箱")
tasks = list_tasks()
output = ROOT / "output"
cols = st.columns(3)
cols[0].metric("正在运行", sum(t["status"] in ACTIVE for t in tasks))
cols[1].metric("任务记录", len(tasks))
cols[2].metric("现有 ZIP 成果", len(list(output.glob("*.zip"))))
cols[2].metric("成果包", _result_zip_count(tasks))
st.markdown("#### 选择工具")
left, right = st.columns(2)
with left, st.container(border=True):
@@ -26,10 +35,3 @@ def render():
st.dataframe([{"数据源": label, "状态": "已就绪" if (ROOT / file).is_file() else "缺失",
"文件": file, "大小 MB": round((ROOT / file).stat().st_size / 1024**2, 1) if (ROOT / file).is_file() else 0}
for label, file, _ in SOURCES.values()], hide_index=True, width="stretch")
summary_path = output / "summary.json"
if summary_path.exists():
try:
data = json.loads(summary_path.read_text(encoding="utf-8"))
st.caption(f"现有正式成果:{len(data.get('zip_results', []))} 个市场包")
except (OSError, ValueError) as error:
st.warning(f"汇总记录无法读取:{error}")