diff --git a/admin/dashboard/templates/index.html b/admin/dashboard/templates/index.html
index a8a9376..c3f40a5 100644
--- a/admin/dashboard/templates/index.html
+++ b/admin/dashboard/templates/index.html
@@ -280,67 +280,21 @@
console.error('加载系统信息出错:', error);
});
},
- // 更新系统信息UI
- updateSystemInfoUI() {
- // 更新系统信息显示
- document.getElementById('system-os').textContent =
- `${this.systemInfo.os} ${this.systemInfo.os_version}`;
- document.getElementById('system-python').textContent =
- this.systemInfo.python_version;
- document.getElementById('system-uptime').textContent =
- this.formatUptime(this.systemInfo.uptime);
-
- // 更新资源使用率
- document.getElementById('system-cpu').textContent =
- `${this.systemInfo.cpu_usage}%`;
- document.getElementById('system-memory').textContent =
- `${this.systemInfo.memory_usage}%`;
- document.getElementById('system-disk').textContent =
- `${this.systemInfo.disk_usage}%`;
-
- // 更新进度条
- document.getElementById('cpu-progress').style.width =
- `${this.systemInfo.cpu_usage}%`;
- document.getElementById('memory-progress').style.width =
- `${this.systemInfo.memory_usage}%`;
- document.getElementById('disk-progress').style.width =
- `${this.systemInfo.disk_usage}%`;
-
- // 设置进度条颜色
- this.setProgressColor('cpu-progress', this.systemInfo.cpu_usage);
- this.setProgressColor('memory-progress', this.systemInfo.memory_usage);
- this.setProgressColor('disk-progress', this.systemInfo.disk_usage);
-
- // 更新时间戳
- document.getElementById('system-update-time').textContent =
- `最后更新: ${this.systemInfo.timestamp}`;
- },
- // 设置进度条颜色
- setProgressColor(elementId, value) {
- const element = document.getElementById(elementId);
- element.classList.remove('bg-success', 'bg-warning', 'bg-danger');
-
+ // 添加获取进度条状态的方法
+ getProgressStatus(value) {
if (value > 70) {
- element.classList.add('bg-danger'); // 红色 (高负载)
+ return 'exception'; // 红色 (高负载)
} else if (value > 50) {
- element.classList.add('bg-warning'); // 黄色 (中等负载)
+ return 'warning'; // 黄色 (中等负载)
} else {
- element.classList.add('bg-success'); // 绿色 (低负载)
+ return 'success'; // 绿色 (低负载)
}
},
- // 格式化运行时间
- formatUptime(seconds) {
- const days = Math.floor(seconds / 86400);
- const hours = Math.floor((seconds % 86400) / 3600);
- const minutes = Math.floor((seconds % 3600) / 60);
-
- let result = '';
- if (days > 0) result += days + '天 ';
- if (hours > 0 || days > 0) result += hours + '小时 ';
- result += minutes + '分钟';
-
- return result;
- },
+ // 删除不再使用的方法
+ // updateSystemInfoUI() { ... },
+ // setProgressColor() { ... },
+ // formatUptime() { ... },
+
loadDashboardSummary(days) {
axios.get(`/api/dashboard_summary?days=${days}`)
.then(response => {