1
wwl
2 天以前 05c1bc4570f3a5faf4dad7683bfced0712908aba
src/utils/websocket.js
@@ -24,7 +24,15 @@
    closeWebSocket();
  }
  const wsUrl = `ws://192.168.1.244:5011/ws?token=${token}`;
// 取当前页面的协议(http/https),主机(域名 + 端口)
const loc = window.location;
const protocol = loc.protocol === 'https:' ? 'wss:' : 'ws:'; // 安全协议自动切换
const host = loc.host; // 域名 + 端口,比如 localhost:8080
// 拼接 WebSocket 地址
const wsUrl = `${protocol}//${host}/ws?token=${token}`;
console.log(wsUrl,"wsUrl");
  ws = new WebSocket(wsUrl);
  ws.onopen = () => {