From 81ebbc3e45d1041f24b4984727def9c77e0c7ba4 Mon Sep 17 00:00:00 2001 From: qinglong Date: Sat, 13 Jun 2026 18:21:05 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20WebUI=20=E9=A6=96=E9=A1=B5=E4=BB=AA?= =?UTF-8?q?=E8=A1=A8=E7=9B=98=20=E2=80=94=20CPU/MEM/=E8=BF=9B=E7=A8=8B?= =?UTF-8?q?=E5=86=85=E5=AD=98=20=E6=95=B0=E5=AD=97=E8=B7=B3=E5=8A=A8?= =?UTF-8?q?=E5=8A=A8=E7=94=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - animateNumber(): 900ms ease-out 缓动, 存储前值于 data-val - CPU%、MEM%、进程内存 三个指标使用跳动动画 - 与 Sentinel 卡片动画风格统一 Co-Authored-By: Claude --- config/permissions/pending_requests.json | 22 ++++++++++++++++++++++ config/plugins/commands.yaml | 2 +- config/services/network_routes.yaml | 2 +- static/web_panel/pages/dashboard.js | 22 +++++++++++++++++++--- 4 files changed, 43 insertions(+), 5 deletions(-) diff --git a/config/permissions/pending_requests.json b/config/permissions/pending_requests.json index 8a1f80d..54c98f8 100644 --- a/config/permissions/pending_requests.json +++ b/config/permissions/pending_requests.json @@ -284,5 +284,27 @@ "framework.command.execute" ], "timestamp": 27821.239961313 + }, + "2ae8c213": { + "plugin_name": "example_plugin", + "permissions": [ + "plugin.example.read", + "plugin.example.write", + "plugin.example.execute", + "framework.event.subscribe", + "framework.command.execute" + ], + "timestamp": 27941.293164548 + }, + "dd24f0d1": { + "plugin_name": "sentinel", + "permissions": [ + "plugin.sentinel.read", + "plugin.sentinel.write", + "plugin.network.access", + "framework.event.subscribe", + "framework.command.execute" + ], + "timestamp": 27941.297902882 } } \ No newline at end of file diff --git a/config/plugins/commands.yaml b/config/plugins/commands.yaml index 56bd955..0d4a60b 100644 --- a/config/plugins/commands.yaml +++ b/config/plugins/commands.yaml @@ -101,7 +101,7 @@ commands: permissions: - framework.command.test source: internal -last_updated: 27821.221132094 +last_updated: 27941.282839757 plugin_commands: example_plugin: echo: *id001 diff --git a/config/services/network_routes.yaml b/config/services/network_routes.yaml index b8d4dd2..c81ec75 100644 --- a/config/services/network_routes.yaml +++ b/config/services/network_routes.yaml @@ -1,5 +1,5 @@ http_port: 4200 -last_updated: 27821.238246209 +last_updated: 27941.295580277 plugin_routes: example_plugin: - methods: diff --git a/static/web_panel/pages/dashboard.js b/static/web_panel/pages/dashboard.js index 27bcfb7..39e6b75 100644 --- a/static/web_panel/pages/dashboard.js +++ b/static/web_panel/pages/dashboard.js @@ -1,3 +1,19 @@ +/* ── 数字跳动动画 ── */ +function animateNumber(el, newVal, decimals, suffix) { + var oldVal = parseFloat(el.getAttribute('data-val') || newVal); + if (oldVal === newVal) { el.textContent = newVal.toFixed(decimals) + suffix; return; } + el.setAttribute('data-val', newVal); + var start = performance.now(); + var duration = 900; + function step(ts) { + var p = Math.min((ts - start) / duration, 1); + var eased = 1 - Math.pow(1 - p, 3); // ease-out + el.textContent = (oldVal + (newVal - oldVal) * eased).toFixed(decimals) + suffix; + if (p < 1) requestAnimationFrame(step); + } + requestAnimationFrame(step); +} + window.DashboardModule = { ws: null, reconnectTimer: null, @@ -73,7 +89,7 @@ window.DashboardModule = { // ── 内存 ── if (sys.memory) { var m = sys.memory.percent || 0; - var el = document.getElementById('d-mem'); if (el) el.textContent = m + '%'; + var el = document.getElementById('d-mem'); if (el) animateNumber(el, m, 1, '%'); el = document.getElementById('d-mem-detail'); if (el) el.textContent = (sys.memory.used_gb || 0).toFixed(1) + ' / ' + (sys.memory.total_gb || 0).toFixed(1) + ' GB'; self.charts.mem.update(m); @@ -86,7 +102,7 @@ window.DashboardModule = { var load = (sys.cpu.load_avg && sys.cpu.load_avg[0]) ? sys.cpu.load_avg[0] : 0; cpuVal = Math.min(100, (load / (sys.cpu.cores || 1)) * 100); } - var el = document.getElementById('d-cpu'); if (el) el.textContent = Math.round(cpuVal) + '%'; + var el = document.getElementById('d-cpu'); if (el) animateNumber(el, cpuVal, 0, '%'); self.charts.cpu.update(cpuVal); if (sys.cpu.load_avg) { @@ -117,7 +133,7 @@ window.DashboardModule = { // ── 进程内存 ── if (sys.process && sys.process.memory_mb !== undefined) { var pm = sys.process.memory_mb || 0; - var el = document.getElementById('d-proc-mem'); if (el) el.textContent = pm + ' MB'; + var el = document.getElementById('d-proc-mem'); if (el) animateNumber(el, pm, 1, ' MB'); self.charts.proc_mem.update(pm); } if (sys.process && sys.process.pid !== undefined) {