Files
ios-client/IosClientKit/Sources/CoreRepository/FakeProfileRepository.swift

41 lines
1.3 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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: "组长"),
]
)
}