新增聊天记录

This commit is contained in:
2026-01-26 18:17:02 +08:00
parent f9d7579536
commit 6a177ceebc
14 changed files with 1447 additions and 18 deletions

View File

@@ -8,14 +8,18 @@
#import "KBAIHomeVC.h"
#import "KBPersonaChatCell.h"
#import "KBPersonaModel.h"
#import "KBVoiceInputBar.h"
#import "AiVM.h"
#import <Masonry/Masonry.h>
@interface KBAIHomeVC () <UICollectionViewDelegate, UICollectionViewDataSource>
@interface KBAIHomeVC () <UICollectionViewDelegate, UICollectionViewDataSource, KBVoiceInputBarDelegate>
///
@property (nonatomic, strong) UICollectionView *collectionView;
///
@property (nonatomic, strong) KBVoiceInputBar *voiceInputBar;
///
@property (nonatomic, strong) NSMutableArray<KBPersonaModel *> *personas;
@@ -67,6 +71,14 @@
[self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.view);
}];
//
[self.view addSubview:self.voiceInputBar];
[self.voiceInputBar mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.equalTo(self.view);
make.bottom.equalTo(self.view);
make.height.mas_equalTo(150); //
}];
}
#pragma mark - 2
@@ -183,6 +195,13 @@
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
KBPersonaChatCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"KBPersonaChatCell" forIndexPath:indexPath];
cell.persona = self.personas[indexPath.item];
//
[self.preloadedIndexes addObject:@(indexPath.item)];
//
[cell preloadDataIfNeeded];
return cell;
}
@@ -241,4 +260,44 @@
return _collectionView;
}
- (KBVoiceInputBar *)voiceInputBar {
if (!_voiceInputBar) {
_voiceInputBar = [[KBVoiceInputBar alloc] init];
_voiceInputBar.delegate = self;
_voiceInputBar.statusText = @"按住按钮开始对话";
}
return _voiceInputBar;
}
#pragma mark - KBVoiceInputBarDelegate
- (void)voiceInputBarDidBeginRecording:(KBVoiceInputBar *)inputBar {
NSLog(@"[KBAIHomeVC] 开始录音");
inputBar.statusText = @"正在聆听...";
// TODO:
// 1.
// 2.
// 3.
}
- (void)voiceInputBarDidEndRecording:(KBVoiceInputBar *)inputBar {
NSLog(@"[KBAIHomeVC] 结束录音");
inputBar.statusText = @"正在识别...";
// TODO:
// 1.
// 2.
// 3.
}
- (void)voiceInputBarDidCancelRecording:(KBVoiceInputBar *)inputBar {
NSLog(@"[KBAIHomeVC] 取消录音");
inputBar.statusText = @"已取消";
// TODO:
// 1.
// 2.
}
@end