fix(dialog): 日K视图左右双栏同步实时刷新 — 蜡烛与内嵌分时接入独立轮询

上个提交只覆盖了「分时」标签页 (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 节奏持续轮询
This commit is contained in:
shy3130
2026-08-30 19:05:16 +08:00
parent 974a3dccd2
commit d9ff91fa12
4 changed files with 9 additions and 1 deletions
@@ -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<string[]>(['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,
})
@@ -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,
})
+1
View File
@@ -167,6 +167,7 @@ export function StockPanel({
onDataChange={setDailyResult}
visibleBars={showIntraday ? 40 : 60}
extColumns={extColumns}
refetchIntervalMs={refetchIntervalMs}
/>
{showIntraday && selectedDate && !intradayDismissed && (
@@ -475,6 +475,7 @@ export function StockPreviewDialog({ symbol, name, onClose, triggerInfo }: Props
dateRange={dateRange}
priceLines={monitorPriceLines}
onPriceDoubleClick={openPriceAlert}
refetchIntervalMs={intradayRefetchMs}
/>
) : (
<>