feat(Capture): 归档后后台预生成大白话摘要,详情页秒开 + 兜底重试

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
link2026
2026-06-10 07:12:48 +08:00
parent 0a824610cf
commit 43cdde9bab
5 changed files with 184 additions and 8 deletions

View File

@@ -257,14 +257,7 @@ struct TimelineEntryDetailView: View {
}
}
if let sum = r.summary, !sum.isEmpty {
card {
Text(String(appLoc: "摘要"))
.font(.tjScaled( 12, weight: .semibold)).foregroundStyle(Tj.Palette.text2)
Text(sum).font(.tjScaled( 14)).foregroundStyle(Tj.Palette.text)
.fixedSize(horizontal: false, vertical: true)
}
}
ReportSummaryCard(report: r)
if !r.indicators.isEmpty {
card {
@@ -559,3 +552,52 @@ private struct EvidenceHighlightOverlay: View {
)
}
}
// MARK: - ()
/// ;(,),
/// 线, SwiftData
private struct ReportSummaryCard: View {
@Environment(\.modelContext) private var ctx
let report: Report
@State private var generating = false
var body: some View {
Group {
if let sum = report.summary, !sum.isEmpty {
container {
Text(String(appLoc: "摘要"))
.font(.tjScaled( 12, weight: .semibold)).foregroundStyle(Tj.Palette.text2)
Text(sum).font(.tjScaled( 14)).foregroundStyle(Tj.Palette.text)
.fixedSize(horizontal: false, vertical: true)
}
} else if generating {
container {
Text("本地 AI 正在解读这份报告…")
.font(.tjScaled( 12)).foregroundStyle(Tj.Palette.text3)
AIFlowBar()
}
}
}
.task {
guard (report.summary ?? "").isEmpty, !report.indicators.isEmpty else { return }
generating = true
await ReportInsightService.shared.pregenerateIfNeeded(report: report, in: ctx)
generating = false
}
}
private func container<C: View>(@ViewBuilder _ body: () -> C) -> some View {
VStack(alignment: .leading, spacing: 10) { body() }
.padding(14)
.frame(maxWidth: .infinity, alignment: .leading)
.background(
RoundedRectangle(cornerRadius: Tj.Radius.md, style: .continuous)
.fill(Tj.Palette.paper)
)
.overlay(
RoundedRectangle(cornerRadius: Tj.Radius.md, style: .continuous)
.strokeBorder(Tj.Palette.lineSoft, lineWidth: 1)
)
}
}