解决了渲染TCP推送数据,在切换功能后不稳定问题,保证了APP端的稳定性。

This commit is contained in:
2026-04-22 15:16:30 +08:00
parent 0402d2f3f5
commit e8a23559d4
9 changed files with 179 additions and 85 deletions

View File

@@ -185,13 +185,15 @@ Future<void> init() async {
sl.registerLazySingleton(() => AppUserCubit()); // AuthCubit 依赖它,必须先注册
sl.registerLazySingleton(() => GetDeviceLocationUseCase(sl()));
sl.registerLazySingleton(() => DevicesCubit(sl(), sl(), sl(), sl(), sl(), sl(), sl(), sl(), sl(), sl(), sl(), sl(),sl(),sl(),sl()));
sl.registerFactory(() => RemoteControlCubit(sl(),sl(),sl()));
/* // 工厂模式(留存,每次获取新实例)r
sl.registerFactory(() => DeviceStatusBloc(sl<NetMessageDispatcher>()));
*/
//单例模式(全局共享一个实例)
sl.registerLazySingleton(() => DeviceStatusBloc(sl<NetMessageDispatcher>()));
// 🔥 DeviceStatusBloc 必须在 RemoteControlCubit 之前注册(单例)
sl.registerLazySingleton(() => DeviceStatusBloc(
sl<NetMessageDispatcher>(),
client: sl<TcpClient>(), // 🔥 传入 TcpClient
));
// 🔥 RemoteControlCubit 注入 DeviceStatusBloc(工厂模式,每次新建)
sl.registerFactory(() => RemoteControlCubit(sl(), sl(), sl(), sl()));
/// . 路径生成
sl.registerLazySingleton<PathHttpDatasource>(