From 77c804dbcad7f0865d047e17f9d847f114ab685c Mon Sep 17 00:00:00 2001 From: ShineKOT <1917095344@qq.com> Date: Wed, 19 Mar 2025 18:13:10 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chat-topic-item/chat-topic-item.tsx | 32 ++++++++++++------- src/components/popup/popup.tsx | 2 +- .../ai-topic/ai-topic.controller.ts | 19 ++++++++--- 3 files changed, 37 insertions(+), 16 deletions(-) diff --git a/src/components/chat-topic-item/chat-topic-item.tsx b/src/components/chat-topic-item/chat-topic-item.tsx index 3dbcf79..c2d1607 100644 --- a/src/components/chat-topic-item/chat-topic-item.tsx +++ b/src/components/chat-topic-item/chat-topic-item.tsx @@ -75,18 +75,28 @@ export const ChatTopicItem = (props: ChatTopicItemProps) => { }; /** - * 处理重命名 + * 处理失焦事件 + * + * - 关闭编辑状态 + * - 执行重命名行为 + * @param {MouseEvent} event + */ + const handleBlur = (event: Event) => { + event.stopPropagation(); + isEditMode.value = false; + onAction('RENAME', event as MouseEvent); + }; + + /** + * 处理回车事件 + * + * - 关闭编辑状态 * @param event */ - const handleRename = (event: Event) => { + const handleKeyDown = (event: KeyboardEvent) => { event.stopPropagation(); - // 如果是回车事件或者失去焦点退出编辑模式并保存 - if ( - (event.type === 'keydown' && (event as any).key === 'Enter') || - event.type === 'focusout' - ) { + if (event.key === 'Enter') { isEditMode.value = false; - onAction('RENAME', event as MouseEvent); } }; @@ -103,8 +113,8 @@ export const ChatTopicItem = (props: ChatTopicItemProps) => { e.stopPropagation()} onChange={value => handleChange(value)} className={ns.em('caption', 'editor')} @@ -125,8 +135,8 @@ export const ChatTopicItem = (props: ChatTopicItemProps) => { {!active.value ? ( }, { id: 'RENAME', caption: '重命名', icon: }, + { id: 'DELETE', caption: '删除话题', icon: }, ]} position='bottom' isOpen={isPopupOpen} diff --git a/src/components/popup/popup.tsx b/src/components/popup/popup.tsx index fc6fce4..71aba4e 100644 --- a/src/components/popup/popup.tsx +++ b/src/components/popup/popup.tsx @@ -68,7 +68,7 @@ export const Popup = ({ if ( triggerRef.current && !triggerRef.current.contains(event.target as Node) && - !(event.target as HTMLElement).closest(`.${ns.b('content')}`) && + !(event.target as HTMLElement).closest(`.${ns.b()}`) && !(event.target as HTMLElement).closest('.ibiz-quick-edit') && !(event.target as HTMLElement).closest('.ibiz-picker__transfer') ) { diff --git a/src/controller/ai-topic/ai-topic.controller.ts b/src/controller/ai-topic/ai-topic.controller.ts index 97a0cdd..e8eea73 100644 --- a/src/controller/ai-topic/ai-topic.controller.ts +++ b/src/controller/ai-topic/ai-topic.controller.ts @@ -181,21 +181,32 @@ export class AiTopicController { /** * 更新话题数据 * - * @param {ChatTopic} data 话题数据 * @param {ITopicOptions} options 话题配置 + * @param {ChatTopic} _data 话题数据 * @return {*} {Promise} * @memberof AiTopicController */ public async updateTopic( - data: ChatTopic, options: ITopicOptions, + _data: ChatTopic, ): Promise { + const result = this.topics.value.map(item => { + return { + appid: item.appid, + id: item.id, + type: item.type, + caption: item.caption, + sourceCaption: item.sourceCaption, + url: item.url, + aiChat: item.aiChat, + }; + }); const config = options.configService( options.appid, 'aitopics', options.type, ); - await config?.save(data); + await config?.save(result); } /** @@ -243,7 +254,7 @@ export class AiTopicController { event, ); } else if (action === 'RENAME') { - await this.updateTopic(topic, this.currentTopicOptions); + await this.updateTopic(this.currentTopicOptions, topic); } this.currentTopicOptions.action?.(action, context, params, topic, event); } -- Gitee