遗漏
This commit is contained in:
@@ -67,17 +67,24 @@ import '../../features/v2/home/domain/usecases/get_home_data_usecase.dart';
|
||||
import '../../features/v2/home/domain/usecases/get_site_list_usecase.dart';
|
||||
import '../../features/v2/home/presentation/bloc/home_v2_bloc.dart';
|
||||
import '../../features/v2/site/presentation/cubit/site_cubit.dart';
|
||||
import '../../features/v2/device_list/data/datasources/device_remote_datasource.dart' as device_v2;
|
||||
import '../../features/v2/device_list/data/repositories/device_repository_impl.dart' as device_v2_repo;
|
||||
import '../../features/v2/device_list/domain/repositories/device_repository.dart' as device_v2_domain;
|
||||
import '../../features/v2/device_list/domain/usecases/get_device_status_data_usecase.dart' as device_v2_usecase;
|
||||
import '../../features/v2/device_list/presentation/bloc/device_status_bloc.dart' as device_v2_bloc;
|
||||
import '../../features/v2/device_list/data/datasources/device_remote_datasource.dart'
|
||||
as device_v2;
|
||||
import '../../features/v2/device_list/data/repositories/device_repository_impl.dart'
|
||||
as device_v2_repo;
|
||||
import '../../features/v2/device_list/domain/repositories/device_repository.dart'
|
||||
as device_v2_domain;
|
||||
import '../../features/v2/device_list/domain/usecases/get_device_status_data_usecase.dart'
|
||||
as device_v2_usecase;
|
||||
import '../../features/v2/device_list/presentation/bloc/device_status_bloc.dart'
|
||||
as device_v2_bloc;
|
||||
import '../../features/v2/device_list/data/datasources/drone_station_datasource.dart';
|
||||
import '../../features/v2/device_list/data/datasources/drone_station_datasource_impl.dart';
|
||||
import '../../features/v2/device_list/data/repositories/drone_station_repository_impl.dart';
|
||||
import '../../features/v2/device_list/domain/repositories/drone_station_repository.dart';
|
||||
import '../../features/v2/device_list/domain/usecases/get_drone_station_list_usecase.dart';
|
||||
import '../../features/v2/device_list/domain/usecases/get_video_stream_usecase.dart';
|
||||
import '../../features/v2/device_list/presentation/bloc/drone_station_bloc.dart';
|
||||
import '../../features/v2/device_list/presentation/bloc/robot_list_bloc.dart';
|
||||
import '../../features/v2/waring_center/data/datasources/alarm_remote_datasource.dart';
|
||||
import '../../features/v2/waring_center/data/datasources/impl/alarm_remote_datasource_impl.dart';
|
||||
import '../../features/v2/waring_center/data/repositories/alarm_repository_impl.dart';
|
||||
@@ -85,6 +92,19 @@ import '../../features/v2/waring_center/domain/repositories/alarm_repository.dar
|
||||
import '../../features/v2/waring_center/domain/usecases/get_alarm_count_usecase.dart';
|
||||
import '../../features/v2/waring_center/domain/usecases/get_alarm_list_usecase.dart';
|
||||
import '../../features/v2/waring_center/presentation/bloc/alarm_cubit.dart';
|
||||
import '../../features/v2/waring_center/data/datasources/alarm_detail_remote_datasource.dart';
|
||||
import '../../features/v2/waring_center/data/datasources/impl/alarm_detail_remote_datasource_impl.dart';
|
||||
import '../../features/v2/waring_center/data/repositories/alarm_detail_repository_impl.dart';
|
||||
import '../../features/v2/waring_center/domain/repositories/alarm_detail_repository.dart';
|
||||
import '../../features/v2/waring_center/domain/usecases/get_alarm_detail_usecase.dart';
|
||||
import '../../features/v2/waring_center/domain/usecases/alarm_actions_usecase.dart';
|
||||
import '../../features/v2/waring_center/presentation/bloc/alarm_detail_cubit.dart';
|
||||
import '../../features/v2/message_center/data/datasources/message_center_remote_datasource.dart';
|
||||
import '../../features/v2/message_center/data/datasources/impl/message_center_remote_datasource_impl.dart';
|
||||
import '../../features/v2/message_center/data/repositories/message_center_repository_impl.dart';
|
||||
import '../../features/v2/message_center/domain/repositories/message_center_repository.dart';
|
||||
import '../../features/v2/message_center/domain/usecases/message_center_usecase.dart';
|
||||
import '../../features/v2/message_center/presentation/bloc/message_center_cubit.dart';
|
||||
import '../app/app_user_cubit.dart';
|
||||
import '../localization/locale_cubit.dart';
|
||||
import '../../features/home/presentation/bloc/permission_request_bloc.dart';
|
||||
@@ -105,17 +125,23 @@ Future<void> init() async {
|
||||
|
||||
/// 1.1.2 TcpClient:TCP客户端
|
||||
sl.registerLazySingleton(
|
||||
() => TcpClient(sl<UserStorage>(), getUserDeviceUseCase: sl<GetUserDeviceUseCase>(), switchDeviceUseCase: sl<SwitchDeviceUseCase>()),
|
||||
() => TcpClient(
|
||||
sl<UserStorage>(),
|
||||
getUserDeviceUseCase: sl<GetUserDeviceUseCase>(),
|
||||
switchDeviceUseCase: sl<SwitchDeviceUseCase>(),
|
||||
),
|
||||
);
|
||||
sl.registerLazySingleton(() => PathPlanningService());
|
||||
|
||||
/// 1.1.3 NetMessageDispatcher:消息调度器,并将 TcpClient 注入给它
|
||||
sl.registerLazySingleton(() => NetMessageDispatcher(
|
||||
sl<TcpClient>(),
|
||||
sl<RoutePlanningRepository>(),
|
||||
sl<PathPlanningService>(),
|
||||
getAppState: () => sl<DevicesCubit>().state.appState,
|
||||
));
|
||||
sl.registerLazySingleton(
|
||||
() => NetMessageDispatcher(
|
||||
sl<TcpClient>(),
|
||||
sl<RoutePlanningRepository>(),
|
||||
sl<PathPlanningService>(),
|
||||
getAppState: () => sl<DevicesCubit>().state.appState,
|
||||
),
|
||||
);
|
||||
|
||||
/// 1.2 --- 本地存储 (LocalStorage) ---
|
||||
/// 1.2.1 SharedPreferences:本地存储库
|
||||
@@ -132,16 +158,18 @@ Future<void> init() async {
|
||||
sl.registerLazySingleton<ILoggerService>(() => SentryLoggerImpl());
|
||||
|
||||
/// 2. 数据源 (DataSource)
|
||||
sl.registerLazySingleton<AuthHttpDataSource>(() => AuthHttpDataSourceImpl(sl()));
|
||||
sl.registerLazySingleton<AuthHttpDataSource>(
|
||||
() => AuthHttpDataSourceImpl(sl()),
|
||||
);
|
||||
sl.registerLazySingleton<DeviceHttpDatasource>(
|
||||
() => DeviceHttpDatasourceImpl(sl(), sl<UserStorage>()), //
|
||||
);
|
||||
sl.registerLazySingleton<RemoteHttpDatasource>(
|
||||
() => RemoteHttpDatasource(sl(), sl<UserStorage>()),
|
||||
() => RemoteHttpDatasource(sl(), sl<UserStorage>()),
|
||||
);
|
||||
|
||||
sl.registerLazySingleton<RemoteTcpDatasource>(
|
||||
() => RemoteTcpDatasource(sl<TcpClient>(), sl<UserStorage>()),
|
||||
() => RemoteTcpDatasource(sl<TcpClient>(), sl<UserStorage>()),
|
||||
);
|
||||
|
||||
/// 3. 仓库 (Repository)
|
||||
@@ -187,19 +215,27 @@ Future<void> init() async {
|
||||
);
|
||||
|
||||
sl.registerLazySingleton<DeviceRepository>(() => DeviceRepositoryImpl(sl()));
|
||||
sl.registerLazySingleton<RemoteControlRepository>(() => RemoteControlRepositoryImpl(sl(), sl() ,sl(),sl()));
|
||||
sl.registerLazySingleton<RemoteControlRepository>(
|
||||
() => RemoteControlRepositoryImpl(sl(), sl(), sl(), sl()),
|
||||
);
|
||||
|
||||
/// 4. 用例 (UseCase)
|
||||
sl.registerLazySingleton(() => LoginUseCase(sl()));
|
||||
sl.registerLazySingleton(() => GetUserDeviceUseCase(sl()));
|
||||
sl.registerLazySingleton(() => DiffSteerUseCase());
|
||||
sl.registerLazySingleton(() => DeviceWorkHostrirty(sl()));
|
||||
sl.registerLazySingleton<SelectWorkRecordUseCase>(() => SelectWorkRecordUseCase(sl<PathRepository>()));
|
||||
sl.registerLazySingleton<SelectWorkRecordUseCase>(
|
||||
() => SelectWorkRecordUseCase(sl<PathRepository>()),
|
||||
);
|
||||
sl.registerLazySingleton(() => UnbindDeviceUseCase(sl()));
|
||||
sl.registerLazySingleton(() => BindDeviceUseCase(sl()));
|
||||
sl.registerLazySingleton(() => UpdateDevicenameUsecase(sl()));
|
||||
sl.registerLazySingleton<SaveWorkRecordUseCase>(() => SaveWorkRecordUseCase(sl<PathRepository>()));
|
||||
sl.registerLazySingleton<SwitchDeviceUseCase>(() => SwitchDeviceUseCase(sl()));
|
||||
sl.registerLazySingleton<SaveWorkRecordUseCase>(
|
||||
() => SaveWorkRecordUseCase(sl<PathRepository>()),
|
||||
);
|
||||
sl.registerLazySingleton<SwitchDeviceUseCase>(
|
||||
() => SwitchDeviceUseCase(sl()),
|
||||
);
|
||||
|
||||
sl.registerLazySingleton<AuthTcpDatasource>(
|
||||
() => AuthTcpDatasourceImpl(
|
||||
@@ -210,73 +246,155 @@ Future<void> init() async {
|
||||
),
|
||||
);
|
||||
|
||||
sl.registerLazySingleton<RequestControlPermissionUseCase>(() => RequestControlPermissionUseCase(sl()));
|
||||
sl.registerLazySingleton<RequestControlPermissionUseCase>(
|
||||
() => RequestControlPermissionUseCase(sl()),
|
||||
);
|
||||
|
||||
/// Home V2
|
||||
sl.registerLazySingleton<HomeRemoteDataSource>(() => HomeRemoteDataSourceImpl());
|
||||
sl.registerLazySingleton<HomeRemoteDataSource>(
|
||||
() => HomeRemoteDataSourceImpl(),
|
||||
);
|
||||
sl.registerLazySingleton<HomeRepository>(() => HomeRepositoryImpl(sl()));
|
||||
sl.registerLazySingleton<GetHomeDataUseCase>(() => GetHomeDataUseCase(sl()));
|
||||
|
||||
|
||||
// Site (场站)
|
||||
sl.registerLazySingleton<SiteDataSource>(() => SiteDataSourceImpl(sl<Dio>()));
|
||||
sl.registerLazySingleton<SiteRepository>(() => SiteRepositoryImpl(sl()));
|
||||
sl.registerLazySingleton<GetSiteListUseCase>(() => GetSiteListUseCase(sl()));
|
||||
|
||||
sl.registerFactory<HomeV2Bloc>(() => HomeV2Bloc(sl(), sl(), sl<AppUserCubit>(), sl<SiteCubit>()));
|
||||
|
||||
sl.registerFactory<HomeV2Bloc>(
|
||||
() => HomeV2Bloc(sl(), sl(), sl<AppUserCubit>(), sl<SiteCubit>()),
|
||||
);
|
||||
|
||||
/// Device Status V2
|
||||
sl.registerLazySingleton<device_v2.DeviceRemoteDataSource>(() => device_v2.DeviceRemoteDataSourceImpl());
|
||||
sl.registerLazySingleton<device_v2_domain.DeviceRepository>(() => device_v2_repo.DeviceRepositoryImpl(remoteDataSource: sl()));
|
||||
sl.registerLazySingleton<device_v2_usecase.GetDeviceStatusDataUseCase>(() => device_v2_usecase.GetDeviceStatusDataUseCase(repository: sl()));
|
||||
sl.registerFactory<device_v2_bloc.DeviceStatusBloc>(() => device_v2_bloc.DeviceStatusBloc(sl()));
|
||||
sl.registerLazySingleton<device_v2.DeviceRemoteDataSource>(
|
||||
() => device_v2.DeviceRemoteDataSourceImpl(sl<Dio>()),
|
||||
);
|
||||
sl.registerLazySingleton<device_v2_domain.DeviceRepository>(
|
||||
() => device_v2_repo.DeviceRepositoryImpl(remoteDataSource: sl()),
|
||||
);
|
||||
sl.registerLazySingleton<device_v2_usecase.GetDeviceStatusDataUseCase>(
|
||||
() => device_v2_usecase.GetDeviceStatusDataUseCase(repository: sl()),
|
||||
);
|
||||
sl.registerFactory<device_v2_bloc.DeviceStatusBloc>(
|
||||
() => device_v2_bloc.DeviceStatusBloc(sl()),
|
||||
);
|
||||
|
||||
/// Drone Station V2
|
||||
sl.registerLazySingleton<DroneStationDataSource>(() => DroneStationDataSourceImpl(sl<Dio>()));
|
||||
sl.registerLazySingleton<DroneStationRepository>(() => DroneStationRepositoryImpl(sl()));
|
||||
sl.registerLazySingleton<GetDroneStationListUseCase>(() => GetDroneStationListUseCase(sl()));
|
||||
sl.registerLazySingleton<GetUAVDetailUseCase>(() => GetUAVDetailUseCase(sl()));
|
||||
sl.registerFactory<DroneStationBloc>(() => DroneStationBloc(sl(), sl()));
|
||||
sl.registerLazySingleton<DroneStationDataSource>(
|
||||
() => DroneStationDataSourceImpl(sl<Dio>()),
|
||||
);
|
||||
sl.registerLazySingleton<DroneStationRepository>(
|
||||
() => DroneStationRepositoryImpl(sl()),
|
||||
);
|
||||
sl.registerLazySingleton<GetDroneStationListUseCase>(
|
||||
() => GetDroneStationListUseCase(sl()),
|
||||
);
|
||||
sl.registerLazySingleton<GetUAVDetailUseCase>(
|
||||
() => GetUAVDetailUseCase(sl()),
|
||||
);
|
||||
sl.registerLazySingleton<GetVideoStreamUseCase>(
|
||||
() => GetVideoStreamUseCase(sl()),
|
||||
);
|
||||
sl.registerFactory<DroneStationBloc>(
|
||||
() => DroneStationBloc(sl(), sl(), sl()),
|
||||
);
|
||||
|
||||
/// Robot List V2
|
||||
sl.registerFactory<RobotListBloc>(
|
||||
() => RobotListBloc(sl<Dio>()),
|
||||
);
|
||||
|
||||
/// Alarm Center V2
|
||||
sl.registerLazySingleton<AlarmRemoteDataSource>(() => AlarmRemoteDataSourceImpl());
|
||||
sl.registerLazySingleton<AlarmRemoteDataSource>(
|
||||
() => AlarmRemoteDataSourceImpl(),
|
||||
);
|
||||
sl.registerLazySingleton<AlarmRepository>(() => AlarmRepositoryImpl(sl()));
|
||||
sl.registerLazySingleton<GetAlarmListUseCase>(() => GetAlarmListUseCase(sl()));
|
||||
sl.registerLazySingleton<GetAlarmCountUseCase>(() => GetAlarmCountUseCase(sl()));
|
||||
sl.registerFactory<AlarmCubit>(() => AlarmCubit(
|
||||
getAlarmListUseCase: sl(),
|
||||
getAlarmCountUseCase: sl(),
|
||||
));
|
||||
sl.registerLazySingleton<GetAlarmListUseCase>(
|
||||
() => GetAlarmListUseCase(sl()),
|
||||
);
|
||||
sl.registerLazySingleton<GetAlarmCountUseCase>(
|
||||
() => GetAlarmCountUseCase(sl()),
|
||||
);
|
||||
sl.registerFactory<AlarmCubit>(
|
||||
() => AlarmCubit(getAlarmListUseCase: sl(), getAlarmCountUseCase: sl()),
|
||||
);
|
||||
|
||||
/// Alarm Detail V2
|
||||
sl.registerLazySingleton<AlarmDetailRemoteDataSource>(
|
||||
() => AlarmDetailRemoteDataSourceImpl(),
|
||||
);
|
||||
sl.registerLazySingleton<AlarmDetailRepository>(
|
||||
() => AlarmDetailRepositoryImpl(sl()),
|
||||
);
|
||||
sl.registerLazySingleton<GetAlarmDetailUseCase>(
|
||||
() => GetAlarmDetailUseCase(sl()),
|
||||
);
|
||||
sl.registerLazySingleton<ConfirmAlarmUseCase>(
|
||||
() => ConfirmAlarmUseCase(sl()),
|
||||
);
|
||||
sl.registerLazySingleton<AIDiagnosisUseCase>(
|
||||
() => AIDiagnosisUseCase(sl()),
|
||||
);
|
||||
sl.registerFactory<AlarmDetailCubit>(
|
||||
() => AlarmDetailCubit(
|
||||
getAlarmDetailUseCase: sl(),
|
||||
confirmAlarmUseCase: sl(),
|
||||
aiDiagnosisUseCase: sl(),
|
||||
),
|
||||
);
|
||||
|
||||
/// 5. 状态管理 (Cubit/Bloc)
|
||||
sl.registerLazySingleton(() => AppUserCubit()); // AuthCubit 依赖它,必须先注册
|
||||
|
||||
|
||||
// 🔥 SiteCubit (全局共享,持久化选中场站)
|
||||
sl.registerLazySingleton(() => SiteCubit(sl<SharedPreferences>()));
|
||||
|
||||
|
||||
// 🔥 语言管理 Cubit (单例)
|
||||
sl.registerLazySingleton(() => LocaleCubit());
|
||||
|
||||
|
||||
// Tab 配置 Cubit (单例)
|
||||
sl.registerLazySingleton(() => TabConfigCubit(sl<SharedPreferences>()));
|
||||
|
||||
|
||||
sl.registerLazySingleton(() => GetDeviceLocationUseCase(sl()));
|
||||
sl.registerLazySingleton(() => DevicesCubit(sl(), sl(), sl(), sl(), sl(), sl(), sl(), sl(), sl(), sl(), sl(), sl(),sl(),sl(),sl()));
|
||||
|
||||
sl.registerLazySingleton(
|
||||
() => DevicesCubit(
|
||||
sl(),
|
||||
sl(),
|
||||
sl(),
|
||||
sl(),
|
||||
sl(),
|
||||
sl(),
|
||||
sl(),
|
||||
sl(),
|
||||
sl(),
|
||||
sl(),
|
||||
sl(),
|
||||
sl(),
|
||||
sl(),
|
||||
sl(),
|
||||
sl(),
|
||||
),
|
||||
);
|
||||
|
||||
// 🔥 DeviceStatusBloc 必须在 RemoteControlCubit 之前注册(单例)
|
||||
sl.registerLazySingleton(() => DeviceStatusBloc(
|
||||
sl<NetMessageDispatcher>(),
|
||||
client: sl<TcpClient>(), // 🔥 传入 TcpClient
|
||||
));
|
||||
|
||||
sl.registerLazySingleton(
|
||||
() => DeviceStatusBloc(
|
||||
sl<NetMessageDispatcher>(),
|
||||
client: sl<TcpClient>(), // 🔥 传入 TcpClient
|
||||
),
|
||||
);
|
||||
|
||||
// 🔥 RemoteControlCubit 注入 DeviceStatusBloc(工厂模式,每次新建)
|
||||
sl.registerFactory(() => RemoteControlCubit(sl(), sl(), sl(), sl()));
|
||||
|
||||
// 🔥 PermissionRequestBloc 用于首页权限弹窗(单例,通过 NetMessageDispatcher 监听)
|
||||
sl.registerLazySingleton(() => PermissionRequestBloc(
|
||||
sl<NetMessageDispatcher>(),
|
||||
sl<RemoteControlRepository>(),
|
||||
));
|
||||
sl.registerLazySingleton(
|
||||
() => PermissionRequestBloc(
|
||||
sl<NetMessageDispatcher>(),
|
||||
sl<RemoteControlRepository>(),
|
||||
),
|
||||
);
|
||||
|
||||
/// . 路径生成
|
||||
sl.registerLazySingleton<PathHttpDatasource>(
|
||||
@@ -285,8 +403,12 @@ Future<void> init() async {
|
||||
sl<UserStorage>(),
|
||||
),
|
||||
);
|
||||
sl.registerLazySingleton<PathRepository>(() => PathRepositoryImpl(datasource: sl<PathHttpDatasource>()));
|
||||
sl.registerLazySingleton<GeneratePathUseCase>(() => GeneratePathUseCaseImpl(sl<PathRepository>()));
|
||||
sl.registerLazySingleton<PathRepository>(
|
||||
() => PathRepositoryImpl(datasource: sl<PathHttpDatasource>()),
|
||||
);
|
||||
sl.registerLazySingleton<GeneratePathUseCase>(
|
||||
() => GeneratePathUseCaseImpl(sl<PathRepository>()),
|
||||
);
|
||||
|
||||
///.路径获取和删除
|
||||
sl.registerLazySingleton(() => GetWorkRecordUseCase(sl<PathRepository>()));
|
||||
@@ -294,7 +416,15 @@ Future<void> init() async {
|
||||
|
||||
/// 6. 认证 (Auth)
|
||||
// --- 关键修改点 1: AuthCubit 必须在 GoRouter 之前注册,并传入参数 ---
|
||||
sl.registerLazySingleton(() => AuthCubit(sl<UserStorage>(), sl<TcpClient>(), sl<AppUserCubit>(), sl<NetMessageDispatcher>(), sl<AuthTcpDatasource>()));
|
||||
sl.registerLazySingleton(
|
||||
() => AuthCubit(
|
||||
sl<UserStorage>(),
|
||||
sl<TcpClient>(),
|
||||
sl<AppUserCubit>(),
|
||||
sl<NetMessageDispatcher>(),
|
||||
sl<AuthTcpDatasource>(),
|
||||
),
|
||||
);
|
||||
|
||||
/// 7. 路由 (Router)
|
||||
sl.registerSingleton<GoRouter>(createRouter(sl<AuthCubit>()));
|
||||
@@ -302,4 +432,24 @@ Future<void> init() async {
|
||||
/// 8. 页面级 Bloc/Cubit (Factory)
|
||||
sl.registerFactory(() => LoginBloc(sl()));
|
||||
sl.registerFactory(() => LoginCubit(sl(), sl()));
|
||||
|
||||
/// 9. 消息中心 (Message Center)
|
||||
sl.registerLazySingleton<MessageCenterRemoteDataSource>(
|
||||
() => MessageCenterRemoteDataSourceImpl(),
|
||||
);
|
||||
sl.registerLazySingleton<MessageCenterRepository>(
|
||||
() => MessageCenterRepositoryImpl(sl()),
|
||||
);
|
||||
sl.registerLazySingleton<GetMessageListUseCase>(
|
||||
() => GetMessageListUseCase(sl()),
|
||||
);
|
||||
sl.registerLazySingleton<MarkAllAsReadUseCase>(
|
||||
() => MarkAllAsReadUseCase(sl()),
|
||||
);
|
||||
sl.registerFactory<MessageCenterCubit>(
|
||||
() => MessageCenterCubit(
|
||||
getMessageListUseCase: sl(),
|
||||
markAllAsReadUseCase: sl(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user