FlashCode-Lab commited on
Commit
ec42609
·
verified ·
1 Parent(s): 2713c23

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -62
app.py CHANGED
@@ -1,74 +1,45 @@
1
  import streamlit as st
2
- import time
3
 
4
- # 1. 模拟 Windows 窗口配置
5
- st.set_page_config(
6
- page_title="Windows 模拟器",
7
- page_icon="💻",
8
- layout="wide"
9
- )
10
 
11
- # 2. 自定义 CSS 增“软件感” (隐藏网页元素)
12
  st.markdown("""
13
  <style>
14
- #MainMenu {visibility: hidden;}
 
15
  footer {visibility: hidden;}
16
- header {visibility: hidden;}
17
- .stApp {background-color: #f0f2f6;}
18
  </style>
19
- """, unsafe_allow_html=True)
20
 
21
- # 3. 模拟左侧“开始菜单/侧边
22
- with st.sidebar:
23
- st.title("📁 我的电脑")
24
- menu = st.radio(
25
- "导航菜单",
26
- ["桌面首页", "控制面板", "文件管理器", "运行命令"],
27
- index=0
28
- )
29
- st.divider()
30
- st.info("系统状态: 运行中")
31
 
32
- # 4. 根据选择渲染不同的“窗口”内容
33
- if menu == "桌面首页":
34
- st.title("📺 欢迎使用 Python 桌面")
35
- st.write("这是一个运行在 Hugging Face 上的 Python 模拟界面。")
36
-
37
- col1, col2 = st.columns(2)
38
- with col1:
39
- with st.expander("📝 记事本", expanded=True):
40
- note = st.text_area("在此输入笔记...", "Hello World!")
41
- if st.button("保存文件"):
42
- st.toast("文件已成功保存到虚拟磁盘!")
43
-
44
- with col2:
45
- with st.expander("📊 性能监控", expanded=True):
46
- st.write("CPU 使用率")
47
- st.progress(45)
48
- st.write("内存占用")
49
- st.progress(62)
50
 
51
- elif menu == "控制板":
52
- st.subheader("⚙️ 系统设置")
53
- theme = st.selectbox("选择界面主题", ["Windows Classic", "Dark Mode", "Fluent Design"])
54
- volume = st.slider("系统音量", 0, 100, 50)
55
- st.toggle("开启自动更新")
56
 
57
- elif menu == "文件管理器":
58
- st.subheader("📂 磁盘路径: C:/Users/Admin/Documents")
59
- files = {
60
- "文件名": ["report.pdf", "photo.jpg", "app.py", "data.csv"],
61
- "大小": ["1.2MB", "4.5MB", "2KB", "150KB"],
62
- "修改日期": ["2024-01-01", "2024-02-15", "2024-03-20", "2024-04-18"]
63
- }
64
- st.table(files)
65
 
66
- elif menu == "运行命令":
67
- st.subheader("💻 命令提示符 (CMD)")
68
- cmd = st.text_input("C:\Users\Admin>", "")
69
- if cmd:
70
- with st.status("正在执行命令...", expanded=True):
71
- time.sleep(1)
72
- st.write(f"正在检索: {cmd}")
73
- time.sleep(0.5)
74
- st.code(f"Error: '{cmd}' 并非内部或外部命令,也不是可运行的程序。")
 
 
 
 
 
1
  import streamlit as st
 
2
 
3
+ st.set_page_config(page_title="系统控制台", layout="wide")
 
 
 
 
 
4
 
5
+ # 强制深色主题和隐藏多余元素
6
  st.markdown("""
7
  <style>
8
+ .reportview-container { background: #1e1e1e; }
9
+ .stDeployButton {display:none;}
10
  footer {visibility: hidden;}
 
 
11
  </style>
12
+ """, unsafe_allow_html=True)
13
 
14
+ # 顶部状态
15
+ col_t1, col_t2 = st.columns([8, 1])
16
+ with col_t1:
17
+ st.caption("🌐 远程服务器连接成功 | 状态: 正常 | 延迟: 24ms")
18
+ with col_t2:
19
+ if st.button("🔴 注销"):
20
+ st.rerun()
 
 
 
21
 
22
+ st.divider()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
 
24
+ # 主界分区
25
+ left_nav, main_window = st.columns([2, 7])
 
 
 
26
 
27
+ with left_nav:
28
+ st.subheader("📁 系统菜单")
29
+ task = st.selectbox("功能选择", ["运行中心", "安全审计", "终端命令", "网络设置"])
30
+ st.progress(85, text="磁盘剩余空间")
31
+ st.button("🔄 刷新系统")
 
 
 
32
 
33
+ with main_window:
34
+ if task == "运行中心":
35
+ st.header("🚀 自动化任务")
36
+ col_a, col_b = st.columns(2)
37
+ col_a.metric("并发连接", "128", "+12%")
38
+ col_b.metric("内存占用", "1.2 GB", "-5%")
39
+ st.line_chart([10, 25, 15, 40, 30, 60]) # 模拟波动图
40
+
41
+ elif task == "终端命令":
42
+ st.header("💻 系统终端")
43
+ cmd = st.text_input("输入 Python 命令:", "print('Hello Security')")
44
+ if st.button("执行"):
45
+ st.code(f"执行结果: \n>>> {cmd}\nSuccess.")