使用ws
This commit is contained in:
parent
bf58260ff0
commit
39e99e8d72
@ -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');
|
const isLocalhost = wsUrl.includes('localhost') || wsUrl.includes('127.0.0.1');
|
||||||
|
|
||||||
// VS Code WebView环境下可能需要wss
|
// VS Code WebView环境下可能需要wss
|
||||||
if (isVsCodeWebview && wsUrl.startsWith('ws://')) {
|
// if (isVsCodeWebview && wsUrl.startsWith('ws://')) {
|
||||||
this.logger('[WebSocketService] 在VS Code WebView中,尝试使用安全WebSocket连接');
|
// this.logger('[WebSocketService] 在VS Code WebView中,尝试使用安全WebSocket连接');
|
||||||
wsUrl = wsUrl.replace('ws://', 'wss://');
|
// wsUrl = wsUrl.replace('ws://', 'wss://');
|
||||||
}
|
// }
|
||||||
|
|
||||||
this.logger(`[WebSocketService] 最终WebSocket URL: ${wsUrl}`);
|
this.logger(`[WebSocketService] 最终WebSocket URL: ${wsUrl}`);
|
||||||
this.socket = new WebSocket(wsUrl);
|
this.socket = new WebSocket(wsUrl);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user