import React, { useEffect, useState } from "react"; import { NETWORK_BASE_URL } from "../../constants/system.js"; export function BotNetwork() { const [linksTime, setLinksTime] = useState(['0 ms', '0 ms', '0 ms', '0 ms']); useEffect(() => { const waitingForTestingLink = [ "https://kimi.moonshot.cn/", "https://github.com/", "https://youtube.com/", "https://www.google.com/" ] async function getNetwork() { for (const value of waitingForTestingLink) { const index = waitingForTestingLink.indexOf(value); const response = await fetch(NETWORK_BASE_URL + value); let tmp = linksTime; tmp[index] = `${ (await response.json()).time }ms`; setLinksTime(tmp); } } // 每隔10秒更新一次系统信息 // const intervalId = setInterval(getNetwork, 10000); // // // 清除定时器,避免内存泄漏 // return () => clearInterval(intervalId); }, []); return (