2
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
#import "WJXEventSource.h"
|
||||
#import "KBTagItemModel.h"
|
||||
#import <MJExtension/MJExtension.h>
|
||||
#import "KBBizCode.h"
|
||||
|
||||
@interface KBFunctionView () <KBFunctionBarViewDelegate, KBStreamOverlayViewDelegate, KBFunctionTagListViewDelegate>
|
||||
// UI
|
||||
@@ -347,6 +348,7 @@
|
||||
NSError *error = nil;
|
||||
NSDictionary *payload = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&error];
|
||||
if (error || ![payload isKindOfClass:[NSDictionary class]]) { return; }
|
||||
if ([self kb_handleBizErrorIfNeeded:payload]) { return; }
|
||||
NSString *type = payload[@"type"];
|
||||
if (![type isKindOfClass:[NSString class]]) { return; }
|
||||
|
||||
@@ -395,6 +397,32 @@
|
||||
self.eventSourceDidReceiveDone = NO;
|
||||
}
|
||||
|
||||
- (BOOL)kb_handleBizErrorIfNeeded:(NSDictionary *)payload {
|
||||
NSInteger code = KBBizCodeFromJSONObject(payload);
|
||||
if (code == NSNotFound || code == KBBizCodeSuccess) {
|
||||
return NO;
|
||||
}
|
||||
BOOL needSubscriptionGuide = (code == KBBizCodeQuotaExhausted);
|
||||
NSString *msg = KBBizMessageFromJSONObject(payload);
|
||||
if (msg.length == 0) {
|
||||
msg = KBLocalized(@"拉取失败");
|
||||
}
|
||||
NSError *bizError = [NSError errorWithDomain:@"KBStreamBizError"
|
||||
code:code
|
||||
userInfo:@{NSLocalizedDescriptionKey: msg}];
|
||||
[self kb_finishEventSourceWithError:bizError];
|
||||
if (needSubscriptionGuide) {
|
||||
[self kb_requestSubscriptionGuide];
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)kb_requestSubscriptionGuide {
|
||||
if ([self.delegate respondsToSelector:@selector(functionViewDidRequestSubscription:)]) {
|
||||
[self.delegate functionViewDidRequestSubscription:self];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Event Parsing
|
||||
|
||||
- (NSString *)kb_normalizedLLMChunkString:(id)dataValue {
|
||||
|
||||
Reference in New Issue
Block a user