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
@@ -123,11 +123,6 @@ export class DialogManager {
segments: string[],
isPlayer: boolean
): void {
// let currentDelay = 500; // 基础延迟 500ms
// 每个后续段落增加随机延迟 (800-1500ms)
// currentDelay += 800 + Math.random() * 700;
segments.forEach((segment, index) => {
this.dialogData.pushDialog(isPlayer, segment);
});
@@ -143,28 +138,15 @@ export class DialogManager {
Utils.sendInnerMsg(InnerMsgCode.Chat_DialogRefresh);
}
/**
* 移除加载中的对话
* 在收到AI回复或出错时调用
*/
public removeLoadingDialog(): void {
const dialogs = this.dialogData.GetDialogs();
const loadingIndex = dialogs.findIndex((dialog) => dialog.isLoading);
if (loadingIndex !== -1) {
dialogs.splice(loadingIndex, 1);
console.log("Loading dialog removed");
Utils.sendInnerMsg(InnerMsgCode.Chat_DialogRefresh);
}
}
/**
* 获取所有对话记录
*
* @returns {Dialog[]} 对话记录数组
*/
public getDialogs() {
return this.dialogData.GetDialogs();
public GetPlayerDialog() {
return this.dialogData.GetPlayerDialog();
}
public GetAIDialog() {
return this.dialogData.GetAIDialog();
}
/**
* 清空当前对话记录
@@ -172,7 +154,6 @@ export class DialogManager {
public clearDialogs(): void {
this.dialogData.cleanDialog();
console.log("All dialogs cleared");
Utils.sendInnerMsg(InnerMsgCode.Chat_DialogRefresh);
}
/**
@@ -185,7 +166,6 @@ export class DialogManager {
this.dialogData.pushDialog(
dialog.isPlayer,
dialog.content,
dialog.isLoading || false
);
});
console.log(`DialogManager: Set ${dialogs.length} dialogs`);
@@ -201,25 +181,4 @@ export class DialogManager {
console.log("DialogManager: Synced dialogs from ChatModel");
}
/**
* 获取对话记录数量
*/
public getDialogCount(): number {
return this.dialogData.GetDialogs().length;
}
/**
* 获取最后一条对话记录
*/
public getLastDialog(): Dialog | null {
const dialogs = this.dialogData.GetDialogs();
return dialogs.length > 0 ? dialogs[dialogs.length - 1] : null;
}
/**
* 检查是否有对话记录
*/
public hasDialogs(): boolean {
return this.dialogData.GetDialogs().length > 0;
}
}