feat: 实现仪表盘页面及系统信息采集功能

新增系统信息采集后端服务,引入 sysinfo 依赖获取 CPU、内存、主机名、系统版本、架构和 IP 地址等数据;新增系统相关 API 接口和 TypeScript 类型定义;重构仪表盘页面,整合服务器/隧道数量统计、系统信息展示、资源占用监控和 Frpc 运行日志功能;新增中英文国际化文案支持,完善前端交互逻辑。
This commit is contained in:
Yuhang Wu
2026-10-13 15:56:05 +08:00
parent 487bde5473
commit 50bf5f7e36
16 changed files with 661 additions and 27 deletions
+9 -16
View File
@@ -1,16 +1,11 @@
import { invoke } from "@tauri-apps/api/core"
import { getSystemInfo } from "@/api/system"
import { isTauri } from "@/utils/window"
interface SystemInfo {
cpu: number
memory: number
}
/**
* 系统资源占用(CPU / 内存 百分比)。
*
* 优先调用后端命令 `get_system_info`(返回 { cpu, memory }),
* 后端尚未实现时回退到模拟数据,保证界面可用。
* 调用后端命令 `get_system_info`(返回 `ApiResponse<{ cpu, memory }>`),
* 在非 Tauri 环境或后端不可用时回退到模拟数据,保证界面可用。
*/
export function useSystemStats(interval = 2000) {
const cpu = ref(0)
@@ -31,15 +26,13 @@ export function useSystemStats(interval = 2000) {
async function refresh() {
if (isTauri()) {
try {
const res = await invoke<SystemInfo>("get_system_info")
if (res) {
cpu.value = Math.round(res.cpu)
memory.value = Math.round(res.memory)
isMock.value = false
return
}
const info = await getSystemInfo()
cpu.value = Math.round(info.cpu)
memory.value = Math.round(info.memory)
isMock.value = false
return
} catch {
// 后端命令未实现,回退到模拟数据
// 后端命令不可用,回退到模拟数据
}
}
mock()