替换 Xcode 默认模板: - 删除 ContentView/Item/__App - 新增 App/TijiApp(SwiftData ModelContainer)、RootView(3 Tab + RecordSheet) - DesignSystem:Tokens(色板/字体/圆角)+ Components(卡片/按钮/Chip) - Models:Indicator / Report / DiaryEntry @Model 初版 - Features:Home / Quick(A1-A3)/ Archive(B1-B5)/ Record / Trends / Me 静态 UI W2 AI 基座工作将在此基线上叠加。 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
97 lines
2.2 KiB
Swift
97 lines
2.2 KiB
Swift
import Foundation
|
|
import SwiftData
|
|
|
|
enum IndicatorStatus: String, Codable, CaseIterable {
|
|
case high, low, normal
|
|
}
|
|
|
|
enum ReportType: String, Codable, CaseIterable {
|
|
case checkup, lab, imaging, prescription, other
|
|
|
|
var label: String {
|
|
switch self {
|
|
case .checkup: return "体检报告"
|
|
case .lab: return "化验单"
|
|
case .imaging: return "影像报告"
|
|
case .prescription: return "处方"
|
|
case .other: return "其他"
|
|
}
|
|
}
|
|
}
|
|
|
|
@Model
|
|
final class Indicator {
|
|
var name: String
|
|
var value: String
|
|
var unit: String
|
|
var range: String
|
|
var statusRaw: String
|
|
var note: String?
|
|
var capturedAt: Date
|
|
|
|
init(name: String,
|
|
value: String,
|
|
unit: String,
|
|
range: String,
|
|
status: IndicatorStatus,
|
|
note: String? = nil,
|
|
capturedAt: Date = .now) {
|
|
self.name = name
|
|
self.value = value
|
|
self.unit = unit
|
|
self.range = range
|
|
self.statusRaw = status.rawValue
|
|
self.note = note
|
|
self.capturedAt = capturedAt
|
|
}
|
|
|
|
var status: IndicatorStatus {
|
|
IndicatorStatus(rawValue: statusRaw) ?? .normal
|
|
}
|
|
}
|
|
|
|
@Model
|
|
final class Report {
|
|
var title: String
|
|
var typeRaw: String
|
|
var reportDate: Date
|
|
var institution: String?
|
|
var note: String?
|
|
var summary: String?
|
|
var pageCount: Int
|
|
var createdAt: Date
|
|
|
|
init(title: String,
|
|
type: ReportType,
|
|
reportDate: Date,
|
|
institution: String? = nil,
|
|
note: String? = nil,
|
|
summary: String? = nil,
|
|
pageCount: Int = 1,
|
|
createdAt: Date = .now) {
|
|
self.title = title
|
|
self.typeRaw = type.rawValue
|
|
self.reportDate = reportDate
|
|
self.institution = institution
|
|
self.note = note
|
|
self.summary = summary
|
|
self.pageCount = pageCount
|
|
self.createdAt = createdAt
|
|
}
|
|
|
|
var type: ReportType {
|
|
ReportType(rawValue: typeRaw) ?? .other
|
|
}
|
|
}
|
|
|
|
@Model
|
|
final class DiaryEntry {
|
|
var content: String
|
|
var createdAt: Date
|
|
|
|
init(content: String, createdAt: Date = .now) {
|
|
self.content = content
|
|
self.createdAt = createdAt
|
|
}
|
|
}
|