perf: 删除历史记录
This commit is contained in:
@ -21,29 +21,28 @@ import icon1 from '@/assets/img/media-account/icon-warn-1.png';
|
||||
const emits = defineEmits(['update', 'close', 'batchUpdate']);
|
||||
|
||||
const visible = ref(false);
|
||||
const chatId = ref(null);
|
||||
const conversationId = ref(null);
|
||||
|
||||
const isBatch = computed(() => Array.isArray(taskId.value));
|
||||
// const isBatch = computed(() => Array.isArray(taskId.value));
|
||||
|
||||
function onClose() {
|
||||
visible.value = false;
|
||||
chatId.value = null;
|
||||
conversationId.value = null;
|
||||
emits('close');
|
||||
}
|
||||
|
||||
const open = (record) => {
|
||||
console.log({record})
|
||||
const { id = null } = record;
|
||||
chatId.value = id;
|
||||
conversationId.value = id;
|
||||
|
||||
visible.value = true;
|
||||
};
|
||||
|
||||
async function onDelete() {
|
||||
const { code } = await deleteHistoryItem(chatId.value);
|
||||
const { code } = await deleteHistoryItem(conversationId.value);
|
||||
if (code === 200) {
|
||||
AMessage.success('删除成功');
|
||||
emits('delete', chatId.value);
|
||||
emits('delete', conversationId.value);
|
||||
onClose();
|
||||
}
|
||||
}
|
||||
|
||||
@ -82,6 +82,12 @@ export default {
|
||||
const { id } = item;
|
||||
handleUserHome({ conversationId: id });
|
||||
};
|
||||
const onDeleteConversation = (id) => {
|
||||
const index = dataSource.value.findIndex((item) => item.id === id);
|
||||
if (index === -1) return;
|
||||
|
||||
dataSource.value.splice(index, 1);
|
||||
}
|
||||
|
||||
expose({
|
||||
showDrawer,
|
||||
@ -107,7 +113,7 @@ export default {
|
||||
</section>
|
||||
)}
|
||||
|
||||
<DeleteChatModal ref={deleteChatModalRef} />
|
||||
<DeleteChatModal ref={deleteChatModalRef} onDelete={onDeleteConversation}/>
|
||||
</Drawer>
|
||||
);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user