"use client"; import { useCallback, useEffect, useState } from "react"; import Link from "next/link"; import { Activity, HardDrive, Loader2, RefreshCw } from "lucide-react"; import { Shell } from "@/components/Shell"; import { useToast } from "@/components/Toast"; import { fetchJson } from "@/lib/api"; type Health = { monitor?: { running?: boolean; live_count?: number }; shorts?: { enabled?: boolean; last_error?: string }; tiktok?: { enabled?: boolean }; yt_long?: { enabled?: boolean }; }; type Metrics = { disk_free_gb?: number; shorts_quota_gap?: number; yt_long_upload_gap?: number; tiktok_daily_gap?: number; failed_jobs?: number; }; export default function OpsMobilePage() { const toast = useToast(); const [health, setHealth] = useState({}); const [metrics, setMetrics] = useState({}); const [loading, setLoading] = useState(true); const load = useCallback(async () => { setLoading(true); try { const [h, m] = await Promise.all([ fetchJson("/api/health?detail=1"), fetchJson("/api/ops/alerts/metrics"), ]); setHealth(h as Health); setMetrics(m as Metrics); } catch (e) { toast.push((e as Error).message, "err"); } finally { setLoading(false); } }, [toast]); useEffect(() => { void load(); const t = setInterval(() => { if (document.hidden) return; void load(); }, 30000); const onVis = () => { if (!document.hidden) void load(); }; document.addEventListener("visibilitychange", onVis); return () => { clearInterval(t); document.removeEventListener("visibilitychange", onVis); }; }, [load]); return (

运维速览

} label="抖音在播" value={String(health.monitor?.live_count ?? "—")} /> } label="磁盘 GB" value={metrics.disk_free_gb?.toFixed(1) ?? "—"} />
监控:{health.monitor?.running ? "运行中" : "已停"}
Shorts:{health.shorts?.enabled ? "开" : "关"}
TikTok:{health.tiktok?.enabled ? "开" : "关"}
长视频:{health.yt_long?.enabled ? "开" : "关"}
任务看板 YouTube 健康 完整运维页
); } function Card({ icon, label, value, }: { icon?: React.ReactNode; label: string; value: string; }) { return (
{icon} {label}
{value}
); }