集成双 MQTT 客户端实现设备实时数据监控(未测试)
1.集成两个独立的 MQTT 客户端,支持 WebSocket 和 TCP 协议 2.实现无人机/机场 OSD 实时监控(ws://1.95.137.212:8083/mqtt) 3.实现任务状态消息订阅(tcp://1.95.137.212:59020) 4.采用清洁架构设计,分层清晰(Domain → Data → Presentation)
This commit is contained in:
@@ -13,6 +13,7 @@ import '../../../../core/app/app_user_cubit.dart';
|
||||
import '../../../../core/router/route_paths.dart';
|
||||
import '../../../devices/presentation/bloc/devices_cubit.dart';
|
||||
import '../../../devices/presentation/bloc/devices_state.dart';
|
||||
import '../../../remote_control/presentation/bloc/remote_control_cubit.dart'; // 🔥 添加 RemoteControlCubit
|
||||
// 导入你的主题文件以获取 offWhite
|
||||
// import 'package:maibu_satabot_v2/core/theme/app_theme.dart';
|
||||
|
||||
@@ -126,11 +127,18 @@ class ImmersionHeader extends StatelessWidget {
|
||||
children: [
|
||||
_buildCircleIcon(Icons.sync, () {
|
||||
// 1. 触发 Cubit 请求最新设备列表
|
||||
// 假设你的 username 存储在 AuthCubit 或类似的全局状态中
|
||||
final username =
|
||||
context.read<AppUserCubit>().state.user?.username ??
|
||||
"";
|
||||
context.read<DevicesCubit>().fetchAllDevices(username);
|
||||
|
||||
// 🔥 修复:检查是否已有 targetDevice
|
||||
final remoteControlState = context.read<RemoteControlCubit>().state;
|
||||
if (remoteControlState.targetDevice == null) {
|
||||
debugPrint('🔄 [ImmersionHeader] 无 targetDevice,开始加载设备列表');
|
||||
context.read<DevicesCubit>().fetchAllDevices(username);
|
||||
} else {
|
||||
debugPrint('✅ [ImmersionHeader] 已有 targetDevice: ${remoteControlState.targetDevice!.deviceName},跳过加载');
|
||||
}
|
||||
|
||||
// 2. 弹出窗口(窗口内部会根据状态显示转圈或列表)
|
||||
_showDeviceSwitcher(context);
|
||||
|
||||
Reference in New Issue
Block a user