This commit is contained in:
shunfeng.zhou 2025-04-13 14:24:48 +08:00
parent bf58260ff0
commit 39e99e8d72

View File

@ -76,14 +76,14 @@ export class WebSocketService {
}
// 检查环境和协议
const isVsCodeWebview = typeof window !== 'undefined' && 'acquireVsCodeApi' in window;
// const isVsCodeWebview = typeof window !== 'undefined' && 'acquireVsCodeApi' in window;
const isLocalhost = wsUrl.includes('localhost') || wsUrl.includes('127.0.0.1');
// VS Code WebView环境下可能需要wss
if (isVsCodeWebview && wsUrl.startsWith('ws://')) {
this.logger('[WebSocketService] 在VS Code WebView中尝试使用安全WebSocket连接');
wsUrl = wsUrl.replace('ws://', 'wss://');
}
// if (isVsCodeWebview && wsUrl.startsWith('ws://')) {
// this.logger('[WebSocketService] 在VS Code WebView中尝试使用安全WebSocket连接');
// wsUrl = wsUrl.replace('ws://', 'wss://');
// }
this.logger(`[WebSocketService] 最终WebSocket URL: ${wsUrl}`);
this.socket = new WebSocket(wsUrl);