diff --git a/CHANGELOG.md b/CHANGELOG.md index cf0f4e832e8b0abd2f87434b1b4690666b697670..c0c9c132410285a9913518f83e8075250a1b9d49 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 bd59086963854211ea6e8614f4f6006bb919f426..fb6455387a68016c2fd98cf0ec2af2e5559f5cc1 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 eaff6796870f36ab5770edfd0d57b7a8103feb5e..2bd37422bee83a1b52a97077184c9fac6e17b65c 100644 --- a/src/components/chat-container/chat-container.tsx +++ b/src/components/chat-container/chat-container.tsx @@ -24,6 +24,21 @@ export interface ChatContainerProps { * @date 2023-10-15 19:10:35 */ close: () => void; + + /** + * 全屏行为 + * + * @memberof ChatContainerProps + */ + fullscreen: (target: boolean) => void; + + /** + * 标题 + * + * @type {string} + * @memberof ChatContainerProps + */ + caption?: string; } interface ChatContainerState { @@ -177,6 +192,7 @@ export class ChatContainer extends Component< if (container) { container.requestFullscreen(); this.setState({ isFullScreen: true }); + this.props.fullscreen(true); } } @@ -190,6 +206,7 @@ export class ChatContainer extends Component< if (this.state.isFullScreen) { document?.exitFullscreen(); this.setState({ isFullScreen: false }); + this.props.fullscreen(false); } } @@ -202,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/ai-chat/ai-chat.controller.ts b/src/controller/ai-chat/ai-chat.controller.ts index d7f9d4c1f52e5128720e0c653e46808b4e1df1d1..bc2018f8277944fd1e0218f2cd950c504c96bca2 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 785f40d384c8fe18411e4a5c795ebc373be86323..72c444bd84145c4daa721ad40e563d2042743a1e 100644 --- a/src/controller/chat/chat.controller.ts +++ b/src/controller/chat/chat.controller.ts @@ -37,12 +37,18 @@ export class ChatController { render( h(ChatContainer, { controller: c, + caption: opts.caption, close: () => { this.close(); if (opts.closed) { 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 2d205b85f628c597d271f57fb7051d2cecde5133..44b02ea4a090ac4db5b1b73dedc82ea40d684b48 100644 --- a/src/interface/i-chat-options/i-chat-options.ts +++ b/src/interface/i-chat-options/i-chat-options.ts @@ -33,11 +33,22 @@ 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 true为打开,false为关闭 + * @memberof IChatOptions + */ + fullscreen?(target: boolean): void; /** * 聊天窗口呈现 @@ -47,4 +58,12 @@ export interface IChatOptions { * @type {IChatContainerOptions} */ containerOptions?: IChatContainerOptions; + + /** + * 聊天窗口标题 + * + * @type {string} + * @memberof IChatOptions + */ + caption?: string; }