import Foundation /// 会话相关错误。 public enum SessionError: Error, Sendable, LocalizedError { case invalidPhone case wrongCode case phoneNotMatched public var errorDescription: String? { switch self { case .invalidPhone: return "请输入正确的手机号" case .wrongCode: return "验证码错误" case .phoneNotMatched: return "手机号未匹配,无法登录" } } } /// 会话仓库协议(登录态 / 手机号登录)。 public protocol SessionRepository: Sendable { /// 观察登录态。 func observeIsLoggedIn() -> AsyncThrowingStream /// 请求短信验证码。 func requestSmsCode(phone: String) async throws /// 手机号 + 验证码登录。 func login(phone: String, code: String) async throws /// 退出登录。 func logout() async throws }