diff --git a/src/components/chat-topic-item/chat-topic-item.tsx b/src/components/chat-topic-item/chat-topic-item.tsx
index 3dbcf79a96ef10b1bd84d591bd87cfe8c94c3dd2..c2d16075cece2eb65348a391641fc5bff1cb2942 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 fc6fce445e2b83fedd2ec0a9284c402811b43dbe..71aba4e83db1d8d50d32ecef08aa1083531e8df4 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 97a0cdd0885a4096461744b02f56ea94f029bc09..e8eea73c95f5605e8d582416a07d15437ad856da 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);
}