Files
keyboard/keyBoard/Class/Me/VM/KBMyVM.m

46 lines
1.4 KiB
Mathematica
Raw Normal View History

2025-12-03 13:31:02 +08:00
//
// KBMyVM.m
// keyBoard
//
// Created by Mac on 2025/12/3.
//
#import "KBMyVM.h"
#import "AppDelegate.h"
@implementation KBMyVM
- (void)logout{
[KBHUD show];
2025-12-03 13:54:57 +08:00
[[KBNetworkManager shared] GET:API_LOGOUT
parameters:nil
headers:nil
2025-12-03 14:30:02 +08:00
autoShowBusinessError:NO
2025-12-03 13:54:57 +08:00
completion:^(NSDictionary *jsonOrData, NSURLResponse * _Nullable response, NSError * _Nullable error) {
// HUD
[KBHUD dismiss];
if (error) {
// message
NSString *msg = KBBizMessageFromJSONObject(jsonOrData) ?: error.localizedDescription ?: KBLocalized(@"Network error");
[KBHUD showInfo:msg];
2025-12-03 13:31:02 +08:00
return;
}
2025-12-03 13:54:57 +08:00
NSString *message = jsonOrData[KBMessage] ?: KBLocalized(@"Success");
2025-12-03 13:31:02 +08:00
[KBHUD showSuccess:message];
2025-12-03 13:54:57 +08:00
// 退
[[KBUserSessionManager shared] logout];
// /
dispatch_async(dispatch_get_main_queue(), ^{
id<UIApplicationDelegate> appDelegate = UIApplication.sharedApplication.delegate;
2025-12-03 14:30:02 +08:00
if ([appDelegate respondsToSelector:@selector(toMainTabbarVC)]) {
2025-12-03 13:54:57 +08:00
AppDelegate *delegate = (AppDelegate *)appDelegate;
2025-12-03 14:30:02 +08:00
[delegate toMainTabbarVC];
2025-12-03 13:54:57 +08:00
}
});
2025-12-03 13:31:02 +08:00
}];
}
@end