feat(ios): IOS-M1-06 分析页增加 AI 综合分析卡片
- AI 综合分析卡片基于 activity 数据生成摘要文案 - 展示学习分钟/连续天数/掌握度等关键指标 - 下方列出 AI 学习推荐 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
90ad19aad1
commit
dd97470e04
@ -75,6 +75,26 @@ struct AnalysisHomeView: View {
|
|||||||
}
|
}
|
||||||
}.padding(.horizontal, 20).padding(.bottom, 120)
|
}.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)
|
.scrollIndicators(.hidden)
|
||||||
.zxPullToRefresh { await viewModel.refresh() }
|
.zxPullToRefresh { await viewModel.refresh() }
|
||||||
}
|
}
|
||||||
@ -82,6 +102,18 @@ struct AnalysisHomeView: View {
|
|||||||
.task { await viewModel.loadAll() }
|
.task { await viewModel.loadAll() }
|
||||||
.navigationDestination(for: Route.self) { $0.destination }
|
.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
|
struct ZXStatBadge: View { let icon: String; let label: String; let value: String; let trend: String; let color: Color
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user