From a9969eea20a347c85d6d075ffd2ed5fe570f82ee Mon Sep 17 00:00:00 2001 From: ShineKOT <1917095344@qq.com> Date: Mon, 7 Apr 2025 20:28:04 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=87=8D=E7=BD=AE=E5=92=8C=E6=B8=85?= =?UTF-8?q?=E7=A9=BA=E5=AF=B9=E8=AF=9D=E6=97=B6=E4=B8=AD=E6=96=ADAI?= =?UTF-8?q?=E5=AF=B9=E8=AF=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controller/ai-chat/ai-chat.controller.ts | 16 ++++++++-------- src/interface/i-chat-options/i-chat-options.ts | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/controller/ai-chat/ai-chat.controller.ts b/src/controller/ai-chat/ai-chat.controller.ts index 5b848f1..d381e3b 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 8ff3f56..259c484 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; /** * 聊天窗历史记录获取 -- Gitee