feat: 新增模块化Streamlit本地工具箱

This commit is contained in:
nixevol
2026-09-16 16:28:27 +08:00
parent 4cdd26a288
commit fbd856d54d
37 changed files with 3921 additions and 2754 deletions
+36
View File
@@ -0,0 +1,36 @@
import json
import streamlit as st
from toolbox.tasks import ROOT, list_tasks, ACTIVE
from toolbox.validation import SOURCES
def render():
st.title("MarketGrid 工具箱")
st.write("从空间数据到可交付成果,集中完成出图、查询与结果检查。")
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"))))
st.subheader("选择工具")
left, right = st.columns(2)
with left, st.container(border=True):
st.markdown("### 🗺️ 市场网格出图")
st.write("六类数据源导入,完整运行专题渲染、空间分包和 QGIS 打包流程。")
st.page_link(st.session_state["pages"]["market"], label="进入出图流程", icon="➡️")
with right, st.container(border=True):
st.markdown("### 🏢 楼宇数据查询")
st.write("导入坐标清单,批量查询楼宇并实时生成 CSV。")
st.page_link(st.session_state["pages"]["buildings"], label="进入楼宇查询", icon="➡️")
st.subheader("默认数据源")
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}")