绑定设备+覆盖模式+控制显示bug+在线更新
This commit is contained in:
@@ -1028,6 +1028,10 @@ class RemoteControlCubit extends Cubit<RemoteControlState> {
|
||||
debugPrint('📦 [RemoteControl] 更新targetDevice状态');
|
||||
emit(state.copyWith(targetDevice: device));
|
||||
debugPrint('✅ [RemoteControl] targetDevice状态已更新');
|
||||
|
||||
// 🔥 MQTT机器状态订阅:切换设备时订阅新设备的topic(与DevicesCubit.switchDevice相同逻辑)
|
||||
debugPrint('📡 [RemoteControl] 开始MQTT机器状态订阅: ${device.deviceName}');
|
||||
deviceStatusBloc.startMqttRealtimeListening(device.deviceName);
|
||||
|
||||
// 🔥 关键修复:TCP 已在登录时建立,设备切换只用 HTTP
|
||||
// 不再创建新 TCP 连接,避免重复发送 0x03 触发服务端推送 have_logged_in
|
||||
|
||||
@@ -12,7 +12,6 @@ import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
import '../../../../core/app/app_user_cubit.dart';
|
||||
import '../../../../core/router/route_paths.dart';
|
||||
import '../../../auth/presentation/bloc/auth_cubit.dart'; // 🔥 导入 AuthCubit
|
||||
import '../../../devices/domain/entities/device_entity.dart';
|
||||
import '../../../devices/presentation/bloc/devices_cubit.dart';
|
||||
import '../bloc/remote_control_cubit.dart';
|
||||
import '../bloc/remote_control_state.dart';
|
||||
@@ -116,9 +115,6 @@ class _RemoteControlPageState extends State<RemoteControlPage> {
|
||||
return;
|
||||
}
|
||||
|
||||
// 🔥 弹窗显示当前控制的设备信息
|
||||
_showTargetDeviceDialog(context, remoteCubit.state.targetDevice!);
|
||||
|
||||
// 🔥 只在控制循环未启动时才启动
|
||||
remoteCubit.startControlLoop();
|
||||
// debugPrint('✅ [RemoteControl] 控制循环已启动');
|
||||
@@ -539,36 +535,6 @@ class _RemoteControlPageState extends State<RemoteControlPage> {
|
||||
);
|
||||
}
|
||||
|
||||
/// 🔥 显示当前控制设备的弹窗
|
||||
void _showTargetDeviceDialog(BuildContext context, DeviceEntity device) {
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: true,
|
||||
builder: (ctx) => AlertDialog(
|
||||
title: const Text('🎮 远程控制'),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'设备名称: ${device.deviceName}',
|
||||
style: const TextStyle(fontSize: 16),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'设备ID: ${device.deviceName}',
|
||||
style: const TextStyle(fontSize: 14, color: Colors.grey),
|
||||
),
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(ctx),
|
||||
child: const Text('确定'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
/// 🔥 显示当前控制设备的弹窗 - 已移除:进入远程遥控页不再弹出设备确认弹窗
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user