update pay ui

This commit is contained in:
2025-12-10 11:43:56 +08:00
parent 2482b01b00
commit 45339902aa
2 changed files with 42 additions and 8 deletions

View File

@@ -2,8 +2,12 @@
* 实时行情 Hook
* 管理上交所和深交所 WebSocket 连接,获取实时行情数据
*
* 上交所 (SSE): ws://49.232.185.254:8765 - 需主动订阅,提供五档行情
* 深交所 (SZSE): ws://222.128.1.157:8765 - 自动推送,提供十档行情
* 连接方式:
* - 生产环境 (HTTPS): 通过 Nginx 代理使用 wss:// (如 wss://valuefrontier.cn/ws/sse)
* - 开发环境 (HTTP): 直连 ws://
*
* 上交所 (SSE): 需主动订阅,提供五档行情
* 深交所 (SZSE): 自动推送,提供十档行情
*/
import { useState, useEffect, useRef, useCallback } from 'react';
@@ -402,7 +406,8 @@ export const useRealtimeQuote = (codes: string[] = []): UseRealtimeQuoteReturn =
}, []);
const createConnection = useCallback((exchange: Exchange) => {
// 检查是否是 HTTPS 页面尝试连接 ws://Mixed Content
// 防御性检查:确保 HTTPS 页面不会意外连接 ws://Mixed Content 安全错误
// 正常情况下 WS_CONFIG 会自动根据协议返回正确的 URL这里是备用保护
const isHttps = typeof window !== 'undefined' && window.location.protocol === 'https:';
const wsUrl = WS_CONFIG[exchange];
const isInsecureWs = wsUrl.startsWith('ws://');
@@ -410,7 +415,7 @@ export const useRealtimeQuote = (codes: string[] = []): UseRealtimeQuoteReturn =
if (isHttps && isInsecureWs) {
logger.warn(
'FlexScreen',
`${exchange} WebSocket 连接被跳过HTTPS 页面无法连接不安全的 ws:// 端点`
`${exchange} WebSocket 配置错误HTTPS 页面尝试连接 ws:// 端点,请检查 Nginx 代理配置`
);
return;
}