From 95a21742bae023b6631d2d232c711a35b6db9955 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Mon, 13 Oct 2025 16:56:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../agent/controllers/agent_controller.dart | 37 ++++++++++++++++++- .../agent_service/AgentServiceImpl.swift | 12 ++++-- 2 files changed, 45 insertions(+), 4 deletions(-) diff --git a/lib/modules/agent/controllers/agent_controller.dart b/lib/modules/agent/controllers/agent_controller.dart index af7d81d0d..f8ec07f3e 100644 --- a/lib/modules/agent/controllers/agent_controller.dart +++ b/lib/modules/agent/controllers/agent_controller.dart @@ -2073,7 +2073,7 @@ class AgentController extends GetxController with WidgetsBindingObserver { color: Colors.grey.withOpacity(0.1), borderRadius: BorderRadius.circular(8), ), - child: const Icon(Icons.navigation, color: Colors.grey), + child: const Icon(Icons.navigation, color: Colors.orange), ), title: const Text('苹果地图'), subtitle: const Text('使用苹果地图导航'), @@ -2082,6 +2082,23 @@ class AgentController extends GetxController with WidgetsBindingObserver { openAppleMap(destination, mode); }, ), + ListTile( + leading: Container( + padding: const EdgeInsets.all(8), + decoration: BoxDecoration( + color: Colors.grey.withOpacity(0.1), + borderRadius: BorderRadius.circular(8), + ), + child: const Icon(Icons.navigation, color: Colors.grey), + ), + title: const Text('内置导航'), + subtitle: const Text('使用内置地图导航'), + onTap: () { + Get.back(); + openInternalGaodeMap( + start, destination, endlatitude, endlongitude, mode); + }, + ), // 底部安全区域 SizedBox(height: MediaQuery.of(Get.context!).padding.bottom + 20), ], @@ -2503,6 +2520,24 @@ class AgentController extends GetxController with WidgetsBindingObserver { } } + /// 打开内置高德地图进行导航 + Future openInternalGaodeMap( + String start, + String destination, + String endlatitude, + String endlongitude, + String mode // 'driving', 'transit', 'walking', 'cycling' + ) async { + try { + _navigationManager.open(start, "$endlongitude,$endlatitude", mode); + return true; + } catch (e) { + print('打开内置高德地图失败: $e'); + Get.snackbar('错误', '打开地图时发生错误'); + return false; + } + } + /// 打开Google地图进行导航 Future openGoogleMap(String daddr, String mode) async { try { 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 a5e25b57d..bcd1eba48 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 @@ -62,6 +62,7 @@ class AgentServiceImpl: NSObject { private let agentId = "default_agent" //工具调用提示 public var callingTool = "" + private var navigationMode = "" private var isInitialized: Bool = false private var isRecognizing: Bool = false @@ -165,6 +166,10 @@ class AgentServiceImpl: NSObject { self.config = config + if let navigationMode = config["navigationMode"] as? String { + self.navigationMode = navigationMode + } + if let callingTool = config["callingTool"] as? String { self.callingTool = callingTool } @@ -215,6 +220,7 @@ class AgentServiceImpl: NSObject { sendError("Azure语音区域缺失", code: "CONFIG_ERROR") return false } + //启动定位服务 NotificationCenter.default.post(name: .locationstartEvent, object: nil) // addlocationmonitor() @@ -1020,7 +1026,7 @@ private func jsonToString(_ json: [String: Any]) -> String? { // 应用在前台时的原有逻辑 // 根据导航模式选择不同的导航方式 - switch mode { + switch self.navigationMode { case "internal_gaode": // 使用内置高德导航 // startInternalNavigation(start: start, destination: destination, @@ -1706,7 +1712,7 @@ class ChatApiStreamCallback: StreamCallback { do { guard let agentService = try agentService else { return } - if sessionid == agentService.currsessionId { + if sessionid == agentService.currsessionId { // 停止等待音效 agentService.audioPlayer?.stopAwaitSound() } @@ -1762,7 +1768,7 @@ class ChatApiStreamCallback: StreamCallback { }catch{ print("liwei--------------- AI Call onFunctionCall 异常: \(error)") } - + } func onFunctionCallResult(_ sessionid:String,_ functionCall: [String: Any], _ functionCallResult: [String: Any]) {