集成接口 开始执行任务的领域层和数据层和UI层的开发啊(待测试)
集成功能 暂停 取消功能 恢复功能的接口的领域层和数据层的开发 下一步待集成到页面上 优化功能,优化了接口异常和未知异常对页面渲染的影响对用户的体验的不好情况。具体通过弹窗友好提示! 优化更新了tcp指示灯点击出现机器状态中添加选中设备的编号 方便用户使用的明白明了!。 优化更新关闭了tcp重连操作内链条中的获取用户设备和切换设备操作项。 调整了获取无人机状态信息的更新频率 为14秒一次
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import '../../domain/usecases/get_device_status_data_usecase.dart';
|
||||
import '../../../../../core/network/error_handler.dart';
|
||||
import 'device_status_event.dart';
|
||||
import 'device_status_state.dart';
|
||||
|
||||
@@ -31,7 +32,10 @@ class DeviceStatusBloc extends Bloc<DeviceStatusEvent, DeviceStatusState> {
|
||||
siteId: event.siteId,
|
||||
));
|
||||
} catch (e) {
|
||||
emit(DeviceStatusError(e.toString()));
|
||||
emit(DeviceStatusError(
|
||||
message: ErrorHandler.getErrorMessage(e),
|
||||
shouldShowError: true, // 🔥 标记需要显示弹窗
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +59,10 @@ class DeviceStatusBloc extends Bloc<DeviceStatusEvent, DeviceStatusState> {
|
||||
devices: response.devices,
|
||||
));
|
||||
} catch (e) {
|
||||
emit(DeviceStatusError(e.toString()));
|
||||
emit(DeviceStatusError(
|
||||
message: ErrorHandler.getErrorMessage(e),
|
||||
shouldShowError: true, // 🔥 标记需要显示弹窗
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,11 +54,15 @@ class DeviceStatusLoaded extends DeviceStatusState {
|
||||
|
||||
class DeviceStatusError extends DeviceStatusState {
|
||||
final String message;
|
||||
final bool shouldShowError; // 🔥 标记是否需要显示错误弹窗
|
||||
|
||||
const DeviceStatusError(this.message);
|
||||
const DeviceStatusError({
|
||||
required this.message,
|
||||
this.shouldShowError = false, // 默认 false
|
||||
});
|
||||
|
||||
@override
|
||||
List<Object?> get props => [message];
|
||||
List<Object?> get props => [message, shouldShowError];
|
||||
}
|
||||
|
||||
class DeviceStatusEmpty extends DeviceStatusState {
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import '../../domain/usecases/get_drone_station_list_usecase.dart';
|
||||
import '../../domain/usecases/get_video_stream_usecase.dart';
|
||||
import '../../domain/usecases/get_uav_video_stream_usecase.dart';
|
||||
import '../../../../../core/network/error_handler.dart';
|
||||
import 'drone_station_event.dart';
|
||||
import 'drone_station_state.dart';
|
||||
|
||||
@@ -33,7 +34,10 @@ class DroneStationBloc extends Bloc<DroneStationEvent, DroneStationState> {
|
||||
final result = await getDroneStationListUseCase(event.siteId);
|
||||
|
||||
result.fold(
|
||||
(failure) => emit(DroneStationError(failure.message)),
|
||||
(failure) => emit(DroneStationError(
|
||||
message: ErrorHandler.getErrorMessage(failure.message),
|
||||
shouldShowError: true, // 🔥 标记需要显示弹窗
|
||||
)),
|
||||
(stations) => emit(DroneStationLoaded(stations)),
|
||||
);
|
||||
}
|
||||
@@ -46,7 +50,10 @@ class DroneStationBloc extends Bloc<DroneStationEvent, DroneStationState> {
|
||||
final result = await getDroneStationListUseCase(event.siteId);
|
||||
|
||||
result.fold(
|
||||
(failure) => emit(DroneStationError(failure.message)),
|
||||
(failure) => emit(DroneStationError(
|
||||
message: ErrorHandler.getErrorMessage(failure.message),
|
||||
shouldShowError: true, // 🔥 标记需要显示弹窗
|
||||
)),
|
||||
(stations) => emit(DroneStationLoaded(stations)),
|
||||
);
|
||||
}
|
||||
@@ -61,7 +68,10 @@ class DroneStationBloc extends Bloc<DroneStationEvent, DroneStationState> {
|
||||
final result = await getUAVDetailUseCase(event.gatewaySn, event.deviceSn);
|
||||
|
||||
result.fold(
|
||||
(failure) => emit(UAVDetailError(failure.message)),
|
||||
(failure) => emit(UAVDetailError(
|
||||
message: ErrorHandler.getErrorMessage(failure.message),
|
||||
shouldShowError: true, // 🔥 标记需要显示弹窗
|
||||
)),
|
||||
(detail) => emit(UAVDetailLoaded(detail)),
|
||||
);
|
||||
}
|
||||
@@ -79,7 +89,10 @@ class DroneStationBloc extends Bloc<DroneStationEvent, DroneStationState> {
|
||||
);
|
||||
|
||||
result.fold(
|
||||
(failure) => emit(VideoStreamError(failure.message)),
|
||||
(failure) => emit(VideoStreamError(
|
||||
message: ErrorHandler.getErrorMessage(failure.message),
|
||||
shouldShowError: true, // 🔥 标记需要显示弹窗
|
||||
)),
|
||||
(videoStream) => emit(VideoStreamLoaded(videoStream, event.cameraPosition)),
|
||||
);
|
||||
}
|
||||
@@ -100,7 +113,10 @@ class DroneStationBloc extends Bloc<DroneStationEvent, DroneStationState> {
|
||||
);
|
||||
|
||||
result.fold(
|
||||
(failure) => emit(UavVideoStreamError(failure.message)),
|
||||
(failure) => emit(UavVideoStreamError(
|
||||
message: ErrorHandler.getErrorMessage(failure.message),
|
||||
shouldShowError: true, // 🔥 标记需要显示弹窗
|
||||
)),
|
||||
(videoStream) => emit(UavVideoStreamLoaded(
|
||||
videoStream: videoStream,
|
||||
cameraIndex: event.cameraIndex,
|
||||
|
||||
@@ -29,11 +29,15 @@ class DroneStationLoaded extends DroneStationState {
|
||||
|
||||
class DroneStationError extends DroneStationState {
|
||||
final String message;
|
||||
final bool shouldShowError; // 🔥 标记是否需要显示错误弹窗
|
||||
|
||||
const DroneStationError(this.message);
|
||||
const DroneStationError({
|
||||
required this.message,
|
||||
this.shouldShowError = false, // 默认 false
|
||||
});
|
||||
|
||||
@override
|
||||
List<Object?> get props => [message];
|
||||
List<Object?> get props => [message, shouldShowError];
|
||||
}
|
||||
|
||||
class UAVDetailLoading extends DroneStationState {
|
||||
@@ -51,11 +55,15 @@ class UAVDetailLoaded extends DroneStationState {
|
||||
|
||||
class UAVDetailError extends DroneStationState {
|
||||
final String message;
|
||||
final bool shouldShowError; // 🔥 标记是否需要显示错误弹窗
|
||||
|
||||
const UAVDetailError(this.message);
|
||||
const UAVDetailError({
|
||||
required this.message,
|
||||
this.shouldShowError = false, // 默认 false
|
||||
});
|
||||
|
||||
@override
|
||||
List<Object?> get props => [message];
|
||||
List<Object?> get props => [message, shouldShowError];
|
||||
}
|
||||
|
||||
class VideoStreamLoading extends DroneStationState {
|
||||
@@ -74,11 +82,15 @@ class VideoStreamLoaded extends DroneStationState {
|
||||
|
||||
class VideoStreamError extends DroneStationState {
|
||||
final String message;
|
||||
final bool shouldShowError; // 🔥 标记是否需要显示错误弹窗
|
||||
|
||||
const VideoStreamError(this.message);
|
||||
const VideoStreamError({
|
||||
required this.message,
|
||||
this.shouldShowError = false, // 默认 false
|
||||
});
|
||||
|
||||
@override
|
||||
List<Object?> get props => [message];
|
||||
List<Object?> get props => [message, shouldShowError];
|
||||
}
|
||||
|
||||
/// 无人机实时视频流加载状态
|
||||
@@ -105,9 +117,13 @@ class UavVideoStreamLoaded extends DroneStationState {
|
||||
/// 无人机实时视频流加载失败状态
|
||||
class UavVideoStreamError extends DroneStationState {
|
||||
final String message;
|
||||
final bool shouldShowError; // 🔥 标记是否需要显示错误弹窗
|
||||
|
||||
const UavVideoStreamError(this.message);
|
||||
const UavVideoStreamError({
|
||||
required this.message,
|
||||
this.shouldShowError = false, // 默认 false
|
||||
});
|
||||
|
||||
@override
|
||||
List<Object?> get props => [message];
|
||||
List<Object?> get props => [message, shouldShowError];
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import '../../../../../core/consts/http_api_consts.dart';
|
||||
import '../../../../../core/network/error_handler.dart';
|
||||
import '../../data/models/robot_data_model.dart';
|
||||
import 'robot_list_event.dart';
|
||||
import 'robot_list_state.dart';
|
||||
@@ -19,7 +20,10 @@ class RobotListBloc extends Bloc<RobotListEvent, RobotListState> {
|
||||
Emitter<RobotListState> emit,
|
||||
) async {
|
||||
if (event.siteId == null) {
|
||||
emit(const RobotListError('请先选择场站'));
|
||||
emit(const RobotListError(
|
||||
message: '请先选择场站',
|
||||
shouldShowError: true,
|
||||
));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -53,7 +57,10 @@ class RobotListBloc extends Bloc<RobotListEvent, RobotListState> {
|
||||
siteId: event.siteId,
|
||||
));
|
||||
} catch (e) {
|
||||
emit(RobotListError(e.toString()));
|
||||
emit(RobotListError(
|
||||
message: ErrorHandler.getErrorMessage(e),
|
||||
shouldShowError: true, // 🔥 标记需要显示弹窗
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +72,10 @@ class RobotListBloc extends Bloc<RobotListEvent, RobotListState> {
|
||||
final currentState = state as RobotListLoaded;
|
||||
|
||||
if (currentState.siteId == null) {
|
||||
emit(const RobotListError('请先选择场站'));
|
||||
emit(const RobotListError(
|
||||
message: '请先选择场站',
|
||||
shouldShowError: true,
|
||||
));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -94,7 +104,10 @@ class RobotListBloc extends Bloc<RobotListEvent, RobotListState> {
|
||||
|
||||
emit(currentState.copyWith(robots: robots));
|
||||
} catch (e) {
|
||||
emit(RobotListError(e.toString()));
|
||||
emit(RobotListError(
|
||||
message: ErrorHandler.getErrorMessage(e),
|
||||
shouldShowError: true, // 🔥 标记需要显示弹窗
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,9 +45,13 @@ class RobotListLoaded extends RobotListState {
|
||||
|
||||
class RobotListError extends RobotListState {
|
||||
final String message;
|
||||
final bool shouldShowError; // 🔥 标记是否需要显示错误弹窗
|
||||
|
||||
const RobotListError(this.message);
|
||||
const RobotListError({
|
||||
required this.message,
|
||||
this.shouldShowError = false, // 默认 false
|
||||
});
|
||||
|
||||
@override
|
||||
List<Object?> get props => [message];
|
||||
List<Object?> get props => [message, shouldShowError];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user