fix: 修复同步问题

This commit is contained in:
hzm
2026-03-16 12:32:43 +08:00
parent ab9e8a5072
commit 139116a0d3
2 changed files with 6 additions and 1 deletions

View File

@@ -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;
}
}

View File

@@ -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();