import React, { useState, useEffect } from 'react'; import axios from 'axios'; const API_BASE = 'http://localhost:8000/api'; function Dashboard() { const [lobsters, setLobsters] = useState([]); const [loading, setLoading] = useState(true); useEffect(() => { fetchLobsters(); const interval = setInterval(fetchLobsters, 5000); return () => clearInterval(interval); }, []); const fetchLobsters = async () => { try { const response = await axios.get(`${API_BASE}/lobsters/`); setLobsters(response.data); setLoading(false); } catch (error) { console.error('获取龙虾状态失败:', error); } }; if (loading) { return
专长:{lobster.specialty}
端口:{lobster.port}
容器:{lobster.container}