- AI 提示词拆分为 markdown 模块(Prompts/global + modules + rag + router) - 新增 AI 同意门控(用户需同意后才能使用 AI 功能) - 新增 AI 录入草稿存储(AiEntryDraftContracts/EfAiEntryDraftStore/AiEntryDraftRecord) - 新增 AI 意图路由(ai_intent_router) - 新增医疗引用知识库(MedicalCitationKnowledge) - 重构 prompt_manager 和 ai_chat_endpoints - 优化聊天/趋势/档案/抽屉/医生端等多个页面 UI - 新增 agent 插画和趋势指标图标资源 - 删除 HANDOFF-2026-07-17.md
127 lines
4.1 KiB
Dart
127 lines
4.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
|
|
import '../core/app_colors.dart';
|
|
import '../core/app_design_tokens.dart';
|
|
import '../providers/ai_consent_provider.dart';
|
|
import '../providers/auth_provider.dart';
|
|
import '../pages/settings/ai_consent_details_page.dart';
|
|
|
|
class AiConsentGate extends ConsumerStatefulWidget {
|
|
final Widget child;
|
|
const AiConsentGate({super.key, required this.child});
|
|
|
|
@override
|
|
ConsumerState<AiConsentGate> createState() => _AiConsentGateState();
|
|
}
|
|
|
|
class _AiConsentGateState extends ConsumerState<AiConsentGate> {
|
|
String? _loadedUserId;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final user = ref.watch(authProvider).user;
|
|
if (user == null || user.id.isEmpty) return widget.child;
|
|
|
|
if (_loadedUserId != user.id) {
|
|
_loadedUserId = user.id;
|
|
Future<void>.microtask(
|
|
() => ref.read(aiConsentProvider.notifier).load(user.id),
|
|
);
|
|
}
|
|
|
|
final consent = ref.watch(aiConsentProvider);
|
|
if (consent.userId != user.id || consent.isLoading) {
|
|
return const Scaffold(backgroundColor: Colors.white);
|
|
}
|
|
if (consent.granted) return widget.child;
|
|
|
|
return Scaffold(
|
|
backgroundColor: AppColors.background,
|
|
body: Center(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(24),
|
|
child: _ConsentCard(userId: user.id),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _ConsentCard extends ConsumerWidget {
|
|
final String userId;
|
|
const _ConsentCard({required this.userId});
|
|
|
|
Future<void> _grant(BuildContext context, WidgetRef ref) async {
|
|
await ref.read(aiConsentProvider.notifier).grant(userId);
|
|
}
|
|
|
|
Future<void> _decline(BuildContext context, WidgetRef ref) async {
|
|
await ref.read(authProvider.notifier).logout();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
return Card(
|
|
elevation: 0,
|
|
color: Colors.white,
|
|
shape: RoundedRectangleBorder(borderRadius: AppRadius.xlBorder),
|
|
child: Padding(
|
|
padding: const EdgeInsets.fromLTRB(22, 24, 22, 20),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
const Icon(Icons.auto_awesome, size: 40, color: AppColors.primary),
|
|
const SizedBox(height: 14),
|
|
const Text(
|
|
'AI 健康服务授权',
|
|
textAlign: TextAlign.center,
|
|
style: TextStyle(fontSize: 21, fontWeight: FontWeight.w700),
|
|
),
|
|
const SizedBox(height: 14),
|
|
const Text(
|
|
'小脉健康的核心功能使用第三方 AI 服务。经你同意后,你主动输入的健康信息、对话内容、图片和报告可能会发送给相关 AI 服务,用于健康记录、饮食识别、报告整理和 AI 回复。',
|
|
style: TextStyle(
|
|
fontSize: 15,
|
|
height: 1.6,
|
|
color: AppColors.textSecondary,
|
|
),
|
|
),
|
|
const SizedBox(height: 10),
|
|
const Text(
|
|
'AI 生成内容仅供健康管理参考,不能替代医生诊断或治疗。',
|
|
style: TextStyle(
|
|
fontSize: 14,
|
|
height: 1.5,
|
|
color: AppColors.textSecondary,
|
|
),
|
|
),
|
|
const SizedBox(height: 10),
|
|
TextButton(
|
|
onPressed: () {
|
|
Navigator.of(context).push(
|
|
MaterialPageRoute<void>(
|
|
builder: (_) => const AiConsentDetailsPage(),
|
|
),
|
|
);
|
|
},
|
|
child: const Text('查看《AI 数据处理说明》'),
|
|
),
|
|
const SizedBox(height: 8),
|
|
FilledButton(
|
|
onPressed: () => _grant(context, ref),
|
|
child: const Text('同意并继续'),
|
|
),
|
|
const SizedBox(height: 8),
|
|
OutlinedButton(
|
|
onPressed: () => _decline(context, ref),
|
|
child: const Text('不同意并退出'),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|