退出登录+机器状态+切换设备+历史作业记录+设备信息
This commit is contained in:
@@ -44,16 +44,26 @@ class MyApp extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// 在 runApp 之前调用 appStarted,确保 GoRouter 初始化时能获取到正确的初始状态
|
||||
sl<AuthCubit>().appStarted();
|
||||
|
||||
return MultiBlocProvider(
|
||||
providers: [
|
||||
//BlocProvider<LoginBloc>(create: (_) => sl<LoginBloc>()),
|
||||
// 核心修正:在这里提供 AuthCubit
|
||||
BlocProvider<AuthCubit>(create: (_) => sl<AuthCubit>()),
|
||||
|
||||
BlocProvider<AppUserCubit>(create: (_) => sl<AppUserCubit>()),
|
||||
BlocProvider<LoginCubit>(create: (_) => sl<LoginCubit>()),
|
||||
BlocProvider<DevicesCubit>(
|
||||
create: (_) =>
|
||||
sl<DevicesCubit>()
|
||||
..fetchAllDevices(sl<AppUserCubit>().state.user!.username),
|
||||
create: (_) {
|
||||
// 增加一个健壮性检查
|
||||
final user = sl<AppUserCubit>().state.user;
|
||||
final devicesCubit = sl<DevicesCubit>();
|
||||
if (user != null) {
|
||||
devicesCubit.fetchAllDevices(user.username);
|
||||
}
|
||||
return devicesCubit;
|
||||
},
|
||||
),
|
||||
],
|
||||
child: MaterialApp.router(
|
||||
|
||||
Reference in New Issue
Block a user