update chat exp

This commit is contained in:
2025-09-16 19:03:00 +08:00
parent 141c6a5909
commit 4e00f2a382
6 changed files with 1104 additions and 874 deletions
+9 -10
View File
@@ -33,7 +33,7 @@ export interface IChatPanelCallback {
/**
* 对话更新回调
*/
onDialogUpdated(): void;
onDialogUpdated(isPlayer: boolean): void;
/**
* 聊天次数用尽回调
@@ -135,7 +135,7 @@ export class ChatController {
this.loadDialogsFromHistory(roleId);
// 同步到DialogManager
this.syncDialogData();
//this.syncDialogData();
console.log(`ChatController initialized with role ${roleId}`);
} else {
@@ -162,7 +162,7 @@ export class ChatController {
this.loadDialogsFromHistory(roleId);
// 同步对话数据到DialogManager
this.syncDialogData();
//this.syncDialogData();
console.log(`ChatController switched to role ${roleId}`);
return true;
@@ -196,16 +196,15 @@ export class ChatController {
// 更新对话显示 - 用户消息
this.dialogManager?.updateDialog(true, message, true);
this.callback?.onDialogUpdated();
this.callback?.onDialogUpdated(true);
// 通知界面消息发送开始
this.callback?.onMessageSent(message);
// 显示加载中的对话
this.dialogManager?.addLoadingDialog();
//this.dialogManager?.addLoadingDialog();
console.log(`Sending message to role ${roleId}: ${message}`);
// 发送消息给AI服务
const response = await ChatAIService.Instance.sendMessage(
roleId,
@@ -214,14 +213,14 @@ export class ChatController {
if (response) {
// 移除加载中的对话
this.dialogManager?.removeLoadingDialog();
//this.dialogManager?.removeLoadingDialog();
// 添加AI回复到模型 (保持完整消息)
this.chatModel.addDialog(false, response);
// 更新对话显示 - AI回复 (使用分段显示)
this.dialogManager?.updateDialogWithSegments(false, response);
this.callback?.onDialogUpdated();
this.callback?.onDialogUpdated(false);
// 通知界面收到回复
this.callback?.onMessageReceived(response);
@@ -235,7 +234,7 @@ export class ChatController {
return true;
} else {
// 移除加载中的对话
this.dialogManager?.removeLoadingDialog();
//this.dialogManager?.removeLoadingDialog();
const error = new Error("AI返回了空响应");
this.handleError(error);
@@ -243,7 +242,7 @@ export class ChatController {
}
} catch (error) {
// 移除加载中的对话
this.dialogManager?.removeLoadingDialog();
//this.dialogManager?.removeLoadingDialog();
ErrorHandler.Instance.handleApiError(
error,