#!/usr/bin/env python3 # -*- coding: utf-8 -*- """统计页面UI精简 - 使用正则替换""" import re with open('/www/wwwroot/zsglpt/templates/admin.html', 'r', encoding='utf-8') as f: content = f.read() # 使用正则找到统计标签页的内容 # 从
).*?(
\s*\n\s*)' new_stats = '''
💻
-
CPU
🧠
-
内存
💾
-
磁盘
🐳
-
容器
⏱️
-
运行

📊 实时监控

● 实时更新
0
🚀 运行中
0
⏳ 排队中
-
⚡ 最大并发
展开查看任务详情
运行中
暂无
排队中
暂无

📈 任务统计

成功任务
0 今日
0 累计
失败任务
0 今日
0 累计
📄 浏览内容
0 今日
0 累计
📎 查看附件
0 今日
0 累计
''' # 使用正则替换 new_content, count = re.subn(pattern, new_stats, content, flags=re.DOTALL) if count > 0: print(f"OK - 成功替换 {count} 处") with open('/www/wwwroot/zsglpt/templates/admin.html', 'w', encoding='utf-8') as f: f.write(new_content) else: print("WARNING - 未找到匹配内容") # 检查文件中是否有tab-stats if 'id="tab-stats"' in content: print("文件中存在 tab-stats") # 找到位置 import re match = re.search(r'
]*>', content) if match: print(f"位置: {match.start()}") print(f"周围内容: {content[match.start():match.start()+200]}")