Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
CHANGED
|
@@ -334,6 +334,17 @@ def _get_custom_css():
|
|
| 334 |
min-width: 0 !important;
|
| 335 |
}
|
| 336 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 337 |
</style>
|
| 338 |
"""
|
| 339 |
|
|
@@ -545,10 +556,12 @@ with st.sidebar:
|
|
| 545 |
)
|
| 546 |
|
| 547 |
if auth_mode == "登录":
|
| 548 |
-
|
| 549 |
-
|
|
|
|
|
|
|
| 550 |
|
| 551 |
-
if
|
| 552 |
if input_username == "" or input_password == "":
|
| 553 |
st.warning("请输入用户名和密码")
|
| 554 |
elif st.session_state.login_attempts >= MAX_LOGIN_ATTEMPTS:
|
|
@@ -569,12 +582,14 @@ with st.sidebar:
|
|
| 569 |
st.rerun()
|
| 570 |
|
| 571 |
else: # 注册
|
| 572 |
-
|
| 573 |
-
|
| 574 |
-
|
| 575 |
-
|
| 576 |
-
|
| 577 |
-
|
|
|
|
|
|
|
| 578 |
if reg_pass != reg_pass2:
|
| 579 |
st.error("两次密码不一致")
|
| 580 |
else:
|
|
@@ -1179,6 +1194,7 @@ with st.sidebar:
|
|
| 1179 |
# 同步删除,避免多线程问题
|
| 1180 |
_delete_chunks_by_file(PUBLIC_SCOPE, fname)
|
| 1181 |
_delete_uploaded_file_from_storage(PUBLIC_SCOPE, fname)
|
|
|
|
| 1182 |
# 更新切片数缓存
|
| 1183 |
st.session_state["_sync_count_public"] = _count_chunks(PUBLIC_SCOPE)
|
| 1184 |
st.toast(f"已删除 {fname}")
|
|
@@ -1227,6 +1243,7 @@ with st.sidebar:
|
|
| 1227 |
# 同步删除,避免多线程问题
|
| 1228 |
_delete_chunks_by_file(PRIVATE_SCOPE, fname)
|
| 1229 |
_delete_uploaded_file_from_storage(PRIVATE_SCOPE, fname)
|
|
|
|
| 1230 |
# 更新切片数缓存
|
| 1231 |
st.session_state["_sync_count_private"] = _count_chunks(PRIVATE_SCOPE)
|
| 1232 |
st.toast(f"已删除 {fname}")
|
|
|
|
| 334 |
min-width: 0 !important;
|
| 335 |
}
|
| 336 |
}
|
| 337 |
+
|
| 338 |
+
/* 侧边栏文件列表:防止文件名溢出遮挡删除按钮 */
|
| 339 |
+
[data-testid="stSidebar"] [data-testid="stHorizontalBlock"] > div:first-child {
|
| 340 |
+
overflow: hidden !important;
|
| 341 |
+
text-overflow: ellipsis !important;
|
| 342 |
+
white-space: nowrap !important;
|
| 343 |
+
}
|
| 344 |
+
[data-testid="stSidebar"] [data-testid="stHorizontalBlock"] > div:last-child {
|
| 345 |
+
flex-shrink: 0 !important;
|
| 346 |
+
z-index: 1 !important;
|
| 347 |
+
}
|
| 348 |
</style>
|
| 349 |
"""
|
| 350 |
|
|
|
|
| 556 |
)
|
| 557 |
|
| 558 |
if auth_mode == "登录":
|
| 559 |
+
with st.form("login_form", clear_on_submit=False):
|
| 560 |
+
input_username = st.text_input("用户名", key="login_user")
|
| 561 |
+
input_password = st.text_input("密码", type="password", key="login_pass")
|
| 562 |
+
submitted = st.form_submit_button("🔓 登录", use_container_width=True, type="primary")
|
| 563 |
|
| 564 |
+
if submitted:
|
| 565 |
if input_username == "" or input_password == "":
|
| 566 |
st.warning("请输入用户名和密码")
|
| 567 |
elif st.session_state.login_attempts >= MAX_LOGIN_ATTEMPTS:
|
|
|
|
| 582 |
st.rerun()
|
| 583 |
|
| 584 |
else: # 注册
|
| 585 |
+
with st.form("register_form", clear_on_submit=False):
|
| 586 |
+
reg_user = st.text_input("用户名", key="reg_user")
|
| 587 |
+
reg_pass = st.text_input("密码", type="password", key="reg_pass")
|
| 588 |
+
reg_pass2 = st.text_input("确认密码", type="password", key="reg_pass2")
|
| 589 |
+
reg_code = st.text_input("邀请码", type="password", key="reg_code")
|
| 590 |
+
reg_submitted = st.form_submit_button("注册", use_container_width=True)
|
| 591 |
+
|
| 592 |
+
if reg_submitted:
|
| 593 |
if reg_pass != reg_pass2:
|
| 594 |
st.error("两次密码不一致")
|
| 595 |
else:
|
|
|
|
| 1194 |
# 同步删除,避免多线程问题
|
| 1195 |
_delete_chunks_by_file(PUBLIC_SCOPE, fname)
|
| 1196 |
_delete_uploaded_file_from_storage(PUBLIC_SCOPE, fname)
|
| 1197 |
+
_list_uploaded_files_db.clear()
|
| 1198 |
# 更新切片数缓存
|
| 1199 |
st.session_state["_sync_count_public"] = _count_chunks(PUBLIC_SCOPE)
|
| 1200 |
st.toast(f"已删除 {fname}")
|
|
|
|
| 1243 |
# 同步删除,避免多线程问题
|
| 1244 |
_delete_chunks_by_file(PRIVATE_SCOPE, fname)
|
| 1245 |
_delete_uploaded_file_from_storage(PRIVATE_SCOPE, fname)
|
| 1246 |
+
_list_uploaded_files_db.clear()
|
| 1247 |
# 更新切片数缓存
|
| 1248 |
st.session_state["_sync_count_private"] = _count_chunks(PRIVATE_SCOPE)
|
| 1249 |
st.toast(f"已删除 {fname}")
|