import React, { useEffect, useState } from 'react'; import { CircularProgressbar, buildStyles } from 'react-circular-progressbar'; import 'react-circular-progressbar/dist/styles.css'; import { SYSTEM_BASE_URL } from "../../constants/system.js"; export default function System() { const [systemInfo, setSystemInfo] = useState(null); useEffect(() => { async function fetchSystemInfo() { const response = await fetch(SYSTEM_BASE_URL); const data = await response.json(); setSystemInfo(data); } const intervalId = setInterval(fetchSystemInfo, 5000); // 每隔5秒更新一次系统信息 return () => clearInterval(intervalId); // 清除定时器,避免内存泄漏 }, []); return (
{/* 状态卡片 */ }

状态

CPU { systemInfo ? `( ${ systemInfo.cpuCoresUsed } / ${ systemInfo.totalCpuCores } ) 核` : "" }
内存 {systemInfo ? `${systemInfo.usedMemory} / ${systemInfo.totalMemory}` : ""}
磁盘使用 {systemInfo ? `${systemInfo.usedDisk} / ${systemInfo.totalDisk}` : ""}
负载
{/* 系统信息卡片 */ }

系统信息

主机名称: {systemInfo ? systemInfo.hostname : ""}

发行版本: {systemInfo ? systemInfo.distro : ""}

内核版本: {systemInfo ? systemInfo.kernelVersion : ""}

系统类型: {systemInfo ? systemInfo.arch : ""}

主机地址: {systemInfo ? systemInfo.ipAddress : ""}

运行时间: {systemInfo ? systemInfo.uptime : ""}

); }