diff --git a/Cunkebao/src/pages/pc/ckbox/main.ts b/Cunkebao/src/pages/pc/ckbox/main.ts index 578f81a7..ddf98dce 100644 --- a/Cunkebao/src/pages/pc/ckbox/main.ts +++ b/Cunkebao/src/pages/pc/ckbox/main.ts @@ -99,7 +99,7 @@ export const initSocket = () => { const { status } = useWebSocketStore.getState(); // 如果已经连接或正在连接,则不重复连接 - if (status === "connected" || status === "connecting") { + if (["connected", "connecting"].includes(status)) { console.log("WebSocket已连接或正在连接,跳过重复连接", { status }); return; } diff --git a/Cunkebao/src/store/module/websocket/sendMessages.ts b/Cunkebao/src/store/module/websocket/sendMessages.ts new file mode 100644 index 00000000..e69de29b diff --git a/Cunkebao/src/store/module/websocket/websocket.ts b/Cunkebao/src/store/module/websocket/websocket.ts index 08feb6db..34e39846 100644 --- a/Cunkebao/src/store/module/websocket/websocket.ts +++ b/Cunkebao/src/store/module/websocket/websocket.ts @@ -137,16 +137,7 @@ export const useWebSocketStore = createPersistStore( t: Date.now().toString(), }); - // 调试信息:输出配置和环境变量 - // console.log("WebSocket配置信息:", { - // configUrl: fullConfig.url, - // envUrl: (import.meta as any).env?.VITE_API_WS_URL, - // fullConfig, - // params: params.toString(), - // }); - const wsUrl = fullConfig.url + "?" + params; - // console.log("最终WebSocket URL:", wsUrl); // 检查URL是否为localhost,如果是则不连接 if (wsUrl.includes("localhost") || wsUrl.includes("127.0.0.1")) {