From ddc20bc49fa725403c63b285da554d5dbbc91a27 Mon Sep 17 00:00:00 2001 From: liuwei Date: Wed, 2 Apr 2025 14:32:54 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E7=8A=B6=E6=80=81=E7=9A=84?= =?UTF-8?q?=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/dashboard/templates/index.html | 66 +++++----------------------- 1 file changed, 10 insertions(+), 56 deletions(-) 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 => {