This commit is contained in:
2025-11-12 16:49:19 +08:00
parent fea22aecab
commit 2f4205ad1a
7 changed files with 144 additions and 18 deletions

View File

@@ -40,6 +40,8 @@ static NSString * const kKBFunctionTagCellId = @"KBFunctionTagCellId";
//
@property (nonatomic, strong, nullable) KBStreamFetcher *streamFetcher;
@property (nonatomic, assign) BOOL streamHasOutput; // \t
@property (nonatomic, strong, nullable) NSNumber *loadingTagIndex; // loadingindex
@property (nonatomic, copy, nullable) NSString *loadingTagTitle;
// Data
@property (nonatomic, strong) NSArray<NSString *> *itemsInternal;
@@ -212,8 +214,7 @@ static NSString * const kKBFunctionTagCellId = @"KBFunctionTagCellId";
}];
self.streamOverlay = overlay;
// GET
[self kb_startNetworkStreamingWithSeed:title];
// UI cell start
}
- (void)kb_onTapStreamDelete {
@@ -258,8 +259,13 @@ static NSString * const kKBStreamDemoURL = @"http://192.168.1.144:7529/api/demo/
};
fetcher.onFinish = ^(NSError * _Nullable error) {
__strong typeof(weakSelf) self = weakSelf; if (!self) return;
// loading
if (!self.streamHasOutput && self.loadingTagIndex) {
[self.tagListView setLoading:NO atIndex:self.loadingTagIndex.integerValue];
self.loadingTagIndex = nil; self.loadingTagTitle = nil;
}
if (error) { [KBHUD showInfo:@"拉取失败"]; }
[self.streamOverlay finish];
if (self.streamOverlay) { [self.streamOverlay finish]; }
};
self.streamFetcher = fetcher;
[self.streamFetcher start];
@@ -277,7 +283,16 @@ static NSString * const kKBStreamDemoURL = @"http://192.168.1.144:7529/api/demo/
/// - KBStreamFetcher /t->\t \t
/// - UI
- (void)kb_appendChunkToStreamView:(NSString *)chunk {
if (chunk.length == 0 || !self.streamOverlay) return;
if (chunk.length == 0) return;
// overlay cell
if (!self.streamOverlay) {
[self kb_showStreamTextViewIfNeededWithTitle:self.loadingTagTitle ?: @""];
if (self.loadingTagIndex) {
[self.tagListView setLoading:NO atIndex:self.loadingTagIndex.integerValue];
self.loadingTagIndex = nil; self.loadingTagTitle = nil;
}
}
if (!self.streamOverlay) return;
[self.streamOverlay appendChunk:chunk];
self.streamHasOutput = YES;
}
@@ -287,10 +302,14 @@ static NSString * const kKBStreamDemoURL = @"http://192.168.1.144:7529/api/demo/
- (void)tagListView:(KBFunctionTagListView *)view didSelectIndex:(NSInteger)index title:(NSString *)title {
// + 访访
if ([[KBFullAccessManager shared] hasFullAccess]) {
[self kb_showStreamTextViewIfNeededWithTitle:title ?: @""];
// cell overlay
[self.tagListView setLoading:YES atIndex:index];
self.loadingTagIndex = @(index);
self.loadingTagTitle = title ?: @"";
[self kb_startNetworkStreamingWithSeed:self.loadingTagTitle];
return;
}
// App
// 访
[KBHUD showInfo:@"处理中…"];
UIInputViewController *ivc = KBFindInputViewController(self);
if (!ivc) return;