完善自主作业下发、暂停恢复和轨迹保留
This commit is contained in:
@@ -192,7 +192,14 @@ class DeviceTaskDatasourceImpl implements DeviceTaskDatasource {
|
||||
final data = response.data as Map<String, dynamic>;
|
||||
if (data['code'] == 200) {
|
||||
_logger.logWithLevel('[recoveryTask] 结果: 成功, data=${jsonEncode(data['data'])}');
|
||||
return data['data'] as Map<String, dynamic>? ?? {};
|
||||
final payload = data['data'];
|
||||
// 恢复接口可能只返回布尔确认,不能把 true 强转成任务对象。
|
||||
if (payload == null || payload == true) return {};
|
||||
if (payload is Map) return Map<String, dynamic>.from(payload);
|
||||
if (payload == false) {
|
||||
throw Exception('恢复任务未成功,请确认设备状态后重试');
|
||||
}
|
||||
throw Exception('恢复任务响应格式异常,请稍后重试');
|
||||
} else {
|
||||
_logger.logWithLevel('[recoveryTask] 业务失败: code=${data['code']}, msg=${data['msg']}');
|
||||
throw Exception(data['msg'] ?? '恢复任务失败');
|
||||
|
||||
@@ -22,7 +22,11 @@ class CreateDeviceTaskUseCase {
|
||||
);
|
||||
return Right(taskId);
|
||||
} catch (e) {
|
||||
return Left(DeviceFailure.networkError(message: e.toString()));
|
||||
final errorMessage = e.toString();
|
||||
if (errorMessage.contains('当前设备切换模式失败')) {
|
||||
return Left(DeviceFailure('请检查遥控器模式后重试'));
|
||||
}
|
||||
return Left(DeviceFailure.networkError(message: errorMessage));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user