集成接口 开始执行任务的领域层和数据层和UI层的开发啊(待测试)
集成功能 暂停 取消功能 恢复功能的接口的领域层和数据层的开发 下一步待集成到页面上 优化功能,优化了接口异常和未知异常对页面渲染的影响对用户的体验的不好情况。具体通过弹窗友好提示! 优化更新了tcp指示灯点击出现机器状态中添加选中设备的编号 方便用户使用的明白明了!。 优化更新关闭了tcp重连操作内链条中的获取用户设备和切换设备操作项。 调整了获取无人机状态信息的更新频率 为14秒一次
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import '../../../../../core/network/tcp/tcp_client.dart';
|
||||
import '../../../home/domain/entities/site_entity.dart';
|
||||
|
||||
class SiteState {
|
||||
@@ -48,8 +51,26 @@ class SiteCubit extends Cubit<SiteState> {
|
||||
|
||||
/// 选择场站(持久化)
|
||||
void selectSite(SiteEntity site) {
|
||||
debugPrint('🏭 [SiteCubit] ========== 切换场站 ==========');
|
||||
debugPrint('🏭 [SiteCubit] 从 ${state.selectedSite?.siteName ?? "无"} 切换到 ${site.siteName}');
|
||||
|
||||
// 🔥 关键修复:只有切换到不同场站时才断开TCP
|
||||
if (state.selectedSite?.id != site.id) {
|
||||
final tcpClient = GetIt.I<TcpClient>();
|
||||
if (tcpClient.isConnected) {
|
||||
debugPrint('🛑 [SiteCubit] 检测到TCP已连接,正在断开...');
|
||||
tcpClient.disconnect();
|
||||
debugPrint('✅ [SiteCubit] TCP已断开,防止场站间设备数据混淆');
|
||||
} else {
|
||||
debugPrint('ℹ️ [SiteCubit] TCP未连接,无需断开');
|
||||
}
|
||||
} else {
|
||||
debugPrint('✅ [SiteCubit] 相同场站,保持TCP连接状态');
|
||||
}
|
||||
|
||||
sharedPreferences.setInt(_selectedSiteIdKey, site.id);
|
||||
emit(state.copyWith(selectedSite: site));
|
||||
debugPrint('✅ [SiteCubit] 场站切换完成');
|
||||
}
|
||||
|
||||
/// 清除选中场站
|
||||
|
||||
Reference in New Issue
Block a user