新增聊天记录
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user