From 7bf4d8feddb4cefe15a01396103b09b430026560 Mon Sep 17 00:00:00 2001 From: jianglinjun Date: Thu, 9 May 2024 19:28:37 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E6=9B=B4=E6=96=B0=E7=82=B9=E5=87=BB?= =?UTF-8?q?=E5=AF=B9=E8=AF=9D=E7=9A=84=E6=8F=90=E9=97=AE=EF=BC=8C=E5=88=A0?= =?UTF-8?q?=E9=99=A4=EF=BC=8C=E5=88=B7=E6=96=B0=EF=BC=8C=E5=A4=8D=E5=88=B6?= =?UTF-8?q?=EF=BC=8C=E5=85=A8=E5=B1=8F=EF=BC=8C=E5=85=B3=E9=97=AD=E8=A1=8C?= =?UTF-8?q?=E4=B8=BA=E6=97=B6=EF=BC=8C=E9=83=BD=E4=BC=9A=E5=90=91=E5=A4=96?= =?UTF-8?q?=E6=9A=B4=E9=9C=B2=E5=BD=93=E5=89=8D=E6=89=A7=E8=A1=8C=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/chat-container/chat-container.tsx | 9 +++++++++ src/controller/ai-chat/ai-chat.controller.ts | 12 ++++++++++++ src/controller/chat/chat.controller.ts | 5 +++++ src/interface/i-chat-options/i-chat-options.ts | 8 ++++++++ 4 files changed, 34 insertions(+) diff --git a/src/components/chat-container/chat-container.tsx b/src/components/chat-container/chat-container.tsx index eaff679..aa906f1 100644 --- a/src/components/chat-container/chat-container.tsx +++ b/src/components/chat-container/chat-container.tsx @@ -24,6 +24,13 @@ export interface ChatContainerProps { * @date 2023-10-15 19:10:35 */ close: () => void; + + /** + * 全屏行为 + * + * @memberof ChatContainerProps + */ + fullscreen: (target: boolean) => void; } interface ChatContainerState { @@ -177,6 +184,7 @@ export class ChatContainer extends Component< if (container) { container.requestFullscreen(); this.setState({ isFullScreen: true }); + this.props.fullscreen(true); } } @@ -190,6 +198,7 @@ export class ChatContainer extends Component< if (this.state.isFullScreen) { document?.exitFullscreen(); this.setState({ isFullScreen: false }); + this.props.fullscreen(false); } } diff --git a/src/controller/ai-chat/ai-chat.controller.ts b/src/controller/ai-chat/ai-chat.controller.ts index d7f9d4c..bc2018f 100644 --- a/src/controller/ai-chat/ai-chat.controller.ts +++ b/src/controller/ai-chat/ai-chat.controller.ts @@ -109,6 +109,9 @@ export class AiChatController { .filter(item => item.type !== 'ERROR') .map(item => item._origin), ); + if (this.opts.action) { + this.opts.action('question', input); + } } /** @@ -139,6 +142,9 @@ export class AiChatController { this.messages.value.splice(i, 1); this.messages.value = [...this.messages.value]; } + if (this.opts.action) { + this.opts.action('deletemsg', message); + } } /** @@ -172,6 +178,9 @@ export class AiChatController { this.messages.value.splice(i - 1, 2); this.question(lastques); } + if (this.opts.action) { + this.opts.action('refreshmsg', message); + } } /** @@ -183,5 +192,8 @@ export class AiChatController { copyMessage(message: IChatMessage) { const text = message.content; TextUtil.copy(text); + if (this.opts.action) { + this.opts.action('copymsg', message); + } } } diff --git a/src/controller/chat/chat.controller.ts b/src/controller/chat/chat.controller.ts index 785f40d..7c3f168 100644 --- a/src/controller/chat/chat.controller.ts +++ b/src/controller/chat/chat.controller.ts @@ -43,6 +43,11 @@ export class ChatController { opts.closed(); } }, + fullscreen: (target: boolean) => { + if (opts.fullscreen) { + opts.fullscreen(target); + } + }, }), this.container, ); diff --git a/src/interface/i-chat-options/i-chat-options.ts b/src/interface/i-chat-options/i-chat-options.ts index 2d205b8..97fbfef 100644 --- a/src/interface/i-chat-options/i-chat-options.ts +++ b/src/interface/i-chat-options/i-chat-options.ts @@ -39,6 +39,14 @@ export interface IChatOptions { */ action?(action: string, params?: T): Promise; + /** + * 全屏操作 + * + * @param {boolean} target + * @memberof IChatOptions + */ + fullscreen?(target: boolean): void; + /** * 聊天窗口呈现 * -- Gitee