feat: 添加自定义提醒功能并优化项目配置 - 添加 CustomReminder 模型支持自由文案周期性提醒功能 - 实现自定义提醒的 UI 界面,包括新建、编辑和列表展示 - 集成本地通知服务支持自定义提醒的时间触发 - 更新项目配置文件添加应用显示名称和加密声明 - 修正 iOS 部署目标版本从 26.0 到 17.0 - 修复 FileDownloader 中的线程安全问题 - 优化 ModelManifest 和 Localization 的并发安全性 - 扩展本地化字符串支持多语言提醒相关文本 - 调整项目支持平台范围仅保留 iphoneos 和 iphonesimulator ```
54 lines
1.9 KiB
Swift
54 lines
1.9 KiB
Swift
import SwiftUI
|
||
import SwiftData
|
||
|
||
@main
|
||
struct KangkangApp: App {
|
||
@State private var lang = LanguageManager.shared
|
||
|
||
var sharedModelContainer: ModelContainer = {
|
||
let schema = Schema([
|
||
Indicator.self,
|
||
Report.self,
|
||
DiaryEntry.self,
|
||
Asset.self,
|
||
ChatTurn.self,
|
||
Symptom.self,
|
||
UserProfile.self,
|
||
MetricReminder.self,
|
||
CustomMonitorMetric.self,
|
||
HealthExport.self,
|
||
CustomReminder.self,
|
||
])
|
||
let config = ModelConfiguration(schema: schema, isStoredInMemoryOnly: false)
|
||
do {
|
||
return try ModelContainer(for: schema, configurations: [config])
|
||
} catch {
|
||
// Demo 阶段 schema 仍在演进:旧 store 与新 schema 不兼容且无正式迁移时,
|
||
// 自动迁移会失败导致启动崩溃。这里重置本地 store 重建(测试数据可丢)。
|
||
// ⚠️ 生产环境必须改为正式的 SwiftData 迁移方案,不能静默删数据。
|
||
print("⚠️ ModelContainer 创建失败,重置本地 store 重建: \(error)")
|
||
let fm = FileManager.default
|
||
let storePath = config.url.path
|
||
for path in [storePath, storePath + "-wal", storePath + "-shm"] {
|
||
try? fm.removeItem(atPath: path)
|
||
}
|
||
do {
|
||
return try ModelContainer(for: schema, configurations: [config])
|
||
} catch {
|
||
fatalError("Could not create ModelContainer even after reset: \(error)")
|
||
}
|
||
}
|
||
}()
|
||
|
||
var body: some Scene {
|
||
WindowGroup {
|
||
AppLockContainer {
|
||
RootView()
|
||
.environment(\.locale, lang.locale)
|
||
.id(lang.current) // 语言切换 → 整树重建,即时生效
|
||
}
|
||
}
|
||
.modelContainer(sharedModelContainer)
|
||
}
|
||
}
|