From e36c1cae932500183a8aabb2475dce6e9153322f Mon Sep 17 00:00:00 2001 From: Songzex <2402265378@qq.com> Date: Sat, 28 Feb 2026 09:01:05 +0800 Subject: [PATCH] =?UTF-8?q?1=EF=BC=8C=E8=A1=A5=E5=85=85=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E5=88=97=E8=A1=A8=E4=B8=AD=E7=9A=84=E4=B8=80?= =?UTF-8?q?=E9=A1=B9=E6=8E=A5=E5=8F=A3=E7=9A=84cubit=E5=B1=82=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/bloc/devices_cubit.dart | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/features/devices/presentation/bloc/devices_cubit.dart b/lib/features/devices/presentation/bloc/devices_cubit.dart index 40fe037d..327d77d1 100644 --- a/lib/features/devices/presentation/bloc/devices_cubit.dart +++ b/lib/features/devices/presentation/bloc/devices_cubit.dart @@ -1,7 +1,9 @@ +import 'package:flutter/rendering.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:maibu_satabot_v2/features/devices/domain/entities/device_entity.dart'; import 'package:maibu_satabot_v2/features/devices/domain/repositories/device_repository.dart'; import 'package:maibu_satabot_v2/features/devices/domain/usecases/get_user_device_usecase.dart'; +import 'package:maibu_satabot_v2/features/devices/domain/usecases/select_work_record_usecase.dart'; import 'package:maibu_satabot_v2/features/devices/domain/usecases/unbind_device_usecase.dart'; import 'package:maibu_satabot_v2/features/devices/domain/usecases/update_devicename_usecase.dart'; @@ -18,6 +20,7 @@ class DevicesCubit extends Cubit { final DeleteWorkRecordUseCase _deleteWorkRecordUseCase; final UnbindDeviceUseCase _unbindDeviceUseCase; final UpdateDevicenameUsecase _updateDevicename; + final SelectWorkRecordUseCase _selectWorkRecordUseCase; DevicesCubit( this.repository, @@ -27,6 +30,7 @@ class DevicesCubit extends Cubit { this._deleteWorkRecordUseCase, this._unbindDeviceUseCase, this._updateDevicename, + this._selectWorkRecordUseCase ) : super(const DevicesState()); Future unbindDevice(String deviceId, String deviceName) async { @@ -258,4 +262,18 @@ class DevicesCubit extends Cubit { ), ); } + /// 加载指定作业名的路径数据 + Future loadSelectedPath(String workName) async { + emit(state.copyWith(isLoading: true)); + try { + final result = await _selectWorkRecordUseCase.call(workName); + result.fold( + (failure) => emit(state.copyWith(isLoading: false, errorMessage: failure.message)), + (data) => emit(state.copyWith(isLoading: false, pathData: data)), + ); + } catch (e) { + emit(state.copyWith(isLoading: false, errorMessage: e.toString())); + } + } + }