2
0
Эх сурвалжийг харах

【新增】添加 CPU 和内存进度条的 title 属性以提升 UI 可读性

为前端模板和 Rust 服务端渲染的进度条元素添加 title 属性,
以便在鼠标悬停时显示具体的百分比或数值信息,增强用户体验。

同时更新版本号至 v0.4.0,新增 README 中的预览图展示,
并完善 HTML 模板中的元数据描述与作者信息。
PJ568 1 жил өмнө
parent
commit
283afe9e8c
7 өөрчлөгдсөн 18 нэмэгдсэн , 13 устгасан
  1. 1 1
      Cargo.lock
  2. 1 1
      Cargo.toml
  3. 2 0
      README.en.md
  4. 2 0
      README.md
  5. BIN
      assets/preview.png
  6. 2 2
      src/server.rs
  7. 10 9
      templates/index.html

+ 1 - 1
Cargo.lock

@@ -942,7 +942,7 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
 
 [[package]]
 name = "swb-sys-monitor"
-version = "0.3.1"
+version = "0.4.0"
 dependencies = [
  "anyhow",
  "clap",

+ 1 - 1
Cargo.toml

@@ -1,6 +1,6 @@
 [package]
 name = "swb-sys-monitor"
-version = "0.3.1"
+version = "0.4.0"
 authors = ["PJ568 <[email protected]>"]
 edition = "2024"
 description = "为嵌入式设备高并发监控场景设计的极简网页资源占用显示系统"

+ 2 - 0
README.en.md

@@ -4,6 +4,8 @@
 
 A minimal resource usage monitoring system designed specifically for embedded device monitoring scenarios. Supports 200+ high-concurrency client connections.
 
+![Preview](assets/preview.png)
+
 ## Features
 
 - **Minimal code implementation**: Pursuing code simplicity and maintainability

+ 2 - 0
README.md

@@ -4,6 +4,8 @@
 
 一个极简的资源占用显示系统,专为嵌入式设备监控场景设计。支持 200+ 高并发客户端访问。
 
+![预览](assets/preview.png)
+
 ## 特性
 
 - **最小最简代码实现**:追求代码简洁性和可维护性;

BIN
assets/preview.png


+ 2 - 2
src/server.rs

@@ -150,8 +150,8 @@ impl StatusServer {
             let mut cores_html = String::from("<fieldset><legend>处理器 - 各核心使用率</legend>");
             for (i, core_stats) in stats.cpu_stats.per_core.iter().enumerate() {
                 cores_html.push_str(&format!(
-                    "<p>核心 {}:<progress value=\"{}\" max=\"100\">{}%</progress></p>",
-                    i, core_stats.total_percent as u32, core_stats.total_percent as u32
+                    "<p>核心 {}:<progress title=\"{}%\" value=\"{}\" max=\"100\">{}%</progress></p>",
+                    i, core_stats.total_percent as u32, core_stats.total_percent as u32, core_stats.total_percent as u32
                 ));
             }
             cores_html.push_str("</fieldset>");

+ 10 - 9
templates/index.html

@@ -2,8 +2,9 @@
 <head lang="zh-Hans-CN">
   <meta charset="UTF-8" />
   <meta name="viewport" content="width=device-width, initial-scale=1.0" />
-  <meta name="description" content="{hostname} 的资源占用" />
+  <meta name="description" content="{hostname} 的资源占用,基于 swaybien/swb-sys-monitor" />
   <meta name="keywords" content="资源占用,效率工具" />
+  <meta name="author" content="swaybien, pj568" />
   <meta http-equiv="refresh" content="10" />
   <link
     rel="icon"
@@ -17,18 +18,18 @@
     <legend>{hostname} 的资源占用</legend>
     <fieldset>
       <legend>处理器</legend>
-      <p>总体使用率:<progress value="{cpu_percent}" max="100">{cpu_percent}%</progress></p>
-      <p>用户态:<progress value="{cpu_user_percent}" max="100">{cpu_user_percent}%</p></progress></p>
-      <p>内核态:<progress value="{cpu_system_percent}" max="100">{cpu_system_percent}%</progress></p>
-      <p>低优先级:<progress value="{cpu_nice_percent}" max="100">{cpu_nice_percent}%</progress></p>
+      <p>总体使用率:<progress title="{cpu_percent}%" value="{cpu_percent}" max="100">{cpu_percent}%</progress></p>
+      <p>用户态:<progress title="{cpu_user_percent}%" value="{cpu_user_percent}" max="100">{cpu_user_percent}%</p></progress></p>
+      <p>内核态:<progress title="{cpu_system_percent}%" value="{cpu_system_percent}" max="100">{cpu_system_percent}%</progress></p>
+      <p>低优先级:<progress title="{cpu_nice_percent}%" value="{cpu_nice_percent}" max="100">{cpu_nice_percent}%</progress></p>
     </fieldset>
     {cpu_cores_section}
     <fieldset>
       <legend>内存</legend>
-      <p>已用:<progress value="{memory_used_mb}" max="{memory_total_mb}">{memory_used_mb}/{memory_total_mb}MB</progress></p>
-      <p>可用:<progress value="{memory_available_mb}" max="{memory_total_mb}">{memory_available_mb}/{memory_total_mb}MB</progress></p>
-      <p>缓存:<progress value="{memory_cached_mb}" max="{memory_total_mb}">{memory_cached_mb}/{memory_total_mb}MB</progress></p>
-      <p>空闲:<progress value="{memory_free_mb}" max="{memory_total_mb}">{memory_free_mb}/{memory_total_mb}MB</progress></p>
+      <p>已用:<progress title="{memory_used_mb}/{memory_total_mb}MB" value="{memory_used_mb}" max="{memory_total_mb}">{memory_used_mb}/{memory_total_mb}MB</progress></p>
+      <p>可用:<progress title="{memory_available_mb}/{memory_total_mb}MB" value="{memory_available_mb}" max="{memory_total_mb}">{memory_available_mb}/{memory_total_mb}MB</progress></p>
+      <p>缓存:<progress title="{memory_cached_mb}/{memory_total_mb}MB" value="{memory_cached_mb}" max="{memory_total_mb}">{memory_cached_mb}/{memory_total_mb}MB</progress></p>
+      <p>空闲:<progress title="{memory_free_mb}/{memory_total_mb}MB" value="{memory_free_mb}" max="{memory_total_mb}">{memory_free_mb}/{memory_total_mb}MB</progress></p>
     </fieldset>
     <fieldset>
       <legend>时间戳</legend>