update pay ui
This commit is contained in:
@@ -382,7 +382,11 @@ export const useRealtimeQuote = (codes: string[] = []): UseRealtimeQuoteReturn =
|
|||||||
heartbeatRefs.current[exchange] = setInterval(() => {
|
heartbeatRefs.current[exchange] = setInterval(() => {
|
||||||
const ws = wsRefs.current[exchange];
|
const ws = wsRefs.current[exchange];
|
||||||
if (ws && ws.readyState === WebSocket.OPEN) {
|
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);
|
}, HEARTBEAT_INTERVAL);
|
||||||
}, [stopHeartbeat]);
|
}, [stopHeartbeat]);
|
||||||
@@ -409,10 +413,20 @@ export const useRealtimeQuote = (codes: string[] = []): UseRealtimeQuoteReturn =
|
|||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
const anyMsg = msg as any;
|
const anyMsg = msg as any;
|
||||||
|
|
||||||
// 心跳响应
|
// 心跳响应(上交所和深交所格式可能不同)
|
||||||
if (msg.type === 'pong') return;
|
if (msg.type === 'pong' || anyMsg.action === 'pong') return;
|
||||||
|
|
||||||
if (exchange === 'SSE') {
|
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(
|
const result = handleSSEMessage(
|
||||||
msg as SSEMessage,
|
msg as SSEMessage,
|
||||||
subscribedCodes.current.SSE,
|
subscribedCodes.current.SSE,
|
||||||
|
|||||||
Reference in New Issue
Block a user