处理为识别到语音
This commit is contained in:
@@ -60,6 +60,9 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
/// 移除 loading AI 消息
|
/// 移除 loading AI 消息
|
||||||
- (void)removeLoadingAssistantMessage;
|
- (void)removeLoadingAssistantMessage;
|
||||||
|
|
||||||
|
/// 移除 loading 用户消息
|
||||||
|
- (void)removeLoadingUserMessage;
|
||||||
|
|
||||||
/// 滚动到底部
|
/// 滚动到底部
|
||||||
- (void)scrollToBottom;
|
- (void)scrollToBottom;
|
||||||
|
|
||||||
|
|||||||
@@ -401,6 +401,32 @@ static inline CGFloat KBChatAbsTimeInterval(NSTimeInterval interval) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)removeLoadingUserMessage {
|
||||||
|
if (self.inverted) {
|
||||||
|
for (NSInteger i = 0; i < self.messages.count; i++) {
|
||||||
|
KBAiChatMessage *message = self.messages[i];
|
||||||
|
if (message.type == KBAiChatMessageTypeUser && message.isLoading) {
|
||||||
|
[self.messages removeObjectAtIndex:i];
|
||||||
|
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:i inSection:0];
|
||||||
|
[self.tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
|
||||||
|
NSLog(@"[KBChatTableView] 移除 loading 用户消息,索引: %ld", (long)i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (NSInteger i = self.messages.count - 1; i >= 0; i--) {
|
||||||
|
KBAiChatMessage *message = self.messages[i];
|
||||||
|
if (message.type == KBAiChatMessageTypeUser && message.isLoading) {
|
||||||
|
[self.messages removeObjectAtIndex:i];
|
||||||
|
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:i inSection:0];
|
||||||
|
[self.tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
|
||||||
|
NSLog(@"[KBChatTableView] 移除 loading 用户消息,索引: %ld", (long)i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (void)scrollToBottom {
|
- (void)scrollToBottom {
|
||||||
[self scrollToBottomAnimated:YES];
|
[self scrollToBottomAnimated:YES];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,9 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
/// 更新最后一条用户消息
|
/// 更新最后一条用户消息
|
||||||
- (void)updateLastUserMessage:(NSString *)text;
|
- (void)updateLastUserMessage:(NSString *)text;
|
||||||
|
|
||||||
|
/// 移除 loading 用户消息
|
||||||
|
- (void)removeLoadingUserMessage;
|
||||||
|
|
||||||
/// 添加 AI 消息(支持打字机效果)
|
/// 添加 AI 消息(支持打字机效果)
|
||||||
- (void)appendAssistantMessage:(NSString *)text
|
- (void)appendAssistantMessage:(NSString *)text
|
||||||
audioId:(nullable NSString *)audioId;
|
audioId:(nullable NSString *)audioId;
|
||||||
|
|||||||
@@ -637,6 +637,32 @@ static NSString * const KBChatSessionDidResetNotification = @"KBChatSessionDidRe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)removeLoadingUserMessage {
|
||||||
|
if (!self.messages) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (self.chatView.inverted) {
|
||||||
|
for (NSInteger i = 0; i < self.messages.count; i++) {
|
||||||
|
KBAiChatMessage *message = self.messages[i];
|
||||||
|
if (message.type == KBAiChatMessageTypeUser && message.isLoading) {
|
||||||
|
[self.messages removeObjectAtIndex:i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (NSInteger i = self.messages.count - 1; i >= 0; i--) {
|
||||||
|
KBAiChatMessage *message = self.messages[i];
|
||||||
|
if (message.type == KBAiChatMessageTypeUser && message.isLoading) {
|
||||||
|
[self.messages removeObjectAtIndex:i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[self.chatView removeLoadingUserMessage];
|
||||||
|
}
|
||||||
|
|
||||||
- (void)markLastUserMessageLoadingComplete {
|
- (void)markLastUserMessageLoadingComplete {
|
||||||
[self.chatView markLastUserMessageLoadingComplete];
|
[self.chatView markLastUserMessageLoadingComplete];
|
||||||
|
|
||||||
|
|||||||
@@ -959,7 +959,7 @@
|
|||||||
NSLog(@"[KBAIHomeVC] 语音转文字结果为空");
|
NSLog(@"[KBAIHomeVC] 语音转文字结果为空");
|
||||||
[KBHUD showError:KBLocalized(@"未识别到语音内容")];
|
[KBHUD showError:KBLocalized(@"未识别到语音内容")];
|
||||||
if (cell) {
|
if (cell) {
|
||||||
[cell updateLastUserMessage:KBLocalized(@"未识别到语音")];
|
[cell removeLoadingUserMessage];
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user