37 lines
873 B
Objective-C
37 lines
873 B
Objective-C
//
|
||
// AVUserManager.h
|
||
// AVDemo
|
||
//
|
||
// 用户管理类 - 管理用户登录状态
|
||
//
|
||
|
||
#import <Foundation/Foundation.h>
|
||
|
||
NS_ASSUME_NONNULL_BEGIN
|
||
|
||
@interface AVUserManager : NSObject
|
||
|
||
/// 单例
|
||
+ (instancetype)sharedManager;
|
||
|
||
/// 检查用户是否已登录
|
||
@property (nonatomic, assign, readonly) BOOL isLoggedIn;
|
||
|
||
/// 当前用户名(可选)
|
||
@property (nonatomic, copy, nullable) NSString *currentUsername;
|
||
|
||
/// 登录(异步,带回调)
|
||
/// @param username 用户名
|
||
/// @param password 密码
|
||
/// @param completion 完成回调,success 表示是否成功,errorMessage 为错误信息(成功时为 nil)
|
||
- (void)loginWithUsername:(NSString *)username
|
||
password:(NSString *)password
|
||
completion:(void (^)(BOOL success, NSString * _Nullable errorMessage))completion;
|
||
|
||
/// 登出
|
||
- (void)logout;
|
||
|
||
@end
|
||
|
||
NS_ASSUME_NONNULL_END
|