This commit is contained in:
2025-11-13 19:07:59 +08:00
parent 5ec950cc61
commit 50163d02a7
9 changed files with 378 additions and 88 deletions

View File

@@ -0,0 +1,32 @@
//
// KBLoginVM.h
// 登录相关的 ViewModel封装 Apple 登录与服务端校验、登录态落盘。
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@class KBUser;
NS_ASSUME_NONNULL_BEGIN
/// 登录完成回调
typedef void(^KBLoginCompletion)(BOOL success, NSError * _Nullable error);
@interface KBLoginVM : NSObject
+ (instancetype)shared;
/// 最近一次登录/拉取到的用户信息(仅内存缓存),可选
@property (atomic, strong, readonly, nullable) KBUser *currentUser; // 最近一次解析得到的用户
/// 调起 Apple 登录并在服务端完成校验;成功后会将 token 写入共享钥匙串KBAuthManager作为“已登录”的判断依据。
- (void)signInWithAppleFromViewController:(UIViewController *)presenter
completion:(KBLoginCompletion)completion;
/// 是否已登录:由 KBAuthManager 判断(是否存在有效 token
- (BOOL)isLoggedIn;
@end
NS_ASSUME_NONNULL_END