From c47e62b658f62b2660ee4bba6fa61d2cd6af4d1a Mon Sep 17 00:00:00 2001 From: link2026 Date: Sun, 19 Jul 2026 20:11:03 +0800 Subject: [PATCH] =?UTF-8?q?fix(concurrency):=20=E4=B8=89=E4=B8=AA=20enum?= =?UTF-8?q?=20=E6=A0=87=20nonisolated?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 工程开了 SWIFT_DEFAULT_ACTOR_ISOLATION=MainActor,这三个纯值类型 enum 会被推成 MainActor 隔离,跨 actor 使用时报错: - CustomMetricNameConflict (CustomMetricEditor) - SeriesKind (SeriesBucket) - ExportTrendBuilder.Direction 已随 v1.1 (build 6) 一同编译上传。 Co-Authored-By: Claude Opus 4.8 (1M context) --- 康康/Features/Indicator/CustomMetricEditor.swift | 2 +- 康康/Features/Trends/SeriesBucket.swift | 2 +- 康康/Services/ExportTrendBuilder.swift | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/康康/Features/Indicator/CustomMetricEditor.swift b/康康/Features/Indicator/CustomMetricEditor.swift index 2190a5c..6c357bf 100644 --- a/康康/Features/Indicator/CustomMetricEditor.swift +++ b/康康/Features/Indicator/CustomMetricEditor.swift @@ -13,7 +13,7 @@ let customMetricIconChoices: [String] = [ ] /// 名称冲突判定结果。`detectNameConflict` 返回此值用于 UI 警告。 -enum CustomMetricNameConflict: Equatable { +nonisolated enum CustomMetricNameConflict: Equatable { case none case builtin(String) // 撞到 MonitorMetric.displayName case existingCustom(String) // 撞到其他 CustomMonitorMetric.name diff --git a/康康/Features/Trends/SeriesBucket.swift b/康康/Features/Trends/SeriesBucket.swift index 127c97e..601ae09 100644 --- a/康康/Features/Trends/SeriesBucket.swift +++ b/康康/Features/Trends/SeriesBucket.swift @@ -5,7 +5,7 @@ import Foundation /// 趋势桶的来源类别。 /// - `.monitor`:长期监测预设 / 自定义 / 血压(按 seriesKey 分组)。 /// - `.lab`:任意出现 ≥2 次的化验/手动/报告指标(按 name+unit 分组,无 seriesKey)。 -enum SeriesKind { case monitor, lab } +nonisolated enum SeriesKind { case monitor, lab } /// 长期监测系列在 Trends 折线图里的展示桶。 /// 单系列(血糖/体重/...)= 1 个 SeriesLine;血压特殊 = 收缩 + 舒张 2 条线同卡。 diff --git a/康康/Services/ExportTrendBuilder.swift b/康康/Services/ExportTrendBuilder.swift index 36a3acf..d0e74e6 100644 --- a/康康/Services/ExportTrendBuilder.swift +++ b/康康/Services/ExportTrendBuilder.swift @@ -8,7 +8,7 @@ import Foundation /// 从根上杜绝小模型编造趋势数字(§10#5 失败回退 / §12#6 禁止编造)。 struct ExportTrend: Sendable { - enum Direction: Sendable { + nonisolated enum Direction: Sendable { case up, down, flat var arrow: String { switch self {