style: 收紧工具箱页面与侧栏留白
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
"""本地工具箱入口:streamlit run app.py。"""
|
||||
import streamlit as st
|
||||
from ui import home_page, market_page, building_page, tasks_page, results_page
|
||||
from ui.layout import apply_compact_layout
|
||||
|
||||
st.set_page_config(page_title="MarketGrid 工具箱", page_icon="🗺️", layout="wide")
|
||||
apply_compact_layout()
|
||||
pages = {
|
||||
"home": st.Page(home_page.render, title="工具箱首页", icon="🏠", default=True),
|
||||
"market": st.Page(market_page.render, title="市场网格出图", icon="🗺️", url_path="market"),
|
||||
@@ -17,13 +19,13 @@ nav = st.navigation(
|
||||
position="hidden",
|
||||
)
|
||||
with st.sidebar:
|
||||
st.title("MarketGrid")
|
||||
st.markdown("## MarketGrid")
|
||||
st.caption("空间数据工具箱")
|
||||
st.subheader("工具")
|
||||
st.markdown("**工具**")
|
||||
st.page_link(pages["home"], label="工具箱首页", icon="🏠", use_container_width=True)
|
||||
st.page_link(pages["market"], label="市场网格出图", icon="🗺️", use_container_width=True)
|
||||
st.page_link(pages["buildings"], label="楼宇数据查询", icon="🏢", use_container_width=True)
|
||||
st.subheader("工作记录")
|
||||
st.markdown("**工作记录**")
|
||||
st.page_link(pages["tasks"], label="任务中心", icon="⏳", use_container_width=True)
|
||||
st.page_link(pages["results"], label="成果浏览", icon="📦", use_container_width=True)
|
||||
nav.run()
|
||||
|
||||
+2
-2
@@ -5,8 +5,8 @@ from .task_panel import show_started, task_panel
|
||||
|
||||
|
||||
def render():
|
||||
st.title("楼宇数据查询")
|
||||
st.write("根据坐标 CSV 查询楼宇 WFS,返回后即时写入,保留未命中和失败记录。")
|
||||
st.markdown("## 楼宇数据查询")
|
||||
st.caption("根据坐标 CSV 查询楼宇 WFS,返回后即时写入,保留未命中和失败记录。")
|
||||
source = file_input("坐标清单", "source/NRBuildingsPoint.csv", "csv", "building_csv")
|
||||
st.caption("输入列名必须包含:序号、经度、维度。输出采用 UTF-8 BOM,方便 Excel 打开。")
|
||||
with st.form("building_run"):
|
||||
|
||||
+6
-6
@@ -5,25 +5,25 @@ from toolbox.validation import SOURCES
|
||||
|
||||
|
||||
def render():
|
||||
st.title("MarketGrid 工具箱")
|
||||
st.write("从空间数据到可交付成果,集中完成出图、查询与结果检查。")
|
||||
st.markdown("## MarketGrid 工具箱")
|
||||
st.caption("从空间数据到可交付成果,集中完成出图、查询与结果检查。")
|
||||
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("选择工具")
|
||||
st.markdown("#### 选择工具")
|
||||
left, right = st.columns(2)
|
||||
with left, st.container(border=True):
|
||||
st.markdown("### 🗺️ 市场网格出图")
|
||||
st.markdown("##### 🗺️ 市场网格出图")
|
||||
st.write("六类数据源导入,完整运行专题渲染、空间分包和 QGIS 打包流程。")
|
||||
st.page_link(st.session_state["pages"]["market"], label="进入出图流程", icon="➡️")
|
||||
with right, st.container(border=True):
|
||||
st.markdown("### 🏢 楼宇数据查询")
|
||||
st.markdown("##### 🏢 楼宇数据查询")
|
||||
st.write("导入坐标清单,批量查询楼宇并实时生成 CSV。")
|
||||
st.page_link(st.session_state["pages"]["buildings"], label="进入楼宇查询", icon="➡️")
|
||||
st.subheader("默认数据源")
|
||||
st.markdown("#### 默认数据源")
|
||||
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")
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
"""共享界面布局样式。"""
|
||||
import streamlit as st
|
||||
|
||||
COMPACT_CSS = """
|
||||
<style>
|
||||
header[data-testid="stHeader"] {
|
||||
background: transparent;
|
||||
height: 2.5rem;
|
||||
}
|
||||
div[data-testid="stDecoration"] {
|
||||
display: none;
|
||||
}
|
||||
.block-container {
|
||||
padding-top: 1.1rem !important;
|
||||
padding-bottom: 1.2rem !important;
|
||||
padding-left: 2rem !important;
|
||||
padding-right: 2rem !important;
|
||||
max-width: 1200px;
|
||||
}
|
||||
section[data-testid="stSidebar"] > div:first-child {
|
||||
padding-top: 0.75rem !important;
|
||||
padding-bottom: 0.75rem !important;
|
||||
}
|
||||
section[data-testid="stSidebar"] [data-testid="stMarkdownContainer"] h1,
|
||||
section[data-testid="stSidebar"] [data-testid="stMarkdownContainer"] h2,
|
||||
section[data-testid="stSidebar"] [data-testid="stMarkdownContainer"] h3 {
|
||||
margin: 0.15rem 0 0.2rem 0 !important;
|
||||
padding: 0 !important;
|
||||
line-height: 1.2 !important;
|
||||
}
|
||||
section[data-testid="stSidebar"] [data-testid="stCaptionContainer"] {
|
||||
margin-top: 0 !important;
|
||||
margin-bottom: 0.55rem !important;
|
||||
}
|
||||
section[data-testid="stSidebar"] [data-testid="stSidebarNavLink"],
|
||||
section[data-testid="stSidebar"] a[data-testid="stPageLink-NavLink"] {
|
||||
padding-top: 0.35rem !important;
|
||||
padding-bottom: 0.35rem !important;
|
||||
margin: 0.05rem 0 !important;
|
||||
}
|
||||
div[data-testid="stMainBlockContainer"] > div {
|
||||
gap: 0.65rem;
|
||||
}
|
||||
div[data-testid="stVerticalBlock"] {
|
||||
gap: 0.55rem !important;
|
||||
}
|
||||
div[data-testid="stHorizontalBlock"] {
|
||||
gap: 0.75rem !important;
|
||||
}
|
||||
[data-testid="stMetric"] {
|
||||
background: #EDF2F7;
|
||||
border-radius: 0.55rem;
|
||||
padding: 0.55rem 0.8rem;
|
||||
}
|
||||
[data-testid="stMetricValue"] {
|
||||
font-size: 1.55rem !important;
|
||||
}
|
||||
h1 {
|
||||
font-size: 1.7rem !important;
|
||||
margin-bottom: 0.2rem !important;
|
||||
}
|
||||
h2, h3 {
|
||||
margin-top: 0.35rem !important;
|
||||
margin-bottom: 0.25rem !important;
|
||||
}
|
||||
hr {
|
||||
margin: 0.4rem 0 !important;
|
||||
}
|
||||
</style>
|
||||
"""
|
||||
|
||||
|
||||
def apply_compact_layout():
|
||||
st.markdown(COMPACT_CSS, unsafe_allow_html=True)
|
||||
+4
-5
@@ -9,10 +9,9 @@ from .task_panel import show_started, task_panel
|
||||
|
||||
|
||||
def render():
|
||||
st.title("市场网格出图")
|
||||
st.write("导入六类数据,一次完成竟对信号渲染、建筑与 AOI 分包、QGIS 工程和全量汇总。")
|
||||
st.caption("大体积 GeoPackage 推荐直接填写本地路径,避免上传时额外占用内存。上传副本和新成果均保存在 output/toolbox。")
|
||||
st.subheader("1 · 导入数据源")
|
||||
st.markdown("## 市场网格出图")
|
||||
st.caption("导入六类数据,一次完成竟对信号渲染、建筑与 AOI 分包、QGIS 工程和全量汇总。大体积 GeoPackage 推荐直接填写本地路径。")
|
||||
st.markdown("#### 1 · 导入数据源")
|
||||
params = {}
|
||||
columns = st.columns(2)
|
||||
for index, (key, (label, default, extension)) in enumerate(SOURCES.items()):
|
||||
@@ -25,7 +24,7 @@ def render():
|
||||
options = market_options(params["MARKET_GPKG"])
|
||||
except (OSError, sqlite3.Error, ValueError) as error:
|
||||
st.warning(f"市场边界暂不可用:{error}")
|
||||
st.subheader("2 · 选择市场与输出参数")
|
||||
st.markdown("#### 2 · 选择市场与输出参数")
|
||||
with st.form("market_run"):
|
||||
all_markets = st.checkbox("处理全部市场", value=True)
|
||||
labels = {fid: f"{fid} · {name}" for fid, name in options}
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@ def preview(path):
|
||||
|
||||
|
||||
def render():
|
||||
st.title("成果浏览")
|
||||
st.markdown("## 成果浏览")
|
||||
st.write("查看既有成果或新任务结果,预览数据表、空间图层、QGIS 图层配置和专题栅格。")
|
||||
tasks = list_tasks()
|
||||
roots = {"现有正式成果": ROOT / "output"}
|
||||
|
||||
+1
-1
@@ -3,6 +3,6 @@ from .task_panel import task_panel
|
||||
|
||||
|
||||
def render():
|
||||
st.title("任务中心")
|
||||
st.markdown("## 任务中心")
|
||||
st.caption("进度每两秒刷新。关闭浏览器不会中断任务;停止请求会保留已完成成果。")
|
||||
task_panel()
|
||||
|
||||
Reference in New Issue
Block a user