//
//  SLGlobalInfo.m
//  SLAiELTS
//
//  Created by Gusont on 2023/3/1.
//

#import "SLGlobalInfo.h"

@implementation SLGlobalInfo

+ (instancetype)SharedInstance
{
    static SLGlobalInfo *gcInfo = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        gcInfo = [[SLGlobalInfo alloc] init];
        
    });
    return gcInfo;
}

- (void)setLoginInfo:(SLLoginInfo *)loginInfo {
    _loginInfo = loginInfo;
    [[SLHttpCenter SharedInstance].requestSerializer setValue:[NSString stringWithFormat:@"Bearer %@",_loginInfo.token] forHTTPHeaderField:@"Authorization"];
    if (_loginInfo) {
        [[NSUserDefaults standardUserDefaults] setObject:_loginInfo.user.phone forKey:@"SLUserPhone"];
        [[NSUserDefaults standardUserDefaults] synchronize];
    }
}

- (void)userLogout {
    self.loginInfo = nil;
    self.roleModel = nil;
    self.targetModel = nil;
}

@end
