From 19284f3677a9f4d0dcccdbdf85a1e30c8219317b Mon Sep 17 00:00:00 2001 From: zzlgreat Date: Wed, 10 Dec 2025 15:24:29 +0800 Subject: [PATCH] update pay ui --- .../FlexScreen/hooks/useRealtimeQuote.ts | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/views/StockOverview/components/FlexScreen/hooks/useRealtimeQuote.ts b/src/views/StockOverview/components/FlexScreen/hooks/useRealtimeQuote.ts index 1b093826..d7bec4ad 100644 --- a/src/views/StockOverview/components/FlexScreen/hooks/useRealtimeQuote.ts +++ b/src/views/StockOverview/components/FlexScreen/hooks/useRealtimeQuote.ts @@ -382,7 +382,11 @@ export const useRealtimeQuote = (codes: string[] = []): UseRealtimeQuoteReturn = heartbeatRefs.current[exchange] = setInterval(() => { const ws = wsRefs.current[exchange]; if (ws && ws.readyState === WebSocket.OPEN) { - ws.send(JSON.stringify({ type: 'ping' })); + // 上交所使用 action: 'ping',深交所使用 type: 'ping' + const pingMsg = exchange === 'SSE' + ? { action: 'ping' } + : { type: 'ping' }; + ws.send(JSON.stringify(pingMsg)); } }, HEARTBEAT_INTERVAL); }, [stopHeartbeat]); @@ -409,10 +413,20 @@ export const useRealtimeQuote = (codes: string[] = []): UseRealtimeQuoteReturn = // eslint-disable-next-line @typescript-eslint/no-explicit-any const anyMsg = msg as any; - // 心跳响应 - if (msg.type === 'pong') return; + // 心跳响应(上交所和深交所格式可能不同) + if (msg.type === 'pong' || anyMsg.action === 'pong') return; if (exchange === 'SSE') { + // 上交所消息处理 + if (msg.type === 'subscribed') { + logger.info('FlexScreen', 'SSE 订阅成功', { channels: anyMsg.channels }); + return; + } + if (msg.type === 'error') { + logger.error('FlexScreen', 'SSE WebSocket 错误', { message: anyMsg.message }); + return; + } + // 处理行情数据 const result = handleSSEMessage( msg as SSEMessage, subscribedCodes.current.SSE,