我的界面 修改昵称完成
This commit is contained in:
@@ -11,6 +11,10 @@ import 'package:maibu_satabot_v2/features/devices/domain/usecases/select_work_re
|
||||
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';
|
||||
import 'package:maibu_satabot_v2/features/devices/presentation/bloc/devices_cubit.dart';
|
||||
import 'package:maibu_satabot_v2/features/my/presentation/bloc/my_cubit.dart';
|
||||
import 'package:maibu_satabot_v2/features/my/repository/my_repository.dart';
|
||||
import 'package:maibu_satabot_v2/features/my/repository/my_repository_impl.dart';
|
||||
import 'package:maibu_satabot_v2/features/my/usecases/updatename_usecase.dart';
|
||||
import 'package:maibu_satabot_v2/features/remote_control/data/repositories/remote_control_repository_impl.dart';
|
||||
import 'package:maibu_satabot_v2/features/remote_control/domain/repositories/remote_control_repository.dart';
|
||||
import 'package:maibu_satabot_v2/features/remote_control/domain/usecase/diff_steer_usecase.dart';
|
||||
@@ -64,9 +68,9 @@ Future<void> init() async {
|
||||
sl.registerLazySingleton<Dio>(() => DioClient.create());
|
||||
|
||||
/// 1.1.2 TcpClient:TCP客户端
|
||||
sl.registerLazySingleton(() => TcpClient( sl<UserStorage>(),
|
||||
getUserDeviceUseCase: sl<GetUserDeviceUseCase>(),
|
||||
switchDeviceUseCase: sl<SwitchDeviceUseCase>(),));
|
||||
sl.registerLazySingleton(
|
||||
() => TcpClient(sl<UserStorage>(), getUserDeviceUseCase: sl<GetUserDeviceUseCase>(), switchDeviceUseCase: sl<SwitchDeviceUseCase>()),
|
||||
);
|
||||
|
||||
/// 1.1.3 NetMessageDispatcher:消息调度器,并将 TcpClient 注入给它
|
||||
sl.registerLazySingleton(() => NetMessageDispatcher(sl()));
|
||||
@@ -86,11 +90,9 @@ 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>()), //
|
||||
() => DeviceHttpDatasourceImpl(sl(), sl<UserStorage>()), //
|
||||
);
|
||||
|
||||
/// 3. 仓库 (Repository)
|
||||
@@ -101,16 +103,32 @@ Future<void> init() async {
|
||||
),
|
||||
);
|
||||
|
||||
// 1. 注册 UpdateNameUsecase
|
||||
sl.registerLazySingleton<UpdateNameUsecase>(
|
||||
() => UpdateNameUsecase(sl<MyRepository>()), // 注入 MyRepository 实例
|
||||
);
|
||||
sl.registerLazySingleton<MyRepository>(
|
||||
() => MyRepositoryImpl(
|
||||
userStorage: sl<UserStorage>(), // 注入 UserStorage
|
||||
),
|
||||
);
|
||||
|
||||
// 2. 注册 MyCubit
|
||||
sl.registerLazySingleton<MyCubit>(
|
||||
() => MyCubit(
|
||||
sl<MyRepository>(), // 注入仓库
|
||||
sl<UpdateNameUsecase>(), // 注入 UseCase
|
||||
),
|
||||
);
|
||||
|
||||
sl.registerLazySingleton<RoutePlanningRepository>(
|
||||
() => RoutePlanningRepositoryImpl(tcp: sl<TcpClient>()), //
|
||||
() => RoutePlanningRepositoryImpl(tcp: sl<TcpClient>()), //
|
||||
);
|
||||
|
||||
sl.registerLazySingleton<RoutePlanningUseCase>(
|
||||
() => RoutePlanningUseCase(sl<RoutePlanningRepository>()), //
|
||||
() => RoutePlanningUseCase(sl<RoutePlanningRepository>()), //
|
||||
);
|
||||
|
||||
|
||||
|
||||
//工作历史
|
||||
sl.registerLazySingleton<DeviceHostrityWorkRepositoryRepository>(
|
||||
() => DeviceHostrityWorkRepositoryImpl(
|
||||
@@ -120,9 +138,7 @@ Future<void> init() async {
|
||||
);
|
||||
|
||||
sl.registerLazySingleton<DeviceRepository>(() => DeviceRepositoryImpl(sl()));
|
||||
sl.registerLazySingleton<RemoteControlRepository>(
|
||||
() => RemoteControlRepositoryImpl(sl(), sl()),
|
||||
);
|
||||
sl.registerLazySingleton<RemoteControlRepository>(() => RemoteControlRepositoryImpl(sl(), sl()));
|
||||
|
||||
/// 4. 用例 (UseCase)
|
||||
sl.registerLazySingleton(() => LoginUseCase(sl()));
|
||||
@@ -137,7 +153,7 @@ Future<void> init() async {
|
||||
sl.registerLazySingleton<SwitchDeviceUseCase>(() => SwitchDeviceUseCase(sl()));
|
||||
|
||||
sl.registerLazySingleton<AuthTcpDatasource>(
|
||||
() => AuthTcpDatasourceImpl(
|
||||
() => AuthTcpDatasourceImpl(
|
||||
sl<TcpClient>(),
|
||||
sl<UserStorage>(),
|
||||
getUserDeviceUseCase: sl<GetUserDeviceUseCase>(),
|
||||
@@ -145,15 +161,12 @@ Future<void> init() async {
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
/// 5. 状态管理 (Cubit/Bloc)
|
||||
sl.registerLazySingleton(() => AppUserCubit()); // AuthCubit 依赖它,必须先注册
|
||||
sl.registerLazySingleton(() => GetDeviceLocationUseCase(sl()));
|
||||
sl.registerLazySingleton(
|
||||
() => DevicesCubit(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.registerFactory(() => RemoteControlCubit(sl()));
|
||||
/* // 工厂模式(留存,每次获取新实例)
|
||||
/* // 工厂模式(留存,每次获取新实例)
|
||||
sl.registerFactory(() => DeviceStatusBloc(sl<NetMessageDispatcher>()));
|
||||
*/
|
||||
//单例模式(全局共享一个实例)
|
||||
@@ -161,16 +174,13 @@ Future<void> init() async {
|
||||
|
||||
/// . 路径生成
|
||||
sl.registerLazySingleton<PathHttpDatasource>(
|
||||
() => PathHttpDatasourceImpl(// 需先注册 http.Client(见下方)
|
||||
() => PathHttpDatasourceImpl(
|
||||
// 需先注册 http.Client(见下方)
|
||||
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>()));
|
||||
@@ -178,15 +188,7 @@ 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>()));
|
||||
|
||||
Reference in New Issue
Block a user