diff --git a/server/components/home/bot-item.jsx b/server/components/home/bot-item.jsx index 6855f40..cb55d9b 100644 --- a/server/components/home/bot-item.jsx +++ b/server/components/home/bot-item.jsx @@ -4,40 +4,59 @@ import { BOT_INFO_URL } from "../../constants/api.js"; export function BotItem() { const [user, setUser] = useState(null); + const [isLoading, setIsLoading] = useState(false); + + const fetchBotInfo = async () => { + setIsLoading(true); + try { + const response = await fetch(BOT_INFO_URL); + const data = await response.json(); + setUser(data); + } catch (error) { + console.error("获取机器人信息失败:", error); + } finally { + setIsLoading(false); + } + }; useEffect(() => { - fetch(BOT_INFO_URL) - .then(response => { - return response.json(); - }) - .then(data => setUser(data)) + fetchBotInfo(); }, []); return (