From 178d3d0a9bcd08e3c8a2b9ce2707d4e1c1cfc0b1 Mon Sep 17 00:00:00 2001 From: lxm <1274844347@qq.com> Date: Wed, 13 Aug 2025 17:52:26 +0800 Subject: [PATCH] =?UTF-8?q?fix(agent):=20=E4=BF=AE=E5=A4=8D=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E6=9F=A5=E7=9C=8B=E5=99=A8=E8=B7=AF=E5=BE=84=E5=A4=84?= =?UTF-8?q?=E7=90=86=E5=B9=B6=E4=BC=98=E5=8C=96=E4=BA=A4=E4=BA=92=E4=BD=93?= =?UTF-8?q?=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 处理图片路径拼接逻辑,支持相对路径和完整路径 - 移除AppBar改为点击图片退出查看器 - 优化图片查看器的交互方式 --- lib/data/services/novice_guide_service.dart | 2 +- .../agent/controllers/agent_controller.dart | 49 +++++++++++++++---- 2 files changed, 41 insertions(+), 10 deletions(-) diff --git a/lib/data/services/novice_guide_service.dart b/lib/data/services/novice_guide_service.dart index 4fa2c12c7..d32be2368 100644 --- a/lib/data/services/novice_guide_service.dart +++ b/lib/data/services/novice_guide_service.dart @@ -12,7 +12,7 @@ class NoviceGuideService extends GetxService { StreamSubscription? _statusSubscription; bool isHomeGuide = true; - bool isAIGuide = false; + bool isAIGuide = true; RxBool isWakeup = false.obs; diff --git a/lib/modules/agent/controllers/agent_controller.dart b/lib/modules/agent/controllers/agent_controller.dart index 4ab856798..89eed9292 100644 --- a/lib/modules/agent/controllers/agent_controller.dart +++ b/lib/modules/agent/controllers/agent_controller.dart @@ -1759,21 +1759,52 @@ class AgentController extends GetxController { // 打开图片查看器 void openImageViewer(BuildContext context, String imagePath) { + // 构建完整的图片路径 + String fullImagePath; + if (imagePath.startsWith('/')) { + // 如果是相对路径(以/开头),需要拼接AppDir.value + fullImagePath = '${AppDir.value}$imagePath'; + } else { + // 如果已经是完整路径,直接使用 + fullImagePath = imagePath; + } + Navigator.push( context, MaterialPageRoute( builder: (context) => Scaffold( - appBar: AppBar( - backgroundColor: Colors.black, - iconTheme: IconThemeData(color: Colors.white), - ), + // appBar: AppBar( + // backgroundColor: Colors.black, + // leading: IconButton( + // icon: Icon(Icons.arrow_back_ios, color: Colors.white), + // onPressed: () => Navigator.of(context).pop(), + // ), + // iconTheme: IconThemeData(color: Colors.white), + // //title: Text('图片预览', style: TextStyle(color: Colors.white)), + // ), body: Container( color: Colors.black, - child: PhotoView( - imageProvider: FileImage(File(imagePath)), - minScale: PhotoViewComputedScale.contained, - maxScale: PhotoViewComputedScale.covered * 2, - backgroundDecoration: BoxDecoration(color: Colors.black), + child: GestureDetector( + onTap: () => Navigator.of(context).pop(), // 点击退出 + + child: PhotoView( + imageProvider: FileImage(File(fullImagePath)), + minScale: PhotoViewComputedScale.contained, + maxScale: PhotoViewComputedScale.covered * 2, + backgroundDecoration: BoxDecoration(color: Colors.black), + // errorBuilder: (context, error, stackTrace) { + // return const Center( + // child: Column( + // mainAxisAlignment: MainAxisAlignment.center, + // children: [ + // Icon(Icons.error, color: Colors.white, size: 64), + // SizedBox(height: 16), + // Text('图片加载失败', style: TextStyle(color: Colors.white)), + // ], + // ), + // ); + // }, + ), ), ), ),