feat: 重造领域模型并对齐 android(home/checkin/plan/profile/session)

This commit is contained in:
AndyChen1024
2026-09-15 14:35:52 +08:00
parent ac4492a8f1
commit 14eb5ad44d
6 changed files with 313 additions and 40 deletions

View File

@@ -1,19 +1,65 @@
import Foundation
/// Home 页面的聚合数据(对应 Android 端 HomeData)。
public struct HomeData: Identifiable, Hashable, Sendable {
public let id: String
/// 顶部问候语,例如「早上好,Andy」。
public let greeting: String
/// 今日打卡摘要,例如「已完成 2 / 4」。
public let summary: String
/// 今日待打卡的习惯列表。
public let habits: [Habit]
/// 首页模块跳转目标。
public enum ModuleDestination: Hashable, Sendable {
case checkin
case plan
case about
}
public init(id: String, greeting: String, summary: String, habits: [Habit]) {
/// 首页功能模块卡片(打卡介绍 / 计划介绍 / 关于我们)。
public struct HomeModule: Identifiable, Hashable, Sendable {
public let id: String
public let emoji: String
public let title: String
public let description: String
public let destination: ModuleDestination
public init(
id: String,
emoji: String,
title: String,
description: String,
destination: ModuleDestination
) {
self.id = id
self.greeting = greeting
self.summary = summary
self.habits = habits
self.emoji = emoji
self.title = title
self.description = description
self.destination = destination
}
}
/// 产品介绍卡片。
public struct IntroCard: Hashable, Sendable {
public let title: String
public let body: String
public init(title: String, body: String) {
self.title = title
self.body = body
}
}
/// 首页聚合数据(落地页)。
public struct HomeData: Hashable, Sendable {
public let greeting: String
public let displayName: String
public let encouragement: String
public let modules: [HomeModule]
public let intros: [IntroCard]
public init(
greeting: String,
displayName: String,
encouragement: String,
modules: [HomeModule],
intros: [IntroCard]
) {
self.greeting = greeting
self.displayName = displayName
self.encouragement = encouragement
self.modules = modules
self.intros = intros
}
}