'use client'; import React, { useEffect, useState } from 'react'; import { CheckCircle2, XCircle, AlertCircle, RefreshCw, Server, Cpu, Radio, Key, Loader2, } from 'lucide-react'; import { getStatus, restartSystem } from '@/lib/api'; import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, } from '@/components/ui/alert-dialog'; import { Button } from '@/components/ui/button'; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; import { Badge } from '@/components/ui/badge'; import type { SystemStatus } from '@/types'; export default function StatusPage() { const [status, setStatus] = useState(null); const [error, setError] = useState(null); const [loading, setLoading] = useState(true); const [restartDialogOpen, setRestartDialogOpen] = useState(false); const [restarting, setRestarting] = useState(false); const [restartError, setRestartError] = useState(null); const loadStatus = async () => { setLoading(true); setError(null); try { const data = await getStatus(); setStatus(data); } catch (err: any) { setError(err.message || '连接后端失败'); } finally { setLoading(false); } }; useEffect(() => { loadStatus(); }, []); useEffect(() => { if (!restarting) { return; } const intervalId = window.setInterval(async () => { try { await getStatus(); window.location.reload(); } catch { // Ignore failures until the container is back. } }, 3000); return () => { window.clearInterval(intervalId); }; }, [restarting]); const handleRestart = async () => { setRestartError(null); try { await restartSystem(); setRestartDialogOpen(false); setRestarting(true); } catch (err: any) { setRestartError(err.message || '重启失败'); } }; if (loading) { return (
); } if (error) { return (

无法连接到 Boardware Agent Sandbox 后端

{error}

请确认后端服务已启动,并且当前页面可以访问它。

); } if (!status) return null; return (

系统状态

{/* System Info */} 系统信息

重启当前实例

{restarting ? '正在重启当前 docker,服务恢复后页面会自动刷新。' : '会重启当前 docker 容器。重启完成后需要重新登录。'}

{restartError ? (

{restartError}

) : null}
确认重启当前实例? 这会重启当前 docker 容器,页面会短暂不可用。由于当前登录态保存在内存里,重启完成后需要重新登录。 取消 {restarting ? '重启中...' : '确认 Restart'}
{/* Model Config */} 智能体配置 {/* Providers */} 提供商
{status.providers.map((p) => (
{p.has_key ? ( ) : ( )} {p.name} {p.detail && ( {p.detail} )}
))}
{/* Channels */} 通道
{status.channels.map((ch) => (
{ch.enabled ? '开启' : '关闭'} {ch.name}
))}
{/* Cron Summary */} 调度器
); } function InfoRow({ label, value, ok, }: { label: string; value: string; ok?: boolean; }) { return (
{label}
{value} {ok !== undefined && (ok ? ( ) : ( ))}
); }