feat(streamlit): 添加重置按钮以准备下一次分析
在单条分析和批量分析界面添加重置按钮,用于清除当前状态并准备下一次测试
This commit is contained in:
parent
0051fe24b7
commit
6959951dd0
2
.gitignore
vendored
2
.gitignore
vendored
@ -28,7 +28,7 @@ logs/
|
||||
*.xlsx
|
||||
*.parquet
|
||||
!data/spam.csv
|
||||
|
||||
!email_data.csv
|
||||
# Streamlit
|
||||
.streamlit/
|
||||
|
||||
|
||||
15
email_data.csv
Normal file
15
email_data.csv
Normal file
@ -0,0 +1,15 @@
|
||||
text
|
||||
"晚上一起吃饭吗?老地方见,我六点下班"
|
||||
"恭喜您获得1000元购物券!点击链接领取:http://prize123.com"
|
||||
"妈,我晚上加班,不用等我吃饭了"
|
||||
"您的快递已放在小区门口快递柜,取件码是3456"
|
||||
"限时特惠!新款手机直降1000元,立即抢购:http://buyphone.com"
|
||||
"明天下午开会,记得带好项目报告"
|
||||
"信用卡账单已出,本期应还款项为1258.36元,还款日25号"
|
||||
"免费领取最新款平板电脑!回复YES即可参与抽奖"
|
||||
"爸,我到北京了,一切顺利,不用担心"
|
||||
"双十一预售开启!全场五折起,快来选购:http://11.11.com"
|
||||
"会议改到明天上午十点,地点不变"
|
||||
"您的话费余额不足,请及时充值以保证正常使用"
|
||||
"恭喜您成为幸运用户!点击链接领取iPhone14:http://gift888.com"
|
||||
"晚上看电影吗?新上映的那部听说不错"
|
||||
|
Binary file not shown.
@ -405,6 +405,19 @@ with col2:
|
||||
|
||||
st.markdown(suggestion_html, unsafe_allow_html=True)
|
||||
|
||||
# 添加重置按钮,准备下一次测试
|
||||
st.markdown("""
|
||||
<div style="margin-top: 20px;">
|
||||
""", unsafe_allow_html=True)
|
||||
|
||||
if st.button("🔄 准备下一条分析", use_container_width=True):
|
||||
# 重置状态,清空输入框并重新运行应用
|
||||
st.session_state.pop("single_result", None) # 如果有存储结果的状态,清除它
|
||||
# 使用空的占位符触发界面重置
|
||||
st.empty()
|
||||
# 重新运行应用以确保完全重置
|
||||
st.experimental_rerun()
|
||||
|
||||
except Exception as e:
|
||||
st.markdown("""
|
||||
<div style="background-color: #0f3460; border: 2px solid #c8102e; border-radius: 8px; padding: 15px; color: #c8102e;">
|
||||
@ -525,6 +538,21 @@ with col2:
|
||||
use_container_width=True
|
||||
)
|
||||
|
||||
# 添加重置按钮,准备下一次测试
|
||||
st.markdown("""
|
||||
<div style="margin-top: 20px;">
|
||||
""", unsafe_allow_html=True)
|
||||
|
||||
if st.button("🔄 准备下一次测试", use_container_width=True):
|
||||
# 重置状态,清除上传文件并重置所有相关状态
|
||||
st.session_state.pop("batch_results", None) # 如果有存储结果的状态,清除它
|
||||
uploaded_file = None # 清除上传文件引用
|
||||
# 使用空的占位符触发界面重置
|
||||
st.empty()
|
||||
# 重新运行应用以确保完全重置
|
||||
st.experimental_rerun()
|
||||
|
||||
|
||||
except Exception as e:
|
||||
st.markdown("""
|
||||
<div style="background-color: #0f3460; border: 2px solid #c8102e; border-radius: 8px; padding: 15px; color: #c8102e;">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user