import type { ReactNode } from 'react'
import { Activity, Cpu, Database, Film, HardDrive, Radio, Users } from 'lucide-react'
import type { Hardware, StatsSnapshot } from '../types'
function fmtBytes(n: number): string {
if (!n || n <= 0) return '—'
const u = ['B', 'KB', 'MB', 'GB', 'TB', 'PB']
let v = n
let i = 0
while (v >= 1024 && i < u.length - 1) {
v /= 1024
i++
}
return `${v.toFixed(2)} ${u[i]}`
}
function fmtHours(seconds: number): string {
if (!seconds || seconds <= 0) return '—'
const h = Math.floor(seconds / 3600)
return `${h.toLocaleString()} h`
}
export function StatsHeader({
generatedAt,
lastMonitorAt,
monitorError,
}: {
generatedAt: string
lastMonitorAt: string
monitorError: string
}) {
return (
聚合快照:{new Date(generatedAt).toLocaleString()} · 实时监控每 2 秒刷新
{monitorError ? '监控重试中' : '实时监控中'}
最近刷新:{lastMonitorAt ? new Date(lastMonitorAt).toLocaleTimeString() : '—'}
实时监控错误:{monitorError}运行状态
系统实时监控
聚合统计
{label}
{value}
{typeof meter === 'number' &&