diff --git a/packages/webui/src/components/pages/overview-page.tsx b/packages/webui/src/components/pages/overview-page.tsx index 008df0ef..7332d06a 100644 --- a/packages/webui/src/components/pages/overview-page.tsx +++ b/packages/webui/src/components/pages/overview-page.tsx @@ -1,9 +1,9 @@ -import { useEffect, useMemo, useState, type ReactNode } from 'react'; +import { useEffect, useId, useMemo, useState, type ReactNode } from 'react'; import { motion, Reorder } from 'motion/react'; import { Link } from '@tanstack/react-router'; import { Activity, ArrowRight, Bell, Cable, Check, Cpu, ExternalLink, Eye, EyeOff, GripVertical, - LayoutGrid, MemoryStick, MonitorCog, Pencil, Plus, PlugZap, RefreshCw, RotateCcw, Server, + Info, LayoutGrid, MemoryStick, MonitorCog, Pencil, Plus, PlugZap, RefreshCw, RotateCcw, Server, Settings2, Users, } from 'lucide-react'; import { Button } from '@/components/ui/button'; @@ -380,6 +380,65 @@ function DropPlaceholder({ onAdd }: { onAdd: (id: string, x: number, y: number) // ─────────────── stat tiles (one widget each) ─────────────── +function StatTileDetails({ + label, + details, + children, +}: { + label: string; + details: string; + children: ReactNode; +}) { + const [open, setOpen] = useState(false); + const [pinned, setPinned] = useState(false); + const detailsId = useId(); + const dismiss = () => { + setPinned(false); + setOpen(false); + }; + return ( + { + if (next || !pinned) setOpen(next); + }} + > + +
+ {children} + + {details} +
+
+ + {details} + +
+ ); +} + function shortDistro(distro: string): string { let s = distro; s = s.replace(/^Debian GNU\/Linux /, 'Debian '); @@ -409,15 +468,23 @@ function shortDistro(distro: string): string { } function StatTile({ - icon, label, value, subtext, accent = false, to, + icon, label, value, subtext, details, accent = false, to, }: { icon: ReactNode; label: string; value: ReactNode; subtext?: ReactNode; + details?: string; accent?: boolean; to?: AppPath; }) { + const copy = ( + <> +

{label}

+
{value}
+ {subtext &&

{subtext}

} + + ); const body = (
{icon}
-
-

{label}

-
{value}
- {subtext &&

{subtext}

} -
+ {details ? ( + {copy} + ) : ( +
{copy}
+ )} {to && }
); @@ -484,24 +551,36 @@ function StatTileWidget({ id }: { id: string }) { /> ); } - case 'stat:host': + case 'stat:host': { + const value = systemInfo?.hostname ?? '—'; + const subtext = systemInfo ? `${shortDistro(systemInfo.distro)} · ${systemInfo.archLabel}` : '加载中'; return ( } label="主机名" - value={systemInfo?.hostname ?? '—'} - subtext={systemInfo ? {shortDistro(systemInfo.distro)} · {systemInfo.archLabel}{systemInfo.distro} · {systemInfo.archLabel} : '加载中'} + value={value} + subtext={subtext} + details={systemInfo + ? `主机名:${systemInfo.hostname}\n系统:${systemInfo.distro} · ${systemInfo.archLabel}` + : undefined} /> ); - case 'stat:uptime': + } + case 'stat:uptime': { + const systemUptime = systemInfo ? formatUptime(systemInfo.uptime) : '—'; + const processUptime = systemInfo ? formatUptime(systemInfo.processUptime) : undefined; return ( } label="系统运行" - value={systemInfo ? formatUptime(systemInfo.uptime) : '—'} - subtext={systemInfo ? `进程 ${formatUptime(systemInfo.processUptime)}` : undefined} + value={systemUptime} + subtext={processUptime ? `进程 ${processUptime}` : undefined} + details={processUptime + ? `系统运行:${systemUptime}\nSnowLuma 进程:${processUptime}` + : undefined} /> ); + } default: return null; }