feat: 统一智能体路由 + 删除 onboarding

- 新增 Unified 智能体(合并 health/diet/medication/exercise/default 全部工具)
- AI 自动判断意图并调用对应工具,前端胶囊自动切换
- 删除 onboarding 智能体及所有建档引导 UI
- 前端始终发 unified 类型,通过 tool_result 事件同步胶囊状态
This commit is contained in:
MingNian
2026-06-08 14:55:38 +08:00
parent b5f2977b32
commit fc7150ad60
9 changed files with 887 additions and 312 deletions

View File

@@ -69,8 +69,6 @@ class ChatMessagesView extends ConsumerWidget {
return _buildDietAnalysisCard(context, msg);
case MessageType.reportAnalysis:
return _buildReportAnalysisCard(context, msg);
case MessageType.onboarding:
return _buildOnboardingCard(context, ref);
case MessageType.quickOptions:
return _buildQuickOptionsCard(context, msg);
default:
@@ -749,66 +747,7 @@ class ChatMessagesView extends ConsumerWidget {
);
}
// ═══════════════════════════════════════════════════════════
// 6. OnboardingCard — 首次建档引导
Widget _buildOnboardingCard(BuildContext context, WidgetRef ref) {
return Align(
alignment: Alignment.centerLeft,
child: Container(
margin: const EdgeInsets.only(bottom: 12),
constraints: BoxConstraints(maxWidth: MediaQuery.of(context).size.width * 0.88),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(20),
boxShadow: [BoxShadow(color: const Color(0xFF8B9CF7).withAlpha(25), blurRadius: 14, offset: const Offset(0, 4))],
),
clipBehavior: Clip.antiAlias,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Container(
width: double.infinity,
padding: const EdgeInsets.fromLTRB(20, 24, 20, 16),
decoration: const BoxDecoration(
gradient: LinearGradient(colors: [Color(0xFF8B9CF7), Color(0xFFA78BFA)], begin: Alignment.topLeft, end: Alignment.bottomRight),
),
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
Row(children: [
Container(width: 48, height: 48, decoration: BoxDecoration(color: Colors.white.withAlpha(30), borderRadius: BorderRadius.circular(14)), child: const Icon(Icons.health_and_safety, size: 28, color: Colors.white)),
const SizedBox(width: 14),
const Text('欢迎来到健康管家!', style: TextStyle(fontSize: 18, fontWeight: FontWeight.w700, color: Colors.white)),
]),
const SizedBox(height: 12),
Text('我是您的AI健康管家。为了给您更精准的建议\n我先了解一些基本信息好吗大约2-3分钟。',
style: TextStyle(fontSize: 14, color: Colors.white.withAlpha(220), height: 1.5)),
]),
),
Padding(
padding: const EdgeInsets.fromLTRB(18, 18, 18, 20),
child: Column(children: [
SizedBox(
width: double.infinity,
child: ElevatedButton(
onPressed: () {
ref.read(chatProvider.notifier).startOnboarding();
},
style: ElevatedButton.styleFrom(backgroundColor: const Color(0xFF8B9CF7), foregroundColor: Colors.white, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(14)), padding: const EdgeInsets.symmetric(vertical: 14)),
child: const Text('开始建档', style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600)),
),
),
const SizedBox(height: 10),
TextButton(
onPressed: () => ref.read(chatProvider.notifier).dismissOnboarding(),
child: const Text('以后再说', style: TextStyle(fontSize: 14, color: Color(0xFF999999)))),
]),
),
],
),
),
);
}
// 7. QuickOptionsCard — 优化样式
// 6. QuickOptionsCard — 优化样式
// ═══════════════════════════════════════════════════════════
Widget _buildQuickOptionsCard(BuildContext context, ChatMessage msg) {