This commit is contained in:
2026-03-04 20:36:53 +08:00
parent 7029209a4d
commit fe08f8d54a
6 changed files with 163 additions and 187 deletions

View File

@@ -14,7 +14,27 @@ NS_ASSUME_NONNULL_BEGIN
typedef void(^KBLoginCompletion)(BOOL success, NSError * _Nullable error);
typedef void(^KBRegisterCompletion)(BOOL success, NSError * _Nullable error);
typedef void(^KBVerifyMailCompletion)(BOOL success, NSError * _Nullable error);
typedef void(^KBAppUpdateCompletion)(NSDictionary * _Nullable data, NSError * _Nullable error);
@class KBAppUpdateInfo;
@class KBAppUpdateResponse;
typedef void(^KBAppUpdateCompletion)(KBAppUpdateInfo * _Nullable info, NSError * _Nullable error);
@interface KBAppUpdateInfo : NSObject
@property (nonatomic, assign) NSInteger minSupportedCode;
@property (nonatomic, copy, nullable) NSString *latestVersionName;
@property (nonatomic, copy, nullable) NSString *downloadUrl;
@property (nonatomic, assign) BOOL needUpdate;
@property (nonatomic, assign) NSInteger latestVersionCode;
@property (nonatomic, assign) BOOL forceUpdate;
@property (nonatomic, copy, nullable) NSString *releaseNotes;
@property (nonatomic, copy, nullable) NSString *storeUrl;
@end
@interface KBAppUpdateResponse : NSObject
@property (nonatomic, assign) NSInteger code;
@property (nonatomic, copy, nullable) NSString *message;
@property (nonatomic, strong, nullable) KBAppUpdateInfo *data;
@end
@interface KBLoginVM : NSObject

View File

@@ -15,6 +15,12 @@
@property (nonatomic, strong) KBMyVM *myVM;
@end
@implementation KBAppUpdateInfo
@end
@implementation KBAppUpdateResponse
@end
@implementation KBLoginVM
+ (instancetype)shared {
@@ -169,7 +175,10 @@
NSDictionary *params = [self kb_appUpdateParams];
[[KBNetworkManager shared] POST:API_APP_CHECK_UPDATE jsonBody:params headers:nil autoShowBusinessError:NO completion:^(NSDictionary * _Nullable jsonOrData, NSURLResponse * _Nullable response, NSError * _Nullable error) {
if (error) { if (completion) completion(nil, error); return; }
if (completion) completion(jsonOrData, nil);
if (![jsonOrData isKindOfClass:NSDictionary.class]) { if (completion) completion(nil, nil); return; }
KBAppUpdateResponse *resp = [KBAppUpdateResponse mj_objectWithKeyValues:jsonOrData];
if (resp.code != 0) { if (completion) completion(nil, nil); return; }
if (completion) completion(resp.data, nil);
}];
}