diff --git a/src/controller/ai-chat/ai-chat.controller.ts b/src/controller/ai-chat/ai-chat.controller.ts index 5b848f1b3a9c7f07a50a320bbc44696d9219fd49..d381e3bfeeb320a66ff31b9cece4a68f8c321a0e 100644 --- a/src/controller/ai-chat/ai-chat.controller.ts +++ b/src/controller/ai-chat/ai-chat.controller.ts @@ -244,12 +244,12 @@ export class AiChatController { * @param {string} id * @param {boolean} completed */ - completeMessage(id: string, completed: boolean): void { + async completeMessage(id: string, completed: boolean): Promise { const chatMsg = this.messages.value.find(item => item.messageid === id); if (chatMsg) { chatMsg.updateCompleted(completed); this.messages.value = [...this.messages.value]; - this.asyncToIndexDB(); + await this.asyncToIndexDB(); } } @@ -293,7 +293,7 @@ export class AiChatController { * @date 2025-03-10 14:03:17 * @param {IChatMessage} data */ - stopMessage(data: IChatMessage): void { + async stopMessage(data: IChatMessage): Promise { const i = this.messages.value.findIndex( item => item.messageid === data.messageid, ); @@ -305,7 +305,7 @@ export class AiChatController { } else { this.messages.value = [...this.messages.value, new ChatMessage(data)]; } - this.asyncToIndexDB(); + await this.asyncToIndexDB(); } /** @@ -398,9 +398,9 @@ export class AiChatController { * @author tony001 * @date 2025-03-10 14:03:48 */ - abortQuestion(): void { + async abortQuestion(): Promise { try { - this.opts.abortQuestion(this); + await this.opts.abortQuestion(this); } finally { this.isLoading.value = false; } @@ -511,7 +511,7 @@ export class AiChatController { */ async resetTopic() { // 中断请求 - this.abortQuestion(); + await this.abortQuestion(); // 清除缓存 if (this.topicId) { await IndexedDBUtil.deleteData( @@ -536,7 +536,7 @@ export class AiChatController { */ async clearTopic() { // 中断请求 - this.abortQuestion(); + await this.abortQuestion(); // 清除缓存 if (this.topicId) { await IndexedDBUtil.deleteData( diff --git a/src/interface/i-chat-options/i-chat-options.ts b/src/interface/i-chat-options/i-chat-options.ts index 8ff3f56c8a67073b3a6660c49d5d3f888f603078..259c4845635a82b2d7403f036f3f7a1ecad05163 100644 --- a/src/interface/i-chat-options/i-chat-options.ts +++ b/src/interface/i-chat-options/i-chat-options.ts @@ -163,7 +163,7 @@ export interface IChatOptions extends IChat { * @date 2025-03-10 14:03:37 * @param {AiChatController} aiChat */ - abortQuestion(aiChat: AiChatController): void; + abortQuestion(aiChat: AiChatController): Promise; /** * 聊天窗历史记录获取