作业首页和机器状态的数据
This commit is contained in:
@@ -20,14 +20,29 @@ class HomeRoutes {
|
||||
static List<RouteBase> get routes => [
|
||||
GoRoute(
|
||||
path: RoutePaths.remoteControl,
|
||||
builder: (context, state) => BlocProvider(
|
||||
// 每次进入该路由,都会创建一个全新的 Cubit 并开启循环
|
||||
create: (context) => sl<RemoteControlCubit>()..startControlLoop(),
|
||||
// 🔥 必须用 .value:RemoteControlCubit 是 GetIt 的 registerLazySingleton
|
||||
// (injection.dart:540),不是本路由创建的。BlocProvider(create:) 的所有权
|
||||
// 语义是“我创建我销毁”,离开路由时它会对这个实例调用 close(),等于把
|
||||
// 全局单例关掉:
|
||||
// · 关掉后 startControlLoop 的 isClosed 守卫直接 return、所有 emit 被忽略,
|
||||
// 旧遥控页与新版 pv_control HUD 一起静默失灵(推杆不动 / 权限不刷新 /
|
||||
// 弹窗不弹),而 LazySingleton 不会重建,只能杀进程恢复;
|
||||
// · 护栏加之前更狠:每个迟到回调都抛 StateError(“Cannot emit new states
|
||||
// after calling close”)。
|
||||
// 下方 DeviceStatusBloc 用的就是 .value(“使用全局单例,确保数据流不中断”),
|
||||
// 遥控保持一致。原来的注释“每次进入都会创建一个全新的 Cubit”是错的。
|
||||
builder: (context, state) => BlocProvider.value(
|
||||
value: sl<RemoteControlCubit>(),
|
||||
child: const RemoteControlPage(),
|
||||
),
|
||||
),
|
||||
GoRoute(path: RoutePaths.routePlan, builder: (context, state) => const RoutePlanPage()),
|
||||
GoRoute(path: RoutePaths.djMap, builder: (context, state) => const DjPage()),
|
||||
// 场站 H5:从横屏「地图与区域编辑」进入时传 extra=true,退出用 pop 回来源页;
|
||||
// 从首页进入保持原来 go() 换栈行为不变。
|
||||
GoRoute(
|
||||
path: RoutePaths.djMap,
|
||||
builder: (context, state) => DjPage(exitToPop: state.extra == true),
|
||||
),
|
||||
GoRoute(path: RoutePaths.productDesc, builder: (context, state) => const ProductPage()),
|
||||
GoRoute(path: RoutePaths.usage, builder: (context, state) => const ManualPage()),
|
||||
GoRoute(
|
||||
|
||||
Reference in New Issue
Block a user