mirror of
https://github.com/xmanrui/OpenClaw-bot-review.git
synced 2026-08-14 00:47:49 +00:00
- Add /workspace page: Agent grid with real-time status - Add /daily page: Daily report board with TTS playback - Add new API routes: /api/agents, /api/daily - Add new components: agent-card, agent-grid - Add sidebar navigation for new pages - Add i18n labels (zh-CN + en)
51 lines
1.2 KiB
TypeScript
51 lines
1.2 KiB
TypeScript
// components/agent-grid.tsx
|
|
'use client';
|
|
|
|
import { useEffect, useState } from 'react';
|
|
import { AgentCard } from './agent-card';
|
|
import { AgentStatus } from '@/lib/agents';
|
|
|
|
export function AgentGrid() {
|
|
const [agents, setAgents] = useState<AgentStatus[]>([]);
|
|
const [loading, setLoading] = useState(true);
|
|
|
|
useEffect(() => {
|
|
async function fetchAgents() {
|
|
try {
|
|
const res = await fetch('/api/agents');
|
|
const data = await res.json();
|
|
setAgents(data.agents || []);
|
|
} catch (error) {
|
|
console.error('Failed to fetch agents:', error);
|
|
} finally {
|
|
setLoading(false);
|
|
}
|
|
}
|
|
|
|
fetchAgents();
|
|
// 每 10 秒刷新一次
|
|
const interval = setInterval(fetchAgents, 10000);
|
|
return () => clearInterval(interval);
|
|
}, []);
|
|
|
|
if (loading) {
|
|
return <div className="text-center py-8 text-gray-500">加载中...</div>;
|
|
}
|
|
|
|
if (agents.length === 0) {
|
|
return (
|
|
<div className="text-center py-8 text-gray-500">
|
|
暂无 Agent 数据
|
|
</div>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
|
|
{agents.map((agent) => (
|
|
<AgentCard key={agent.id} agent={agent} />
|
|
))}
|
|
</div>
|
|
);
|
|
}
|