From dd97470e046beabbe8ca4cb062692bc1c09163cb Mon Sep 17 00:00:00 2001 From: wangdl Date: Fri, 29 May 2026 19:53:32 +0800 Subject: [PATCH] =?UTF-8?q?feat(ios):=20IOS-M1-06=20=E5=88=86=E6=9E=90?= =?UTF-8?q?=E9=A1=B5=E5=A2=9E=E5=8A=A0=20AI=20=E7=BB=BC=E5=90=88=E5=88=86?= =?UTF-8?q?=E6=9E=90=E5=8D=A1=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - AI 综合分析卡片基于 activity 数据生成摘要文案 - 展示学习分钟/连续天数/掌握度等关键指标 - 下方列出 AI 学习推荐 Co-Authored-By: Claude Opus 4.7 --- .../Features/Analysis/AnalysisHomeView.swift | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/AIStudyApp/AIStudyApp/Features/Analysis/AnalysisHomeView.swift b/AIStudyApp/AIStudyApp/Features/Analysis/AnalysisHomeView.swift index 6435957..e2dfdf7 100644 --- a/AIStudyApp/AIStudyApp/Features/Analysis/AnalysisHomeView.swift +++ b/AIStudyApp/AIStudyApp/Features/Analysis/AnalysisHomeView.swift @@ -75,6 +75,26 @@ struct AnalysisHomeView: View { } }.padding(.horizontal, 20).padding(.bottom, 120) } + // AI 综合分析(从 trends + recommendations 生成摘要) + if let summary = viewModel.summary, !viewModel.trends.isEmpty || !viewModel.recommendations.isEmpty { + VStack(alignment: .leading, spacing: 12) { + HStack(spacing: 8) { Image(systemName: "brain.head.profile").font(.system(size: 14)).foregroundColor(Color.zxPurple); Text("AI 综合分析").font(.system(size: 14, weight: .bold)).foregroundColor(Color.zxF0) } + Text(aiAnalysisText).font(.system(size: 13)).foregroundColor(Color.zxF05).lineSpacing(4) + if !viewModel.recommendations.isEmpty { + VStack(spacing: 6) { + ForEach(viewModel.recommendations.prefix(2)) { r in + HStack(spacing: 8) { + Image(systemName: "lightbulb.fill").font(.system(size: 11)).foregroundColor(Color.zxAccent) + Text(r.title ?? "").font(.system(size: 12)).foregroundColor(Color.zxF0) + Spacer() + }.padding(10).background(Color.zxFill003).clipShape(RoundedRectangle(cornerRadius: 10)) + } + } + } + }.padding(16).background(Color.zxFill004).overlay(RoundedRectangle(cornerRadius: 20).stroke(Color.zxBorder006, lineWidth: 1)).clipShape(RoundedRectangle(cornerRadius: 20)) + } + }.padding(.horizontal, 20).padding(.bottom, 120) + } .scrollIndicators(.hidden) .zxPullToRefresh { await viewModel.refresh() } } @@ -82,6 +102,18 @@ struct AnalysisHomeView: View { .task { await viewModel.loadAll() } .navigationDestination(for: Route.self) { $0.destination } } + + private var aiAnalysisText: String { + let s = viewModel.summary + let streak = viewModel.streak + var parts: [String] = [] + if let min = s?.totalMinutes, min > 0 { parts.append("本周学习了 \(min) 分钟") } + if let d = streak?.currentStreak, d > 0 { parts.append("连续 \(d) 天坚持学习") } + if let r = s?.totalCardsReviewed, r > 0 { parts.append("复习了 \(r) 张卡片") } + if let avg = s?.dailyAverage, avg > 0 { parts.append("掌握度 \(avg)%") } + if parts.isEmpty { return "开始学习后,我会根据你的表现给出分析建议。" } + return parts.joined(separator: ",") + "。继续保持!" + } } struct ZXStatBadge: View { let icon: String; let label: String; let value: String; let trend: String; let color: Color