This commit is contained in:
2026-02-18 17:54:07 +08:00
parent 378b9bd71f
commit e679a9402f
11 changed files with 739 additions and 5 deletions

View File

@@ -229,7 +229,9 @@ class WebSocketClient {
*/
export function createWebSocket(userId, token, options = {}) {
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:'
const host = window.location.host
// 优先使用配置的 WS_URL否则使用当前域名
const host = options.wsUrl || window.location.host
const url = `${protocol}//${host}/ws?user_id=${userId}&token=${token}`
return new WebSocketClient(url, options)