From bfc16447c397c48b37c554e0037747e5e133d5b2 Mon Sep 17 00:00:00 2001 From: Songzex <2402265378@qq.com> Date: Thu, 5 Mar 2026 21:25:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=88=87=E6=8D=A2=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E6=9C=BA=E5=99=A8=E7=8A=B6=E6=80=81=E7=9A=84=E5=AE=9E?= =?UTF-8?q?=E6=97=B6=E6=8E=A5=E5=8F=97=E5=92=8CUI=E5=AE=9E=E6=97=B6?= =?UTF-8?q?=E5=88=B7=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/core/network/tcp/tcp_client.dart | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/core/network/tcp/tcp_client.dart b/lib/core/network/tcp/tcp_client.dart index 39c0cf4a..4c89881b 100644 --- a/lib/core/network/tcp/tcp_client.dart +++ b/lib/core/network/tcp/tcp_client.dart @@ -426,7 +426,14 @@ class TcpClient { onDone: (){ // TODO: 断线重连 debugPrint('onDone❌ 被动[TCP] 连接已断开!'); - _handleDisconnectBySwitch(deviceName); + if (!_isSwitching) { + _handleDisconnectBySwitch(deviceName); + } else { + debugPrint('🚫 [TCP] 检测到切换过程中的断开,忽略重连调度,防止死循环'); + // 可选:如果是因为切换导致的断开,这里不需要做任何事,因为主流程已经在运行了 + // 但为了安全,可以重置一下标志位,防止后续逻辑误判 + _isSwitching = false; + } }, onError: (e) { debugPrint('❌ 被动[TCP] 发生错误:$e');