1更新无人机的摄像头视频显示的条件为在离线情况下的自动刷新+下拉刷新的机制。
2更新优化去除原有路径规划的初始化阶段的获取设备的接口请求,改为使用新的 targetDevice。 3修改无人机机场的在线状态简化为在线和离线。去掉机场二字。 4.更新同一账号同时段登录,被强制下线的友好提示!
This commit is contained in:
@@ -9,6 +9,7 @@ import 'package:maibu_satabot_v2/core/network/tcp/tcp_client.dart';
|
||||
import 'package:maibu_satabot_v2/features/devices/presentation/bloc/devices_cubit.dart';
|
||||
import 'package:maibu_satabot_v2/features/devices/presentation/bloc/devices_state.dart'; // 👈 必须加
|
||||
import 'package:maibu_satabot_v2/features/remote_control/domain/repositories/remote_control_repository.dart';
|
||||
import 'package:maibu_satabot_v2/features/remote_control/presentation/bloc/remote_control_cubit.dart';
|
||||
|
||||
import '../../../devices/domain/entities/device_entity.dart';
|
||||
import '../bloc/permission_request_bloc.dart';
|
||||
@@ -44,6 +45,17 @@ class _HomePageState extends State<HomePage> {
|
||||
|
||||
final devicesCubit = context.read<DevicesCubit>();
|
||||
|
||||
// 🔥 修复:检查是否已有 targetDevice,如果有则不需要加载设备列表
|
||||
final remoteControlState = context.read<RemoteControlCubit>().state;
|
||||
if (remoteControlState.targetDevice != null) {
|
||||
debugPrint('✅ [HomePage] 已有 targetDevice: ${remoteControlState.targetDevice!.deviceName},跳过设备列表加载');
|
||||
setState(() {
|
||||
_isDevicesLoading = false;
|
||||
_hasLoadedDevices = true;
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// 🔥 关键:等待设备加载完成
|
||||
await devicesCubit.fetchAllDevices(username);
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
import '../../../../core/app/app_user_cubit.dart';
|
||||
import '../../../devices/presentation/bloc/devices_cubit.dart';
|
||||
import '../../../remote_control/presentation/bloc/remote_control_cubit.dart';
|
||||
import '../widgets/map/test_amap_page.dart';
|
||||
import '../widgets/map/testmap_pages.dart';
|
||||
|
||||
@@ -11,17 +11,87 @@ class RoutePlanPage extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// 同时监听用户和设备状态
|
||||
final userState = context.read<AppUserCubit>().state;
|
||||
final deviceState = context.read<DevicesCubit>().state;
|
||||
final currentDevice = deviceState.selectedDevice;
|
||||
try {
|
||||
// 🔥 修复:使用 RemoteControlCubit 的 targetDevice 作为唯一设备数据源
|
||||
final userState = context.watch<AppUserCubit>().state;
|
||||
final remoteControlState = context.watch<RemoteControlCubit>().state;
|
||||
final targetDevice = remoteControlState.targetDevice;
|
||||
|
||||
if (currentDevice == null)
|
||||
return const Scaffold(body: Center(child: Text("加载中...")));
|
||||
debugPrint('🔍 [RoutePlanPage] targetDevice: ${targetDevice?.deviceName ?? "null"}');
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: const Color(0xFFF7F7F7),
|
||||
body: MapPageEnterprise(),
|
||||
);
|
||||
// 检查是否有选中的设备
|
||||
if (targetDevice == null) {
|
||||
return Scaffold(
|
||||
body: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.devices_other,
|
||||
size: 64,
|
||||
color: Color(0xFF86909C),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
const Text(
|
||||
'请先选择设备',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Color(0xFF1D2129),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'在设备列表或场站中选择要控制的设备',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Color(0xFF86909C),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: const Color(0xFFF7F7F7),
|
||||
body: MapPageEnterprise(),
|
||||
);
|
||||
} catch (e, stackTrace) {
|
||||
debugPrint('❌ [RoutePlanPage] 构建错误: $e');
|
||||
debugPrint('堆栈跟踪: $stackTrace');
|
||||
return Scaffold(
|
||||
body: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.error_outline,
|
||||
size: 64,
|
||||
color: Colors.red,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
const Text(
|
||||
'页面加载失败',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Color(0xFF1D2129),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'错误: $e',
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
color: Colors.red,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user