You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.7 KiB
45 lines
1.7 KiB
import 'package:get/get.dart';
|
|
import '../../core/controllers/permission_controller.dart';
|
|
import '../../data/services/audio_service.dart';
|
|
import '../../data/services/notification_service.dart';
|
|
import '../../data/services/volcano_ai_service.dart';
|
|
import '../../data/services/voice_recognition_service.dart';
|
|
import '../../data/services/volcano_tts_service.dart';
|
|
|
|
/// 初始绑定,用于管理全局依赖
|
|
class InitialBinding extends Bindings {
|
|
@override
|
|
void dependencies() {
|
|
// 初始化所有服务
|
|
final notificationService = Get.put(NotificationService(), permanent: true);
|
|
final audioService = Get.put(AudioServiceManager(), permanent: true);
|
|
final volcanoAiService = Get.put(VolcanoAIService(), permanent: true);
|
|
final voiceRecognitionService = Get.put(VoiceRecognitionService(), permanent: true);
|
|
final volcanoTtsService = Get.put(VolcanoTtsService(), permanent: true);
|
|
|
|
// 只注册全局控制器
|
|
Get.put(PermissionController(), permanent: true);
|
|
|
|
// 异步初始化各个服务
|
|
_initializeServices(notificationService, audioService);
|
|
}
|
|
|
|
// 单独提取初始化服务的方法,以便更好地处理错误
|
|
void _initializeServices(NotificationService notificationService, AudioServiceManager audioService) {
|
|
// 初始化通知服务
|
|
notificationService.init().catchError((error) {
|
|
print('通知服务初始化失败: $error');
|
|
return null;
|
|
});
|
|
|
|
// 初始化音频服务
|
|
audioService.init().then((_) {
|
|
print('AudioServiceManager 初始化完成,可以接收蓝牙耳机按键事件');
|
|
}).catchError((error) {
|
|
print('音频服务初始化失败: $error');
|
|
return null;
|
|
});
|
|
|
|
// 其他服务初始化可以在这里添加
|
|
}
|
|
}
|