根据提供的code differences信息,由于没有具体的代码变更内容,我将生成一个通用的commit message模板:
``` docs(readme): 更新文档说明 - 添加了项目使用指南 - 完善了API接口说明 - 修正了一些文字错误 ``` 注:由于未提供具体的代码差异信息,以上为示例格式。请提供具体的代码变更内容以便生成准确的commit message。
This commit is contained in:
@@ -153,8 +153,21 @@ struct UnifiedCaptureFlow: View {
|
||||
phase = .analyzing(images: images, assets: nil)
|
||||
let timeout = analyzeTimeoutSeconds
|
||||
analyzeTask = Task {
|
||||
// Step 1: 先把图写进 Vault(归档的核心价值就是「把原图存下来」,先保证它)。
|
||||
let assets = images.compactMap { try? FileVault.shared.writeJPEG($0) }
|
||||
// Step 1: 把图写进 Vault(归档核心价值:先把原图存下来),并立刻降采样出预览缩略图。
|
||||
// 整段放后台线程,JPEG 编码逐张包 autoreleasepool 让中间 Data / 位图及时回收 ——
|
||||
// 既不卡主线程,又能在写完后释放全分辨率原图,不让它贯穿整个识别期常驻(jetsam 防护)。
|
||||
let inputBox = UncheckedImageBox(images: images)
|
||||
let written: (assets: [FileVault.SavedAsset], thumbs: UncheckedImageBox) =
|
||||
await Task.detached(priority: .userInitiated) {
|
||||
let assets = inputBox.images.compactMap { img in
|
||||
autoreleasepool { try? FileVault.shared.writeJPEG(img) }
|
||||
}
|
||||
let thumbs = assets.compactMap {
|
||||
try? FileVault.shared.loadDownsampledImage(relativePath: $0.relativePath, maxPixelSize: 600)
|
||||
}
|
||||
return (assets, UncheckedImageBox(images: thumbs))
|
||||
}.value
|
||||
let assets = written.assets
|
||||
// 极端情况:用户在写图过程中按了「取消」,View 已 dismiss、cancelAll 看到的
|
||||
// phase 还是 .analyzing(_, nil),清不到这批刚写完的图 — 这里手动收尾。
|
||||
if Task.isCancelled {
|
||||
@@ -171,11 +184,9 @@ struct UnifiedCaptureFlow: View {
|
||||
}
|
||||
return
|
||||
}
|
||||
// 把 assets 暴露给 phase,使工具栏「取消」也能找到孤儿清理。
|
||||
// 原图已落盘:phase 改持 600px 缩略图(释放全分辨率原图),同时把 assets 暴露给「取消」做孤儿清理。
|
||||
await MainActor.run {
|
||||
if case .analyzing(let imgs, _) = phase {
|
||||
phase = .analyzing(images: imgs, assets: assets)
|
||||
}
|
||||
phase = .analyzing(images: written.thumbs.images, assets: assets)
|
||||
}
|
||||
|
||||
// Step 2: 轻量 meta 提取(OCR + 文本 LLM,只抽日期/机构/类型/标题)。
|
||||
@@ -287,6 +298,12 @@ struct UnifiedCaptureFlow: View {
|
||||
}
|
||||
}
|
||||
|
||||
/// 跨 detached 边界安全携带 UIImage 数组:图片只读、不并发改,封装免 Sendable 报错
|
||||
/// (同 MNNBackend.MNNUncheckedBox 思路)。
|
||||
private struct UncheckedImageBox: @unchecked Sendable {
|
||||
let images: [UIImage]
|
||||
}
|
||||
|
||||
// MARK: - 分析中视图
|
||||
|
||||
private struct AnalyzingView: View {
|
||||
|
||||
Reference in New Issue
Block a user