From ce559664f1e6c6b13ac36e2df5b05a9f53eb7d0a Mon Sep 17 00:00:00 2001 From: hzm <934585316@qq.com> Date: Mon, 16 Mar 2026 10:02:35 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A4=A7=E7=9B=98=E6=8C=87=E6=95=B0?= =?UTF-8?q?=E5=88=B7=E6=96=B0=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/components/MarketIndexAccordion.jsx | 21 +++++++++++++++++++-- app/page.jsx | 1 + 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/app/components/MarketIndexAccordion.jsx b/app/components/MarketIndexAccordion.jsx index e6f5359..4a4c989 100644 --- a/app/components/MarketIndexAccordion.jsx +++ b/app/components/MarketIndexAccordion.jsx @@ -198,6 +198,7 @@ export default function MarketIndexAccordion({ onHeightChange, isMobile, onCustomSettingsChange, + refreshing = false, }) { const [indices, setIndices] = useState([]); const [loading, setLoading] = useState(true); @@ -222,8 +223,9 @@ export default function MarketIndexAccordion({ }; }, [onHeightChange, loading, indices.length]); - useEffect(() => { + const loadIndices = () => { let cancelled = false; + setLoading(true); fetchMarketIndices() .then((data) => { if (!cancelled) setIndices(Array.isArray(data) ? data : []); @@ -234,9 +236,24 @@ export default function MarketIndexAccordion({ .finally(() => { if (!cancelled) setLoading(false); }); - return () => { cancelled = true; }; + return () => { + cancelled = true; + }; + }; + + useEffect(() => { + // 初次挂载时加载一次指数 + const cleanup = loadIndices(); + return cleanup; }, []); + useEffect(() => { + // 跟随基金刷新节奏:每次开始刷新时重新拉取指数 + if (!refreshing) return; + const cleanup = loadIndices(); + return cleanup; + }, [refreshing]); + // 初始化选中指数(本地偏好 > 默认集合) useEffect(() => { if (!indices.length || typeof window === 'undefined') return; diff --git a/app/page.jsx b/app/page.jsx index e6a81ee..08f14de 100644 --- a/app/page.jsx +++ b/app/page.jsx @@ -3923,6 +3923,7 @@ export default function HomePage() { onHeightChange={setMarketIndexAccordionHeight} isMobile={isMobile} onCustomSettingsChange={triggerCustomSettingsSync} + refreshing={refreshing} />