| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- import streamlit as st
- if "logged_in" not in st.session_state:
- st.session_state.logged_in = False
- def login():
- if st.button("Log in"):
- st.session_state.logged_in = True
- st.rerun()
- def logout():
- if st.button("Log out"):
- st.session_state.logged_in = False
- st.rerun()
- login_page = st.Page(login, title="Log in", icon=":material/login:")
- logout_page = st.Page(logout, title="Log out", icon=":material/logout:")
- dashboard = st.Page(
- "reports/dashboard.py", title="Dashboard", icon=":material/dashboard:", default=True
- )
- bugs = st.Page("reports/data_editor.py", title="Data Editor", icon=":material/edit:")
- alerts = st.Page(
- "reports/table.py", title="测试表格", icon=":material/notification_important:"
- )
- search = st.Page("tools/search.py", title="Search", icon=":material/search:")
- history = st.Page("tools/history.py", title="History", icon=":material/history:")
- if st.session_state.logged_in:
- pg = st.navigation(
- {
- "Account": [logout_page],
- "Reports": [dashboard, bugs, alerts],
- "Tools": [search, history],
- }
- )
- else:
- pg = st.navigation([login_page])
- pg.run()
|