import 'package:equatable/equatable.dart'; import 'package:maibu_satabot_v2/features/devices/domain/entities/device_entity.dart'; class DevicesState extends Equatable { final List devices; // 名下所有设备列表 final DeviceEntity? selectedDevice; // 当前主界面选中的/操作的设备 final bool isLoading; // 是否正在加载 final String? errorMessage; // 错误信息 final double? deviceLatitude; // 新增字段 final double? deviceLongitude; // 新增字段 final List>? workRecords; const DevicesState({ this.devices = const [], this.selectedDevice, this.isLoading = false, this.errorMessage, this.deviceLatitude, this.deviceLongitude, this.workRecords }); // 使用 copyWith 方便局部更新状态 DevicesState copyWith({ List? devices, DeviceEntity? selectedDevice, bool? isLoading, String? errorMessage, double? deviceLatitude, double? deviceLongitude, List>? workRecords, }) { return DevicesState( devices: devices ?? this.devices, selectedDevice: selectedDevice ?? this.selectedDevice, isLoading: isLoading ?? this.isLoading, errorMessage: errorMessage, // 错误信息通常每次更新都要重新赋值或清空 deviceLatitude: deviceLatitude ?? this.deviceLatitude, deviceLongitude: deviceLongitude ?? this.deviceLongitude, workRecords: workRecords ?? this.workRecords, ); } @override List get props => [devices, selectedDevice, isLoading, errorMessage, deviceLatitude, deviceLongitude, workRecords, ]; }