界面:全局隐藏输入框 Enter 提示,连接信息框内 ✕ 清除;修复内联 SVG 导致全局样式被 DOMPurify 丢弃
This commit is contained in:
+3
-12
@@ -32,18 +32,9 @@ def save_connection(values):
|
||||
CONNECTION_FILE.write_text(json.dumps(values, ensure_ascii=False, indent=2), encoding="utf-8")
|
||||
|
||||
|
||||
def _clear(state_key):
|
||||
st.session_state[state_key] = ""
|
||||
|
||||
|
||||
def connection_input(label, key, placeholder=None):
|
||||
"""带一键清除按钮的文本框;按钮不能放在 form 内,所以连接信息独立于表单。"""
|
||||
state_key = f"conn_{key}"
|
||||
text_col, clear_col = st.columns([14, 1], vertical_alignment="bottom")
|
||||
value = text_col.text_input(label, key=state_key, placeholder=placeholder)
|
||||
clear_col.button("", icon=":material/close:", key=f"clear_{key}", help="清除",
|
||||
on_click=_clear, args=(state_key,), use_container_width=True)
|
||||
return value
|
||||
"""type=search 的输入框在框内右侧自带 ✕ 清除按钮(样式见 layout.py)。"""
|
||||
return st.text_input(label, key=f"conn_{key}", placeholder=placeholder, type="search")
|
||||
|
||||
|
||||
def render():
|
||||
@@ -56,7 +47,7 @@ def render():
|
||||
st.markdown("**连接信息**(默认显示脚本内配置或上次保存值;修改后保存到本地,下次自动读取)")
|
||||
url = connection_input("服务地址", "URL", "https://...wfs?...ak=...&sig=...")
|
||||
cookies = connection_input("登录信息(Cookies)", "COOKIES", "CASTGC=...")
|
||||
referer = connection_input("来源页(可留空)", "REFERER")
|
||||
referer = connection_input("来源页(可留空)", "REFERER", "可留空")
|
||||
with st.form("building_run"):
|
||||
c1, c2, c3 = st.columns(3)
|
||||
start = c1.number_input("起始行", 1, value=1)
|
||||
|
||||
Reference in New Issue
Block a user