From b8d239de409d11813a4e87d66167fe96909a5966 Mon Sep 17 00:00:00 2001 From: hzm <934585316@qq.com> Date: Tue, 3 Mar 2026 20:57:19 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=88=9D=E5=A7=8B=E5=8C=96=E5=88=B7?= =?UTF-8?q?=E6=96=B0=E5=90=8E=E8=A6=86=E7=9B=96=E6=9C=AC=E5=9C=B0funds?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=88=B0=E4=BA=91=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/page.jsx | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/app/page.jsx b/app/page.jsx index 97da556..6706642 100644 --- a/app/page.jsx +++ b/app/page.jsx @@ -1459,14 +1459,19 @@ export default function HomePage() { userIdRef.current = user?.id || null; }, [user]); - const getFundCodesSignature = useCallback((value) => { + const getFundCodesSignature = useCallback((value, extraFields = []) => { try { - const list = JSON.parse(value || '[]'); + const list = Array.isArray(value) ? value : JSON.parse(value || '[]'); if (!Array.isArray(list)) return ''; + const fields = Array.from(new Set([ + 'jzrq', + 'dwjz', + ...(Array.isArray(extraFields) ? extraFields : []) + ])); const items = list.map((item) => { if (!item?.code) return null; - // 加入 jzrq 和 dwjz 以检测净值更新 - return `${item.code}:${item.jzrq || ''}:${item.dwjz || ''}`; + const extras = fields.map((field) => item?.[field] || '').join(':'); + return `${item.code}:${extras}`; }).filter(Boolean); return Array.from(new Set(items)).join('|'); } catch (e) { @@ -3027,6 +3032,25 @@ export default function HomePage() { if (nextFunds.length) { const codes = Array.from(new Set(nextFunds.map((f) => f.code))); if (codes.length) await refreshAll(codes); + // 刷新完成后,强制同步本地localStorage 的 funds 数据到云端 + const currentUserId = userIdRef.current || user?.id; + if (currentUserId) { + try { + const latestFunds = JSON.parse(localStorage.getItem('funds') || '[]'); + const localSig = getFundCodesSignature(latestFunds, ['gztime']); + const cloudSig = getFundCodesSignature(Array.isArray(cloudData.funds) ? cloudData.funds : [], ['gztime']); + if (localSig !== cloudSig) { + await syncUserConfig( + currentUserId, + false, + { funds: Array.isArray(latestFunds) ? latestFunds : [] }, + true + ); + } + } catch (e) { + console.error('刷新后强制同步 funds 到云端失败', e); + } + } } const payload = collectLocalPayload();