refactor: 移除测试相关代码及组件
fix(websocket): 禁用所有Toast提示以优化用户体验 删除开发环境下的测试路由、页面及组件,清理不再使用的代码。同时修改websocket模块,移除所有Toast提示以避免干扰用户操作。
This commit is contained in:
@@ -130,7 +130,7 @@ export const useWebSocketStore = createPersistStore<WebSocketState>(
|
||||
const { token2 } = useUserStore.getState();
|
||||
|
||||
if (!token2) {
|
||||
Toast.show({ content: "未找到有效的访问令牌", position: "top" });
|
||||
// Toast.show({ content: "未找到有效的访问令牌", position: "top" });
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -147,10 +147,10 @@ export const useWebSocketStore = createPersistStore<WebSocketState>(
|
||||
// 检查URL是否为localhost,如果是则不连接
|
||||
if (wsUrl.includes("localhost") || wsUrl.includes("127.0.0.1")) {
|
||||
// console.error("WebSocket连接被拦截:不允许连接到本地地址", wsUrl);
|
||||
Toast.show({
|
||||
content: "WebSocket连接被拦截:不允许连接到本地地址",
|
||||
position: "top",
|
||||
});
|
||||
// Toast.show({
|
||||
// content: "WebSocket连接被拦截:不允许连接到本地地址",
|
||||
// position: "top",
|
||||
// });
|
||||
set({ status: WebSocketStatus.ERROR });
|
||||
return;
|
||||
}
|
||||
@@ -175,7 +175,7 @@ export const useWebSocketStore = createPersistStore<WebSocketState>(
|
||||
} catch (error) {
|
||||
// console.error("WebSocket连接失败:", error);
|
||||
set({ status: WebSocketStatus.ERROR });
|
||||
Toast.show({ content: "WebSocket连接失败", position: "top" });
|
||||
// Toast.show({ content: "WebSocket连接失败", position: "top" });
|
||||
}
|
||||
},
|
||||
|
||||
@@ -207,7 +207,7 @@ export const useWebSocketStore = createPersistStore<WebSocketState>(
|
||||
currentState.status !== WebSocketStatus.CONNECTED ||
|
||||
!currentState.ws
|
||||
) {
|
||||
Toast.show({ content: "WebSocket未连接", position: "top" });
|
||||
// Toast.show({ content: "WebSocket未连接", position: "top" });
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -220,7 +220,7 @@ export const useWebSocketStore = createPersistStore<WebSocketState>(
|
||||
// console.log("消息发送成功:", fullMessage);
|
||||
} catch (error) {
|
||||
// console.error("消息发送失败:", error);
|
||||
Toast.show({ content: "消息发送失败", position: "top" });
|
||||
// Toast.show({ content: "消息发送失败", position: "top" });
|
||||
}
|
||||
},
|
||||
|
||||
@@ -232,10 +232,10 @@ export const useWebSocketStore = createPersistStore<WebSocketState>(
|
||||
currentState.status !== WebSocketStatus.CONNECTED ||
|
||||
!currentState.ws
|
||||
) {
|
||||
Toast.show({
|
||||
content: "WebSocket未连接,正在重新连接...",
|
||||
position: "top",
|
||||
});
|
||||
// Toast.show({
|
||||
// content: "WebSocket未连接,正在重新连接...",
|
||||
// position: "top",
|
||||
// });
|
||||
|
||||
// 重置连接状态并发起重新连接
|
||||
set({ status: WebSocketStatus.DISCONNECTED });
|
||||
@@ -256,7 +256,7 @@ export const useWebSocketStore = createPersistStore<WebSocketState>(
|
||||
// console.log("命令发送成功:", command);
|
||||
} catch (error) {
|
||||
// console.error("命令发送失败:", error);
|
||||
Toast.show({ content: "命令发送失败", position: "top" });
|
||||
// Toast.show({ content: "命令发送失败", position: "top" });
|
||||
|
||||
// 发送失败时也尝试重新连接
|
||||
set({ status: WebSocketStatus.DISCONNECTED });
|
||||
@@ -339,7 +339,7 @@ export const useWebSocketStore = createPersistStore<WebSocketState>(
|
||||
});
|
||||
}
|
||||
|
||||
Toast.show({ content: "WebSocket连接成功", position: "top" });
|
||||
// Toast.show({ content: "WebSocket连接成功", position: "top" });
|
||||
|
||||
// 启动客服状态查询定时器
|
||||
currentState._startAliveStatusTimer();
|
||||
@@ -356,10 +356,10 @@ export const useWebSocketStore = createPersistStore<WebSocketState>(
|
||||
// 处理Auth failed通知
|
||||
if (data.notify === "Auth failed" || data.notify === "Kicked out") {
|
||||
// console.error(`WebSocket ${data.notify},断开连接`);
|
||||
Toast.show({
|
||||
content: `WebSocket ${data.notify},断开连接`,
|
||||
position: "top",
|
||||
});
|
||||
// Toast.show({
|
||||
// content: `WebSocket ${data.notify},断开连接`,
|
||||
// position: "top",
|
||||
// });
|
||||
|
||||
// 禁用自动重连
|
||||
if (get().config) {
|
||||
@@ -436,7 +436,7 @@ export const useWebSocketStore = createPersistStore<WebSocketState>(
|
||||
|
||||
set({ status: WebSocketStatus.ERROR });
|
||||
|
||||
Toast.show({ content: "WebSocket连接错误", position: "top" });
|
||||
// Toast.show({ content: "WebSocket连接错误", position: "top" });
|
||||
},
|
||||
|
||||
// 内部方法:启动重连定时器
|
||||
|
||||
Reference in New Issue
Block a user