添加网络层并接入 v9 登录流程及单元测试

This commit is contained in:
2026-07-06 15:33:34 +08:00
parent 31ffec0f2b
commit d424928243
21 changed files with 2387 additions and 18 deletions
+20
View File
@@ -13,6 +13,8 @@ final class AppStore {
private enum Key {
static let token = "key_in_token"
static let lastLoginUsername = "key_last_login_username"
static let privacyAgreementAccepted = "key_privacy_agreement_accepted"
}
private let defaults: UserDefaults
@@ -27,6 +29,24 @@ final class AppStore {
set { defaults.set(newValue, forKey: Key.token) }
}
/// 上次登录手机号,用于登录页恢复。
var lastLoginUsername: String? {
get { defaults.string(forKey: Key.lastLoginUsername) }
set {
if let newValue {
defaults.set(newValue, forKey: Key.lastLoginUsername)
} else {
defaults.removeObject(forKey: Key.lastLoginUsername)
}
}
}
/// 是否已同意隐私协议。
var privacyAgreementAccepted: Bool {
get { defaults.bool(forKey: Key.privacyAgreementAccepted) }
set { defaults.set(newValue, forKey: Key.privacyAgreementAccepted) }
}
/// Token 非空视为已登录。
var isLoggedIn: Bool {
!token.isEmpty