From 2a6fb97a43f188bc9cd5ed0ba5f96dd73c05a1b1 Mon Sep 17 00:00:00 2001
From: root
| 价格 | 数量 | @@ -133,7 +133,7 @@ function FlowAnalysis({ symbol }: { symbol: Symbol }) { const [loading, setLoading] = useState(true); const [dataAge, setDataAge] = useState(0); // 数据积累分钟数 - const fetchData = useCallback(async () => { + const fetchData = useCallback(async (showLoading = false) => { const end_ms = Date.now(); const windowMs = { "1m": 3600000, "5m": 14400000, "15m": 43200000, "1h": 172800000 }[interval]; const start_ms = end_ms - windowMs; @@ -145,7 +145,7 @@ function FlowAnalysis({ symbol }: { symbol: Symbol }) { const json = await res.json(); const bars: SummaryBar[] = json.data || []; setData(bars); - setLoading(false); + if (showLoading) setLoading(false); if (bars.length > 0) { const ageMs = end_ms - bars[0].time_ms; setDataAge(Math.round(ageMs / 60000)); @@ -155,8 +155,8 @@ function FlowAnalysis({ symbol }: { symbol: Symbol }) { useEffect(() => { setLoading(true); - fetchData(); - const iv = setInterval(fetchData, 30000); + fetchData(true); + const iv = setInterval(() => fetchData(false), 30000); // 定时刷新不触发loading return () => clearInterval(iv); }, [fetchData]);
|---|