Files
zsglpt/fix_stats_ui.py
Yu Yon b5344cd55e 修复所有bug并添加新功能
- 修复添加账号按钮无反应问题
- 添加账号备注字段(可选)
- 添加账号设置按钮(修改密码/备注)
- 修复用户反馈���能
- 添加定时任务执行日志
- 修复容器重启后账号加载问题
- 修复所有JavaScript语法错误
- 优化账号加载机制(4层保障)

🤖 Generated with Claude Code
2025-12-10 11:19:16 +08:00

314 lines
22 KiB
Python
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""统计页面UI精简 - 使用可视化图标,合并信息"""
with open('/www/wwwroot/zsglpt/templates/admin.html', 'r', encoding='utf-8') as f:
content = f.read()
# 找到统计标签页的内容,替换为精简版
old_stats_start = '''<div id="tab-stats" class="tab-content">
<h3 style="margin-bottom: 15px; font-size: 16px;">服务器信息</h3>
<div style="display: grid; grid-template-columns: repeat(2, 1fr); gap: 15px; margin-bottom: 25px;">
<div style="background: white; padding: 20px; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.1);">
<div style="font-size: 24px; font-weight: bold; color: #f5576c;" id="serverCpu">-</div>
<div style="font-size: 14px; color: #666; margin-top: 5px;">CPU使用率</div>
</div>
<div style="background: white; padding: 20px; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.1);">
<div style="font-size: 24px; font-weight: bold; color: #f093fb;" id="serverMemory">-</div>
<div style="font-size: 14px; color: #666; margin-top: 5px;">内存使用</div>
</div>
<div style="background: white; padding: 20px; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.1);">
<div style="font-size: 24px; font-weight: bold; color: #764ba2;" id="serverDisk">-</div>
<div style="font-size: 14px; color: #666; margin-top: 5px;">磁盘使用</div>
</div>
<div style="background: white; padding: 20px; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.1);">
<div style="font-size: 24px; font-weight: bold; color: #17a2b8;" id="serverUptime">-</div>
<div style="font-size: 14px; color: #666; margin-top: 5px;">运行时长</div>
</div>
</div>
<h3 style="margin: 25px 0 15px 0; font-size: 16px;">Docker容器状态</h3>
<div style="display: grid; grid-template-columns: repeat(2, 1fr); gap: 15px; margin-bottom: 25px;">
<div style="background: white; padding: 20px; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.1);">
<div style="font-size: 20px; font-weight: bold; color: #28a745;" id="dockerContainerName">-</div>
<div style="font-size: 14px; color: #666; margin-top: 5px;">容器名称</div>
</div>
<div style="background: white; padding: 20px; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.1);">
<div style="font-size: 20px; font-weight: bold; color: #17a2b8;" id="dockerUptime">-</div>
<div style="font-size: 14px; color: #666; margin-top: 5px;">容器运行时间</div>
</div>
<div style="background: white; padding: 20px; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.1);">
<div style="font-size: 20px; font-weight: bold; color: #f093fb;" id="dockerMemory">-</div>
<div style="font-size: 14px; color: #666; margin-top: 5px;">容器内存使用</div>
</div>
<div style="background: white; padding: 20px; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.1);">
<div style="font-size: 20px; font-weight: bold;" id="dockerStatus" style="color: #28a745;">-</div>
<div style="font-size: 14px; color: #666; margin-top: 5px;">运行状态</div>
</div>
</div>
<!-- 实时任务监控 -->
<h3 style="margin: 25px 0 15px 0; font-size: 16px;">实时任务监控 <span id="taskMonitorStatus" style="font-size: 12px; color: #28a745; font-weight: normal;">● 实时更新中</span></h3>
<div style="display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; margin-bottom: 15px;">
<div style="background: white; padding: 15px; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.1); text-align: center;">
<div style="font-size: 28px; font-weight: bold; color: #28a745;" id="runningTaskCount">0</div>
<div style="font-size: 13px; color: #666; margin-top: 5px;">运行中</div>
</div>
<div style="background: white; padding: 15px; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.1); text-align: center;">
<div style="font-size: 28px; font-weight: bold; color: #fd7e14;" id="queuingTaskCount">0</div>
<div style="font-size: 13px; color: #666; margin-top: 5px;">排队中</div>
</div>
<div style="background: white; padding: 15px; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.1); text-align: center;">
<div style="font-size: 28px; font-weight: bold; color: #6c757d;" id="maxConcurrentDisplay">-</div>
<div style="font-size: 13px; color: #666; margin-top: 5px;">最大并发</div>
</div>
</div>
<!-- 运行中的任务列表 -->
<div style="background: white; padding: 15px; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.1); margin-bottom: 15px;">
<div style="font-size: 14px; font-weight: bold; color: #28a745; margin-bottom: 10px;">🚀 运行中的任务</div>
<div id="runningTasksList" style="font-size: 13px;">
<div style="color: #999; text-align: center; padding: 10px;">暂无运行中的任务</div>
</div>
</div>
<!-- 排队中的任务列表 -->
<div style="background: white; padding: 15px; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.1); margin-bottom: 25px;">
<div style="font-size: 14px; font-weight: bold; color: #fd7e14; margin-bottom: 10px;">⏳ 排队中的任务</div>
<div id="queuingTasksList" style="font-size: 13px;">
<div style="color: #999; text-align: center; padding: 10px;">暂无排队中的任务</div>
</div>
</div>
<h3 style="margin: 25px 0 15px 0; font-size: 16px;">当日任务统计</h3>
<div style="display: grid; grid-template-columns: repeat(2, 1fr); gap: 15px; margin-bottom: 25px;">
<div style="background: white; padding: 20px; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.1);">
<div style="font-size: 32px; font-weight: bold; color: #28a745;" id="todaySuccessTasks">0</div>
<div style="font-size: 14px; color: #666; margin-top: 5px;">成功任务</div>
</div>
<div style="background: white; padding: 20px; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.1);">
<div style="font-size: 32px; font-weight: bold; color: #dc3545;" id="todayFailedTasks">0</div>
<div style="font-size: 14px; color: #666; margin-top: 5px;">失败任务</div>
</div>
<div style="background: white; padding: 20px; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.1);">
<div style="font-size: 32px; font-weight: bold; color: #007bff;" id="todayTotalItems">0</div>
<div style="font-size: 14px; color: #666; margin-top: 5px;">浏览内容数</div>
</div>
<div style="background: white; padding: 20px; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.1);">
<div style="font-size: 32px; font-weight: bold; color: #17a2b8;" id="todayTotalAttachments">0</div>
<div style="font-size: 14px; color: #666; margin-top: 5px;">查看附件数</div>
</div>
</div>
<h3 style="margin: 25px 0 15px 0; font-size: 16px;">历史累计统计</h3>
<div style="display: grid; grid-template-columns: repeat(2, 1fr); gap: 15px;">
<div style="background: white; padding: 20px; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.1);">
<div style="font-size: 32px; font-weight: bold; color: #28a745;" id="totalSuccessTasks">0</div>
<div style="font-size: 14px; color: #666; margin-top: 5px;">累计成功任务</div>
</div>
<div style="background: white; padding: 20px; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.1);">
<div style="font-size: 32px; font-weight: bold; color: #dc3545;" id="totalFailedTasks">0</div>
<div style="font-size: 14px; color: #666; margin-top: 5px;">累计失败任务</div>
</div>
<div style="background: white; padding: 20px; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.1);">
<div style="font-size: 32px; font-weight: bold; color: #007bff;" id="totalTotalItems">0</div>
<div style="font-size: 14px; color: #666; margin-top: 5px;">累计浏览内容</div>
</div>
<div style="background: white; padding: 20px; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.1);">
<div style="font-size: 32px; font-weight: bold; color: #17a2b8;" id="totalTotalAttachments">0</div>
<div style="font-size: 14px; color: #666; margin-top: 5px;">累计查看附件</div>
</div>
</div>
</div>'''
new_stats = '''<div id="tab-stats" class="tab-content">
<!-- 系统状态概览 - 精简合并版 -->
<div style="background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); border-radius: 12px; padding: 20px; margin-bottom: 20px; color: white;">
<div style="display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 15px;">
<div style="display: flex; align-items: center; gap: 10px;">
<span style="font-size: 24px;">💻</span>
<div>
<div style="font-size: 20px; font-weight: bold;" id="serverCpu">-</div>
<div style="font-size: 12px; opacity: 0.8;">CPU</div>
</div>
</div>
<div style="display: flex; align-items: center; gap: 10px;">
<span style="font-size: 24px;">🧠</span>
<div>
<div style="font-size: 20px; font-weight: bold;" id="serverMemory">-</div>
<div style="font-size: 12px; opacity: 0.8;">内存</div>
</div>
</div>
<div style="display: flex; align-items: center; gap: 10px;">
<span style="font-size: 24px;">💾</span>
<div>
<div style="font-size: 20px; font-weight: bold;" id="serverDisk">-</div>
<div style="font-size: 12px; opacity: 0.8;">磁盘</div>
</div>
</div>
<div style="display: flex; align-items: center; gap: 10px;">
<span style="font-size: 24px;">🐳</span>
<div>
<div style="font-size: 20px; font-weight: bold;" id="dockerMemory">-</div>
<div style="font-size: 12px; opacity: 0.8;">容器</div>
</div>
</div>
<div style="display: flex; align-items: center; gap: 10px;">
<span style="font-size: 24px;">⏱️</span>
<div>
<div style="font-size: 20px; font-weight: bold;" id="serverUptime">-</div>
<div style="font-size: 12px; opacity: 0.8;">运行</div>
</div>
</div>
</div>
</div>
<!-- 隐藏的元素保持JS兼容性 -->
<div style="display:none;">
<span id="dockerContainerName"></span>
<span id="dockerUptime"></span>
<span id="dockerStatus"></span>
</div>
<!-- 实时任务监控 -->
<div style="background: white; border-radius: 12px; padding: 20px; margin-bottom: 20px; box-shadow: 0 2px 12px rgba(0,0,0,0.08);">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px;">
<h3 style="margin: 0; font-size: 16px; display: flex; align-items: center; gap: 8px;">
<span>📊</span> 实时监控
</h3>
<span id="taskMonitorStatus" style="font-size: 12px; color: #28a745;">● 实时更新</span>
</div>
<div style="display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; margin-bottom: 15px;">
<div style="background: linear-gradient(135deg, #28a745 0%, #20c997 100%); padding: 15px; border-radius: 10px; text-align: center; color: white;">
<div style="font-size: 32px; font-weight: bold;" id="runningTaskCount">0</div>
<div style="font-size: 12px; opacity: 0.9; margin-top: 3px;">🚀 运行中</div>
</div>
<div style="background: linear-gradient(135deg, #fd7e14 0%, #ffc107 100%); padding: 15px; border-radius: 10px; text-align: center; color: white;">
<div style="font-size: 32px; font-weight: bold;" id="queuingTaskCount">0</div>
<div style="font-size: 12px; opacity: 0.9; margin-top: 3px;">⏳ 排队中</div>
</div>
<div style="background: linear-gradient(135deg, #6c757d 0%, #495057 100%); padding: 15px; border-radius: 10px; text-align: center; color: white;">
<div style="font-size: 32px; font-weight: bold;" id="maxConcurrentDisplay">-</div>
<div style="font-size: 12px; opacity: 0.9; margin-top: 3px;">⚡ 最大并发</div>
</div>
</div>
<!-- 任务列表(折叠式) -->
<details style="margin-top: 10px;">
<summary style="cursor: pointer; font-size: 13px; color: #666; padding: 8px 0;">展开查看任务详情</summary>
<div style="margin-top: 10px; padding: 10px; background: #f8f9fa; border-radius: 8px;">
<div style="font-size: 13px; font-weight: bold; color: #28a745; margin-bottom: 8px;">运行中</div>
<div id="runningTasksList" style="font-size: 12px; margin-bottom: 10px;">
<div style="color: #999;">暂无</div>
</div>
<div style="font-size: 13px; font-weight: bold; color: #fd7e14; margin-bottom: 8px;">排队中</div>
<div id="queuingTasksList" style="font-size: 12px;">
<div style="color: #999;">暂无</div>
</div>
</div>
</details>
</div>
<!-- 任务统计 - 合并当日和累计 -->
<div style="background: white; border-radius: 12px; padding: 20px; box-shadow: 0 2px 12px rgba(0,0,0,0.08);">
<h3 style="margin: 0 0 15px 0; font-size: 16px; display: flex; align-items: center; gap: 8px;">
<span>📈</span> 任务统计
</h3>
<div style="display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px;">
<!-- 成功任务 -->
<div style="background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%); padding: 15px; border-radius: 10px;">
<div style="display: flex; align-items: center; gap: 10px; margin-bottom: 8px;">
<span style="font-size: 20px;">✅</span>
<span style="font-size: 13px; color: #155724; font-weight: bold;">成功任务</span>
</div>
<div style="display: flex; justify-content: space-between; align-items: baseline;">
<div>
<span style="font-size: 28px; font-weight: bold; color: #155724;" id="todaySuccessTasks">0</span>
<span style="font-size: 12px; color: #155724;">今日</span>
</div>
<div style="text-align: right;">
<span style="font-size: 16px; color: #28a745;" id="totalSuccessTasks">0</span>
<span style="font-size: 11px; color: #666;">累计</span>
</div>
</div>
</div>
<!-- 失败任务 -->
<div style="background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%); padding: 15px; border-radius: 10px;">
<div style="display: flex; align-items: center; gap: 10px; margin-bottom: 8px;">
<span style="font-size: 20px;">❌</span>
<span style="font-size: 13px; color: #721c24; font-weight: bold;">失败任务</span>
</div>
<div style="display: flex; justify-content: space-between; align-items: baseline;">
<div>
<span style="font-size: 28px; font-weight: bold; color: #721c24;" id="todayFailedTasks">0</span>
<span style="font-size: 12px; color: #721c24;">今日</span>
</div>
<div style="text-align: right;">
<span style="font-size: 16px; color: #dc3545;" id="totalFailedTasks">0</span>
<span style="font-size: 11px; color: #666;">累计</span>
</div>
</div>
</div>
<!-- 浏览内容 -->
<div style="background: linear-gradient(135deg, #cce5ff 0%, #b8daff 100%); padding: 15px; border-radius: 10px;">
<div style="display: flex; align-items: center; gap: 10px; margin-bottom: 8px;">
<span style="font-size: 20px;">📄</span>
<span style="font-size: 13px; color: #004085; font-weight: bold;">浏览内容</span>
</div>
<div style="display: flex; justify-content: space-between; align-items: baseline;">
<div>
<span style="font-size: 28px; font-weight: bold; color: #004085;" id="todayTotalItems">0</span>
<span style="font-size: 12px; color: #004085;">今日</span>
</div>
<div style="text-align: right;">
<span style="font-size: 16px; color: #007bff;" id="totalTotalItems">0</span>
<span style="font-size: 11px; color: #666;">累计</span>
</div>
</div>
</div>
<!-- 查看附件 -->
<div style="background: linear-gradient(135deg, #d1ecf1 0%, #bee5eb 100%); padding: 15px; border-radius: 10px;">
<div style="display: flex; align-items: center; gap: 10px; margin-bottom: 8px;">
<span style="font-size: 20px;">📎</span>
<span style="font-size: 13px; color: #0c5460; font-weight: bold;">查看附件</span>
</div>
<div style="display: flex; justify-content: space-between; align-items: baseline;">
<div>
<span style="font-size: 28px; font-weight: bold; color: #0c5460;" id="todayTotalAttachments">0</span>
<span style="font-size: 12px; color: #0c5460;">今日</span>
</div>
<div style="text-align: right;">
<span style="font-size: 16px; color: #17a2b8;" id="totalTotalAttachments">0</span>
<span style="font-size: 11px; color: #666;">累计</span>
</div>
</div>
</div>
</div>
</div>
</div>'''
if old_stats_start in content:
content = content.replace(old_stats_start, new_stats)
print("OK - 统计页面已更新为精简可视化版本")
else:
print("WARNING - 未找到原始统计页面内容")
# 尝试找到部分匹配
if '<div id="tab-stats" class="tab-content">' in content:
print("找到tab-stats开始标签但完整内容不匹配")
with open('/www/wwwroot/zsglpt/templates/admin.html', 'w', encoding='utf-8') as f:
f.write(content)
print("完成")