From d9ff91fa12e7826900ae8aa35df4e7d396c90a77 Mon Sep 17 00:00:00 2001 From: shy3130 <415333856@qq.com> Date: Sun, 30 Aug 2026 19:05:16 +0800 Subject: [PATCH] =?UTF-8?q?fix(dialog):=20=E6=97=A5K=E8=A7=86=E5=9B=BE?= =?UTF-8?q?=E5=B7=A6=E5=8F=B3=E5=8F=8C=E6=A0=8F=E5=90=8C=E6=AD=A5=E5=AE=9E?= =?UTF-8?q?=E6=97=B6=E5=88=B7=E6=96=B0=20=E2=80=94=20=E8=9C=A1=E7=83=9B?= =?UTF-8?q?=E4=B8=8E=E5=86=85=E5=B5=8C=E5=88=86=E6=97=B6=E6=8E=A5=E5=85=A5?= =?UTF-8?q?=E7=8B=AC=E7=AB=8B=E8=BD=AE=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 上个提交只覆盖了「分时」标签页 (StockMultiDayIntradayChart); 默认日K视图 的 StockPanel 双栏仍不刷新: - 左侧蜡烛 (StockDailyKChart): 日K查询挂载后从不轮询, 今日实时蜡烛 (后端 _maybe_inject_live_candle 注入) 不随行情更新 → 透传 refetchIntervalMs 到 StockDailyKChart 接入同一轮询 - 右侧内嵌分时 (StockIntradayChart): 对话框漏传 refetchIntervalMs 给 StockPanel 日K分支, 且请求未带 live → 补传参数; 轮询上下文中 klineMinute 带 live=1, 当日盘中直接实时拉取 (历史日期后端自行忽略) 浏览器实测 (实时行情关闭): 日K视图下 kline/daily 与 kline/minute?date=当日&live=1 均以约 6s 节奏持续轮询 --- frontend/src/components/StockDailyKChart.tsx | 4 ++++ frontend/src/components/StockIntradayChart.tsx | 4 +++- frontend/src/components/StockPanel.tsx | 1 + frontend/src/components/StockPreviewDialog.tsx | 1 + 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/StockDailyKChart.tsx b/frontend/src/components/StockDailyKChart.tsx index 9f87e67..495ecc4 100644 --- a/frontend/src/components/StockDailyKChart.tsx +++ b/frontend/src/components/StockDailyKChart.tsx @@ -54,6 +54,8 @@ interface Props { onDataChange?: (result: StockDailyKChartResult) => void /** 扩展数据列参数(逗号分隔 config_id.field_name),透传给 klineDaily 接口 */ extColumns?: string + /** 日K自动刷新间隔(ms)。undefined = 不轮询(默认)。个股对话框实时刷新时传入, 盘中今日蜡烛随之更新 */ + refetchIntervalMs?: number } function isValidRow(r: any): boolean { @@ -136,6 +138,7 @@ export function StockDailyKChart({ onPriceDoubleClick, onDataChange, extColumns, + refetchIntervalMs, }: Props) { const [activeIndicators, setActiveIndicators] = useState(['vol']) const [showMarkers, setShowMarkers] = useState(true) @@ -150,6 +153,7 @@ export function StockDailyKChart({ queryKey: QK.kline(symbol, dateRange.start, dateRange.end, extColumns), queryFn: () => api.klineDaily(symbol, days, dateRange, extColumns), enabled: !!symbol, + refetchInterval: refetchIntervalMs, placeholderData: (prev) => prev, }) diff --git a/frontend/src/components/StockIntradayChart.tsx b/frontend/src/components/StockIntradayChart.tsx index 95d5ca0..6f014e9 100644 --- a/frontend/src/components/StockIntradayChart.tsx +++ b/frontend/src/components/StockIntradayChart.tsx @@ -36,7 +36,9 @@ export function StockIntradayChart({ const minute = useQuery({ queryKey: QK.klineMinute(symbol, date ?? ''), - queryFn: () => api.klineMinute(symbol, date ?? undefined), + // 轮询上下文 (个股详情) 传 live: 当日盘中后端直接实时拉取最新K, + // 避免读到分钟增量落盘的上一轮本地分区; 历史日期后端自行忽略 live。 + queryFn: () => api.klineMinute(symbol, date ?? undefined, refetchIntervalMs != null), enabled: !!symbol && !!date, refetchInterval: refetchIntervalMs, }) diff --git a/frontend/src/components/StockPanel.tsx b/frontend/src/components/StockPanel.tsx index ef5aa90..04c9544 100644 --- a/frontend/src/components/StockPanel.tsx +++ b/frontend/src/components/StockPanel.tsx @@ -167,6 +167,7 @@ export function StockPanel({ onDataChange={setDailyResult} visibleBars={showIntraday ? 40 : 60} extColumns={extColumns} + refetchIntervalMs={refetchIntervalMs} /> {showIntraday && selectedDate && !intradayDismissed && ( diff --git a/frontend/src/components/StockPreviewDialog.tsx b/frontend/src/components/StockPreviewDialog.tsx index f793d5e..26f422e 100644 --- a/frontend/src/components/StockPreviewDialog.tsx +++ b/frontend/src/components/StockPreviewDialog.tsx @@ -475,6 +475,7 @@ export function StockPreviewDialog({ symbol, name, onClose, triggerInfo }: Props dateRange={dateRange} priceLines={monitorPriceLines} onPriceDoubleClick={openPriceAlert} + refetchIntervalMs={intradayRefetchMs} /> ) : ( <>