"use client"; import { useEffect, useState } from "react"; import { RefreshCcw, ShieldCheck, Database, Cpu, HardDrive } from "lucide-react"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { opsApi } from "@/lib/ops-api"; import type { SystemStatusPayload, HealthPayload } from "@/types/ops"; export function SystemPageClient() { const [loading, setLoading] = useState(true); const [health, setHealth] = useState(null); const [status, setStatus] = useState(null); const [error, setError] = useState(""); const load = async () => { setLoading(true); setError(""); try { const [h, s] = await Promise.all([ opsApi.health(), opsApi.systemStatus() as Promise, ]); setHealth(h); setStatus(s); } catch (e) { setError(String(e).slice(0, 200)); } finally { setLoading(false); } }; useEffect(() => { void load(); }, []); if (loading) { return
加载中...
; } if (error) { return
加载失败: {error}
; } const dbOk = status?.db?.ok ?? health?.db?.ok; const cacheAnalysis = status?.cache?.analysis; return (

系统状态

{/* Health badges */}
Health
{health?.status ?? "—"}
Database
{dbOk ? "OK" : "FAIL"}
存储模式
{status?.state_storage_mode ?? "—"}
概率引擎
{status?.probability?.engine_mode ?? "—"}
{/* Features & Integrations */}
功能开关
{status?.features ? Object.entries(status.features).map(([k, v]) => (
{k} {String(v)}
)) : 无数据}
集成状态
{status?.integrations ? Object.entries(status.integrations).map(([k, v]) => (
{k} {String(v)}
)) : 无数据}
{/* Cache Analysis */} {cacheAnalysis ? ( 缓存分析
总请求
{cacheAnalysis.total_requests ?? 0}
命中
{cacheAnalysis.cache_hits ?? 0}
未命中
{cacheAnalysis.cache_misses ?? 0}
命中率
{cacheAnalysis.hit_rate != null ? `${(cacheAnalysis.hit_rate * 100).toFixed(0)}%` : "—"}
) : null} {/* DB Path */} {status?.db?.db_path ? ( 数据库路径 {status.db.db_path} ) : null}
); }