From 7bf4d8feddb4cefe15a01396103b09b430026560 Mon Sep 17 00:00:00 2001 From: jianglinjun Date: Thu, 9 May 2024 19:28:37 +0800 Subject: [PATCH 1/2] =?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 From 13413a93a6bf2153567a2eaf7a0e17230254d243 Mon Sep 17 00:00:00 2001 From: jianglinjun Date: Fri, 10 May 2024 11:13:37 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E6=B6=88=E6=81=AF=E5=AF=B9=E8=AF=9D=E6=A1=86=E7=9A=84?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F=EF=BC=8CIA=E8=81=8A=E5=A4=A9=E6=9A=B4?= =?UTF-8?q?=E9=9C=B2=E4=BA=8B=E4=BB=B6=E6=A0=87=E8=AF=86=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E9=99=90=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 2 + .../chat-container/chat-container.scss | 2 +- .../chat-container/chat-container.tsx | 12 +++- .../error-message/error-message.scss | 63 ++++++++++++++++- .../error-message/error-message.tsx | 70 ++++++++++++++++++- src/controller/chat/chat.controller.ts | 1 + .../i-chat-options/i-chat-options.ts | 17 ++++- 7 files changed, 160 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cf0f4e8..c0c9c13 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ ## [Unreleased] +- 更新错误消息对话框的样式,IA聊天暴露事件标识增加限定 + ## [0.0.4] - 2024-05-08 - 更新提问框样式 diff --git a/src/components/chat-container/chat-container.scss b/src/components/chat-container/chat-container.scss index bd59086..fb64553 100644 --- a/src/components/chat-container/chat-container.scss +++ b/src/components/chat-container/chat-container.scss @@ -49,7 +49,7 @@ $ai-chat: ( } @include b(chat-container-header-caption) { - padding: 0 6px; + padding: 0 6px 0 16px ; font-size: 18px; font-weight: 800; } diff --git a/src/components/chat-container/chat-container.tsx b/src/components/chat-container/chat-container.tsx index aa906f1..2bd3742 100644 --- a/src/components/chat-container/chat-container.tsx +++ b/src/components/chat-container/chat-container.tsx @@ -31,6 +31,14 @@ export interface ChatContainerProps { * @memberof ChatContainerProps */ fullscreen: (target: boolean) => void; + + /** + * 标题 + * + * @type {string} + * @memberof ChatContainerProps + */ + caption?: string; } interface ChatContainerState { @@ -211,7 +219,9 @@ export class ChatContainer extends Component< ref={this.containerRef} >
-
AIChat
+
+ {this.props.caption || 'AIChart'} +
{this.state.isFullScreen ? (
{ const content = useComputed(() => props.message.content); + + const onBackfill = () => { + props.controller.backfill(props.message); + }; + + const onDeleteMessage = () => { + props.controller.deleteMessage(props.message); + }; + + const onRefreshMessage = () => { + props.controller.refreshMessage(props.message); + }; + + const onCopyMessage = () => { + props.controller.copyMessage(props.message); + }; + return (
- {content} +
+
AI
+
+
+ + + 回填 + +
+
+ + + 刷新 + +
+
+ + + 删除 + +
+
+ + + 复制 + +
+
+
+
+ {content} +
); }; diff --git a/src/controller/chat/chat.controller.ts b/src/controller/chat/chat.controller.ts index 7c3f168..72c444b 100644 --- a/src/controller/chat/chat.controller.ts +++ b/src/controller/chat/chat.controller.ts @@ -37,6 +37,7 @@ export class ChatController { render( h(ChatContainer, { controller: c, + caption: opts.caption, close: () => { this.close(); if (opts.closed) { diff --git a/src/interface/i-chat-options/i-chat-options.ts b/src/interface/i-chat-options/i-chat-options.ts index 97fbfef..44b02ea 100644 --- a/src/interface/i-chat-options/i-chat-options.ts +++ b/src/interface/i-chat-options/i-chat-options.ts @@ -33,16 +33,19 @@ export interface IChatOptions { * * @author chitanda * @date 2023-10-13 18:10:56 - * @param {string} action 操作的行为标识 + * @param {string} action 操作的行为标识 backfill:回填 question:提问 deletemsg:删除消息 refreshmsg:刷新消息 * @param {T} [params] 传递的参数 * @return {*} {Promise} 等待操作,用于显示 loading 并获取最终成功与否 */ - action?(action: string, params?: T): Promise; + action?( + action: 'backfill' | 'question' | 'deletemsg' | 'refreshmsg', + params?: T, + ): Promise; /** * 全屏操作 * - * @param {boolean} target + * @param {boolean} target true为打开,false为关闭 * @memberof IChatOptions */ fullscreen?(target: boolean): void; @@ -55,4 +58,12 @@ export interface IChatOptions { * @type {IChatContainerOptions} */ containerOptions?: IChatContainerOptions; + + /** + * 聊天窗口标题 + * + * @type {string} + * @memberof IChatOptions + */ + caption?: string; } -- Gitee