diff --git a/lib/core/translations/language/en_us.dart b/lib/core/translations/language/en_us.dart index e84caa5af..3541bb74a 100644 --- a/lib/core/translations/language/en_us.dart +++ b/lib/core/translations/language/en_us.dart @@ -540,6 +540,7 @@ const Map enUS = { "loadMoreMessages": "Load more messages...", "loadFailedClickRetry": "Load failed, click to retry", "swipeUpForMore": "Swipe up for more", + "callingTool": "I'm helping you, please wait!", // 正在帮您,请稍等! // 预设提示词 "presetMusic": "Play some music", // Play some music diff --git a/lib/core/translations/language/zh_cn.dart b/lib/core/translations/language/zh_cn.dart index 63d24ebbb..cfee20434 100644 --- a/lib/core/translations/language/zh_cn.dart +++ b/lib/core/translations/language/zh_cn.dart @@ -511,7 +511,7 @@ const Map zhCN = { "loadMoreMessages": "加载更多消息...", "loadFailedClickRetry": "加载失败,点击重试", "swipeUpForMore": "向上滑动查看更多", - "callingTool": "正在调用工具!", + "callingTool": "正在帮您,请稍等!", // 预设提示词 "presetMusic": "来点音乐", // 来点音乐 diff --git a/lib/modules/pairing/controllers/pairing_controller.dart b/lib/modules/pairing/controllers/pairing_controller.dart index ba9ed71f4..dced5ab47 100644 --- a/lib/modules/pairing/controllers/pairing_controller.dart +++ b/lib/modules/pairing/controllers/pairing_controller.dart @@ -807,13 +807,13 @@ class PairingController extends GetxController with WidgetsBindingObserver { } } else { //未绑定设备 - _bleManager.clearPairedDevices(); + Logger.i(_tag, '验证时BLE状态: $currentBleState'); if (currentBleState == 2) { //已连接 清理 // BleConnectionState.connected Logger.i(_tag, 'BLE已连接,断开并清理缓存'); - + _bleManager.clearPairedDevices(); _bleManager.disconnect(); } } @@ -944,6 +944,11 @@ class PairingController extends GetxController with WidgetsBindingObserver { } } } + final currentBleState = await _bleManager.getConnectionState(); + if (currentBleState == 2) { + _bleManager.clearPairedDevices(); + _bleManager.disconnect(); + } await Future.delayed(Duration(seconds: 1)); } _bleManager.stopScan(); diff --git a/local_plugins/agent_service/ios/agent_service/Sources/agent_service/AgentServiceImpl.swift b/local_plugins/agent_service/ios/agent_service/Sources/agent_service/AgentServiceImpl.swift index e9a756ebf..25e740417 100644 --- a/local_plugins/agent_service/ios/agent_service/Sources/agent_service/AgentServiceImpl.swift +++ b/local_plugins/agent_service/ios/agent_service/Sources/agent_service/AgentServiceImpl.swift @@ -27,6 +27,10 @@ class AgentServiceImpl: NSObject { static let shared = AgentServiceImpl() + // UserDefaults 相关常量 + private let PREF_NAME = "agent_service_prefs" + private let KEY_IS_INTERRUPT = "is_interrupt" + private var listeners = [AgentServiceListener]() private let listenersLock = NSLock() @@ -252,6 +256,8 @@ class AgentServiceImpl: NSObject { if isInitialized { loadChatHistory() + // 从 UserDefaults 加载 isInterrupt 状态 + loadIsInterruptFromCache() } LocationService.shared.getCurrentLocation() { location in // self.locationInfo = location @@ -2238,4 +2244,25 @@ extension AgentServiceImpl: AzureAsrHelper.ContinuousRecognizeCallback { stopRequestedDuringStart = false stopIdleCheck() } + + // MARK: - isInterrupt 缓存方法 + + /** + * 从 UserDefaults 加载 isInterrupt 状态 + */ + private func loadIsInterruptFromCache() { + let userDefaults = UserDefaults.standard + let cachedValue = userDefaults.bool(forKey: KEY_IS_INTERRUPT) // 默认值为 false + isInterrupt = cachedValue + os_log("从缓存加载 isInterrupt 状态: %{public}@", log: logger, type: .info, String(isInterrupt)) + } + + /** + * 保存 isInterrupt 状态到 UserDefaults + */ + func saveIsInterruptToCache(_ isInterrupt: Bool) { + let userDefaults = UserDefaults.standard + userDefaults.set(isInterrupt, forKey: KEY_IS_INTERRUPT) + os_log("保存 isInterrupt 状态到缓存: %{public}@", log: logger, type: .info, String(isInterrupt)) + } } diff --git a/local_plugins/agent_service/ios/agent_service/Sources/agent_service/AgentServicePlugin.swift b/local_plugins/agent_service/ios/agent_service/Sources/agent_service/AgentServicePlugin.swift index 6c7b0d36b..0877ab63e 100644 --- a/local_plugins/agent_service/ios/agent_service/Sources/agent_service/AgentServicePlugin.swift +++ b/local_plugins/agent_service/ios/agent_service/Sources/agent_service/AgentServicePlugin.swift @@ -79,8 +79,15 @@ public class AgentServicePlugin: NSObject, FlutterPlugin { impl.startRecognition(mode: mode) result(true) case "isInterrupt": - impl.isInterrupt = !impl.isInterrupt - result(impl.isInterrupt) + if let args = call.arguments as? [String: Any], + let isInterrupt = args["isinterrupt"] as? Bool { + impl.isInterrupt = isInterrupt + // 保存到 UserDefaults + impl.saveIsInterruptToCache(isInterrupt) + result(impl.isInterrupt) + } else { + result(FlutterError(code: "INVALID_ARGUMENTS", message: "isinterrupt 参数缺失或类型错误", details: nil)) + } case "recognizeCallback": impl.recognizeCallback()