同步 oneApp 的代码

This commit is contained in:
2025-09-17 15:09:05 +08:00
parent 62924296b2
commit 33aef48f84
21 changed files with 597 additions and 186 deletions

View File

@@ -21,7 +21,7 @@ import 'command_service.dart';
import 'package:fluttertoast/fluttertoast.dart';
class MessageService extends ChangeNotifier {
static const MethodChannel _asrChannel = MethodChannel('com.example.ai_chat_assistant/asr');
static const MethodChannel _asrChannel = MethodChannel('com.example.ai_chat_assistant/ali_sdk');
static final MessageService _instance = MessageService._internal();
@@ -61,7 +61,7 @@ class MessageService extends ChangeNotifier {
// final AudioRecorderService _audioService = AudioRecorderService();
// final VoiceRecognitionService _recognitionService = VoiceRecognitionService();
final TextClassificationService _classificationService =
TextClassificationService();
TextClassificationService();
final VehicleCommandService _vehicleCommandService = VehicleCommandService();
final List<ChatMessage> _messages = [];
@@ -106,7 +106,6 @@ class MessageService extends ChangeNotifier {
abortReply();
_latestUserMessageId = null;
_latestAssistantMessageId = null;
_isReplyAborted = false;
changeState(MessageServiceState.recording);
_latestUserMessageId = addMessage("", true, MessageStatus.listening);
_asrChannel.invokeMethod("startAsr");
@@ -138,6 +137,7 @@ class MessageService extends ChangeNotifier {
return;
}
try {
_isReplyAborted = false;
changeState(MessageServiceState.recognizing);
_asrChannel.invokeMethod("stopAsr");
_asrCompleter = Completer<String>();
@@ -227,7 +227,7 @@ class MessageService extends ChangeNotifier {
return;
}
final vehicleCommandResponse =
await _vehicleCommandService.getCommandFromText(text);
await _vehicleCommandService.getCommandFromText(text);
if (vehicleCommandResponse == null) {
if (_isReplyAborted) {
return;
@@ -269,12 +269,12 @@ class MessageService extends ChangeNotifier {
bool isSuccess;
if (containOpenAC && command.type == VehicleCommandType.changeACTemp) {
isSuccess = await Future.delayed(const Duration(milliseconds: 2000),
() => processCommand(command, isChinese));
() => processCommand(command, isChinese));
} else {
isSuccess = await processCommand(command, isChinese);
}
if (isSuccess) {
successCommandList.add(command.type.name);
successCommandList.add(isChinese ? command.type.chinese : command.type.english);
}
}
replaceMessage(
@@ -286,7 +286,7 @@ class MessageService extends ChangeNotifier {
return;
}
String controlResponse =
await _vehicleCommandService.getControlResponse(successCommandList);
await _vehicleCommandService.getControlResponse(successCommandList);
if (_isReplyAborted || controlResponse.isEmpty) {
return;
}