fix(operation-client): 修正 WebSocket 路径格式并优化连接 URL 生成

This commit is contained in:
kuaifan 2026-01-19 10:30:02 +08:00
parent 066a5a619c
commit f36317b081

View File

@ -4,8 +4,7 @@
* 负责与 MCP Server 建立 WebSocket 连接
* 接收来自 MCP 工具的请求并返回响应
*/
const WS_PATH = '/apps/mcp_server/mcp/operation';
const WS_PATH = 'apps/mcp_server/mcp/operation';
const RECONNECT_DELAY = 3000;
const MAX_RECONNECT_ATTEMPTS = 5;
@ -59,9 +58,10 @@ export class OperationClient {
return;
}
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
const host = window.location.host;
const url = `${protocol}//${host}${WS_PATH}?token=${encodeURIComponent(token)}`;
let url = $A.mainUrl(WS_PATH);
url = url.replace("https://", "wss://");
url = url.replace("http://", "ws://");
url += `?token=${encodeURIComponent(token)}`;
try {
this.ws = new WebSocket(url);