41 lines
1.3 KiB
Swift
41 lines
1.3 KiB
Swift
import CoreCommon
|
||
import CoreDomain
|
||
import CoreModel
|
||
|
||
/// Fake 个人资料仓库(骨架阶段返回假数据)。
|
||
public struct FakeProfileRepository: ProfileRepository {
|
||
public init() {}
|
||
|
||
public func observeProfile() -> AsyncThrowingStream<UserProfile, Error> {
|
||
AsyncThrowingStream { continuation in
|
||
let task = Task {
|
||
do {
|
||
try await Task.sleep(for: .milliseconds(400))
|
||
try Task.checkCancellation()
|
||
Logger.info("FakeProfileRepository 返回假数据")
|
||
continuation.yield(Self.fakeData)
|
||
continuation.finish()
|
||
} catch {
|
||
continuation.finish(throwing: error)
|
||
}
|
||
}
|
||
continuation.onTermination = { _ in task.cancel() }
|
||
}
|
||
}
|
||
|
||
private static let fakeData = UserProfile(
|
||
displayName: "张三",
|
||
name: "张三",
|
||
studentId: "20260001",
|
||
phone: "138****1234",
|
||
role: "成员",
|
||
group: "进阶一组",
|
||
loginType: "手机号",
|
||
avatarUrl: nil,
|
||
classGroups: [
|
||
ClassGroup(period: "2026 秋季", group: "进阶一组", role: "成员"),
|
||
ClassGroup(period: "2026 春季", group: "进阶二组", role: "组长"),
|
||
]
|
||
)
|
||
}
|