diff --git a/app/components/MarketIndexAccordion.jsx b/app/components/MarketIndexAccordion.jsx index 4a4c989..2d744d7 100644 --- a/app/components/MarketIndexAccordion.jsx +++ b/app/components/MarketIndexAccordion.jsx @@ -207,6 +207,7 @@ export default function MarketIndexAccordion({ const [settingOpen, setSettingOpen] = useState(false); const [tickerIndex, setTickerIndex] = useState(0); const rootRef = useRef(null); + const hasInitializedSelectedCodes = useRef(false); useEffect(() => { const el = rootRef.current; @@ -257,6 +258,7 @@ export default function MarketIndexAccordion({ // 初始化选中指数(本地偏好 > 默认集合) useEffect(() => { if (!indices.length || typeof window === 'undefined') return; + if (hasInitializedSelectedCodes.current) return; try { const stored = window.localStorage.getItem('marketIndexSelected'); const availableCodes = new Set(indices.map((it) => it.code)); @@ -266,6 +268,7 @@ export default function MarketIndexAccordion({ const filtered = parsed.filter((c) => availableCodes.has(c)); if (filtered.length) { setSelectedCodes(filtered); + hasInitializedSelectedCodes.current = true; return; } } diff --git a/app/page.jsx b/app/page.jsx index d6dd061..d45a5e4 100644 --- a/app/page.jsx +++ b/app/page.jsx @@ -1624,7 +1624,9 @@ export default function HomePage() { if (key === 'funds') { const prevSig = getFundCodesSignature(prevValue); const nextSig = getFundCodesSignature(nextValue); - if (prevSig === nextSig) return; + if (prevSig === nextSig) { + return; + } } if (!skipSyncRef.current) { const now = nowInTz().toISOString();