From 80540e21910b732bcf1cdaeaf393c8be35e0bf99 Mon Sep 17 00:00:00 2001 From: MingNian <1281442923@qq.com> Date: Mon, 22 Jun 2026 15:58:59 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=81=A5=E5=BA=B7=E6=A1=A3=E6=A1=88?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E6=8C=89=E9=92=AE=E7=A7=BB=E8=87=B3=E5=8F=B3?= =?UTF-8?q?=E4=B8=8A=E8=A7=92=20+=205=E9=A1=B5=E9=9D=A2=E8=A1=A5=E5=85=85?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E6=8C=89=E9=92=AE=20+=20API=E5=9C=B0?= =?UTF-8?q?=E5=9D=80=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 健康档案: 保存按钮移到AppBar右侧,删除底部按钮和绿色成功SnackBar - 5个缺失页面补充左上角返回按钮: 健康概览/编辑用药/报告管理/报告详情/报告解读 - api_client.dart: 默认baseUrl改为192.168.1.29 (支持WiFi直连) --- health_app/lib/core/api_client.dart | 4 +- health_app/lib/pages/chart/trend_page.dart | 7 ++- .../medication/medication_edit_page.dart | 5 +- health_app/lib/pages/remaining_pages.dart | 53 ++++++------------- .../lib/pages/report/ai_analysis_page.dart | 5 +- health_app/lib/pages/report/report_pages.dart | 10 +++- 6 files changed, 40 insertions(+), 44 deletions(-) diff --git a/health_app/lib/core/api_client.dart b/health_app/lib/core/api_client.dart index b0729f8..5012dd7 100644 --- a/health_app/lib/core/api_client.dart +++ b/health_app/lib/core/api_client.dart @@ -4,9 +4,11 @@ import 'package:dio/dio.dart'; import 'local_database.dart'; /// API 基础地址。可通过 --dart-define=API_BASE_URL=http://host:5000 覆盖。 +/// Android 真机 USB: 先执行 adb reverse tcp:5000 tcp:5000 然后 localhost 即可 +/// Android 真机 WiFi: flutter run --dart-define=API_BASE_URL=http://电脑IP:5000 const String baseUrl = String.fromEnvironment( 'API_BASE_URL', - defaultValue: 'http://localhost:5000', + defaultValue: 'http://192.168.1.29:5000', ); class ApiException implements Exception { diff --git a/health_app/lib/pages/chart/trend_page.dart b/health_app/lib/pages/chart/trend_page.dart index e4971ae..aa00b7b 100644 --- a/health_app/lib/pages/chart/trend_page.dart +++ b/health_app/lib/pages/chart/trend_page.dart @@ -3,6 +3,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import '../../core/app_colors.dart'; import '../../core/app_theme.dart'; +import '../../core/navigation_provider.dart'; import '../../providers/auth_provider.dart'; import '../../providers/data_providers.dart'; @@ -247,7 +248,11 @@ class _TrendPageState extends ConsumerState { @override Widget build(BuildContext context) { return GradientScaffold( - appBar: AppBar(title: const Text('健康概览'), centerTitle: true), + appBar: AppBar( + leading: IconButton(icon: const Icon(Icons.arrow_back), onPressed: () => popRoute(ref)), + title: const Text('健康概览'), + centerTitle: true, + ), floatingActionButton: FloatingActionButton( onPressed: _showAddDialog, backgroundColor: _color, diff --git a/health_app/lib/pages/medication/medication_edit_page.dart b/health_app/lib/pages/medication/medication_edit_page.dart index fc92e09..c7462c8 100644 --- a/health_app/lib/pages/medication/medication_edit_page.dart +++ b/health_app/lib/pages/medication/medication_edit_page.dart @@ -138,7 +138,10 @@ class _MedicationEditPageState extends ConsumerState { @override Widget build(BuildContext context) { return GradientScaffold( - appBar: AppBar(title: Text(widget.id != null ? '编辑用药' : '添加用药')), + appBar: AppBar( + leading: IconButton(icon: const Icon(Icons.arrow_back), onPressed: () => popRoute(ref)), + title: Text(widget.id != null ? '编辑用药' : '添加用药'), + ), body: ListView( padding: const EdgeInsets.all(16), children: [ diff --git a/health_app/lib/pages/remaining_pages.dart b/health_app/lib/pages/remaining_pages.dart index 019ad8f..ddb0c38 100644 --- a/health_app/lib/pages/remaining_pages.dart +++ b/health_app/lib/pages/remaining_pages.dart @@ -1381,14 +1381,6 @@ class _HealthArchivePageState extends ConsumerState { 'familyHistory': _familyCtrl.text, }); await ref.read(authProvider.notifier).refreshProfile(); - if (mounted) { - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar( - content: Text('保存成功'), - backgroundColor: AppColors.success, - ), - ); - } } catch (_) { if (mounted) { ScaffoldMessenger.of(context).showSnackBar( @@ -1438,6 +1430,21 @@ class _HealthArchivePageState extends ConsumerState { icon: const Icon(Icons.arrow_back, color: AppColors.textPrimary), onPressed: () => popRoute(ref), ), + actions: [ + _saving + ? const Padding( + padding: EdgeInsets.only(right: 16), + child: SizedBox( + width: 24, + height: 24, + child: CircularProgressIndicator(strokeWidth: 2), + ), + ) + : TextButton( + onPressed: _save, + child: const Text('保存', style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600)), + ), + ], ), body: ListView( padding: const EdgeInsets.all(16), @@ -1525,36 +1532,6 @@ class _HealthArchivePageState extends ConsumerState { const SizedBox(height: 12), _F('家族病史', _familyCtrl, hint: '如: 父亲冠心病'), ]), - const SizedBox(height: 24), - Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(14), - gradient: AppColors.primaryGradient, - ), - padding: const EdgeInsets.all(1.5), - child: SizedBox( - width: double.infinity, - height: 52, - child: ElevatedButton( - onPressed: _saving ? null : _save, - style: ElevatedButton.styleFrom( - backgroundColor: Colors.white, - foregroundColor: AppColors.primary, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(13), - ), - elevation: 0, - ), - child: Text( - _saving ? '保存中...' : '保存档案', - style: const TextStyle( - fontSize: 17, - fontWeight: FontWeight.w600, - ), - ), - ), - ), - ), const SizedBox(height: 40), ], ), diff --git a/health_app/lib/pages/report/ai_analysis_page.dart b/health_app/lib/pages/report/ai_analysis_page.dart index 3917f1c..bfb9637 100644 --- a/health_app/lib/pages/report/ai_analysis_page.dart +++ b/health_app/lib/pages/report/ai_analysis_page.dart @@ -31,7 +31,10 @@ class _AiAnalysisPageState extends ConsumerState { if (analysis == null) { return GradientScaffold( - appBar: AppBar(title: const Text('报告解读')), + appBar: AppBar( + leading: IconButton(icon: const Icon(Icons.arrow_back), onPressed: () => popRoute(ref)), + title: const Text('报告解读'), + ), body: const Center( child: CircularProgressIndicator(color: AppColors.primary), ), diff --git a/health_app/lib/pages/report/report_pages.dart b/health_app/lib/pages/report/report_pages.dart index 72fc07d..82cf129 100644 --- a/health_app/lib/pages/report/report_pages.dart +++ b/health_app/lib/pages/report/report_pages.dart @@ -351,7 +351,10 @@ class ReportListPage extends ConsumerWidget { if (state.isAnalyzing) { return GradientScaffold( - appBar: AppBar(title: const Text('报告管理')), + appBar: AppBar( + leading: IconButton(icon: const Icon(Icons.arrow_back), onPressed: () => popRoute(ref)), + title: const Text('报告管理'), + ), body: Center( child: Column( mainAxisSize: MainAxisSize.min, @@ -720,7 +723,10 @@ class ReportOriginalPage extends StatelessWidget { Widget build(BuildContext context) { final imageUrl = _absoluteUrl(url); return GradientScaffold( - appBar: AppBar(title: Text(title)), + appBar: AppBar( + leading: IconButton(icon: const Icon(Icons.arrow_back), onPressed: () => Navigator.pop(context)), + title: Text(title), + ), body: Center( child: InteractiveViewer( minScale: 0.7,