52 lines
1.7 KiB
Dart
52 lines
1.7 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:get/get.dart';
|
|
|
|
import 'package:pj_supermarket_cloud/common/index.dart';
|
|
|
|
/// Load 页控制器:只读取 AppControl 发布的真实启动步骤状态,
|
|
/// 业务初始化由应用入口微任务统一驱动,页面不重复打开数据库或设备。
|
|
class LoadController extends GetxController {
|
|
static const String _tag = "load Controller";
|
|
|
|
AppControl get appControl => Get.find<AppControl>();
|
|
|
|
/// 虹软整库注册的最新进度文案;装载人脸库期间展示在步骤列表下方。
|
|
final faceRegistrationMessage = ''.obs;
|
|
|
|
StreamSubscription<FaceRegistrationProgress>? _registrationSubscription;
|
|
|
|
@override
|
|
void onInit() {
|
|
super.onInit();
|
|
// 注册进度事件通道订阅即回放最近一次进度,
|
|
// 启动装载人脸库时给收银员实时反馈,避免最长的步骤只有静态“进行中”。
|
|
_registrationSubscription = FaceDiscernPlugs.registrationStream.listen(
|
|
(progress) {
|
|
faceRegistrationMessage.value =
|
|
progress.inProgress && progress.message.trim().isNotEmpty
|
|
? progress.message.trim()
|
|
: '';
|
|
},
|
|
onError: (Object error, StackTrace stack) {
|
|
logger.w('|$_tag|注册进度监听失败error:$error|stack:$stack|');
|
|
},
|
|
);
|
|
}
|
|
|
|
@override
|
|
void onClose() {
|
|
_registrationSubscription?.cancel();
|
|
super.onClose();
|
|
}
|
|
|
|
List<AppStartupStepState> get startupSteps => appControl.startupSteps;
|
|
|
|
int get completedCount => appControl.startupCompletedCount;
|
|
|
|
double get progress => appControl.startupProgress;
|
|
|
|
/// 失败后重新执行启动链路;进行中的初始化会被 AppControl 自身防重入拦截。
|
|
Future<void> retry() => appControl.initAsync(force: true);
|
|
}
|