fix(websocket): 🐛 完善WebSocket端点配置检查逻辑

在所有WebSocket相关组件中添加对VITE_APP_WS_ENDPOINT的检查
确保未配置WebSocket端点时不会尝试建立连接
防止出现"brokerURL or webSocketFactory must be provided"错误
This commit is contained in:
Ray.Hao
2025-04-29 23:46:32 +08:00
parent 142d808a5e
commit d619e3c2e6
3 changed files with 26 additions and 0 deletions

View File

@@ -91,6 +91,13 @@ export function useOnlineCount() {
const initWebSocket = () => {
if (isConnecting.value) return;
// 检查WebSocket端点是否配置
const wsEndpoint = import.meta.env.VITE_APP_WS_ENDPOINT;
if (!wsEndpoint) {
console.log("未配置WebSocket端点(VITE_APP_WS_ENDPOINT),跳过WebSocket连接");
return;
}
// 检查是否有可用的令牌
const hasToken = !!getAccessToken();
if (!hasToken) {