mirror of
https://github.com/chaos-zhu/easynode.git
synced 2026-10-07 12:48:28 +08:00
🐛 修复AI会话历史记录bug
This commit is contained in:
@@ -60,9 +60,8 @@ async function saveChatHistory({ res, request }) {
|
||||
|
||||
async function removeChatHistory({ res, request }) {
|
||||
let { params: { id } } = request
|
||||
console.log(id)
|
||||
if (!id) return res.fail({ data: false, msg: '参数错误' })
|
||||
await chatHistoryDB.removeAsync({ id })
|
||||
await chatHistoryDB.removeAsync({ _id: id })
|
||||
res.success({ data: true })
|
||||
}
|
||||
|
||||
|
||||
@@ -32,15 +32,22 @@
|
||||
</template>
|
||||
</el-dropdown>
|
||||
<div class="right_wrap">
|
||||
<el-icon class="right_wrap_icon" title="新建对话" @click="addChat">
|
||||
<el-icon
|
||||
class="right_wrap_icon"
|
||||
title="新建对话"
|
||||
@click="addChat"
|
||||
>
|
||||
<Plus />
|
||||
</el-icon>
|
||||
<el-dropdown
|
||||
v-if="hasChatHistory"
|
||||
:disabled="!hasChatHistory"
|
||||
trigger="click"
|
||||
class="chat_list_dropdown"
|
||||
>
|
||||
<el-icon class="right_wrap_icon" title="历史记录" @click="handleChatListDropdown">
|
||||
<el-icon
|
||||
class="right_wrap_icon"
|
||||
title="历史记录"
|
||||
>
|
||||
<ChatDotRound />
|
||||
</el-icon>
|
||||
<template #dropdown>
|
||||
@@ -55,7 +62,7 @@
|
||||
<div class="chat_item_info">
|
||||
<span>{{ new Date(chatItem.createdAt).toLocaleString() }}</span>
|
||||
</div>
|
||||
<el-icon class="chat_item_icon" @click.stop="removeChat(chatItem.id)">
|
||||
<el-icon class="chat_item_icon" @click.stop="removeChat(chatItem._id)">
|
||||
<Delete />
|
||||
</el-icon>
|
||||
</div>
|
||||
@@ -333,10 +340,6 @@ const handleSetting = () => {
|
||||
aiApiConfigVisible.value = true
|
||||
}
|
||||
|
||||
const handleChatListDropdown = () => {
|
||||
$store.getChatHistory()
|
||||
}
|
||||
|
||||
</script>
|
||||
<style scoped lang="scss">
|
||||
.ai_header_wrap {
|
||||
|
||||
@@ -208,7 +208,12 @@ export function useAIChat() {
|
||||
const removeChat = async (id) => {
|
||||
await $api.removeChatHistory(id)
|
||||
ElMessage.success('删除成功')
|
||||
$store.getChatHistory()
|
||||
await $store.getChatHistory()
|
||||
if (chatHistory.value.length > 0) {
|
||||
changeChat(chatHistory.value[0].id)
|
||||
} else {
|
||||
addChat()
|
||||
}
|
||||
}
|
||||
|
||||
const changeChat = (id) => {
|
||||
@@ -217,8 +222,11 @@ export function useAIChat() {
|
||||
curChat.value = chatItem
|
||||
}
|
||||
|
||||
const saveChat = () => {
|
||||
$api.saveChatHistory(curChat.value)
|
||||
const saveChat = async () => {
|
||||
await $api.saveChatHistory(curChat.value)
|
||||
setTimeout(() => {
|
||||
$store.getChatHistory()
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
onUnmounted(() => {
|
||||
|
||||
@@ -5705,9 +5705,9 @@ supports-preserve-symlinks-flag@^1.0.0:
|
||||
integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==
|
||||
|
||||
tar-fs@^2.0.0, tar-fs@^2.1.1:
|
||||
version "2.1.1"
|
||||
resolved "https://registry.yarnpkg.com/tar-fs/-/tar-fs-2.1.1.tgz#489a15ab85f1f0befabb370b7de4f9eb5cbe8784"
|
||||
integrity sha512-V0r2Y9scmbDRLCNex/+hYzvp/zyYjvFbHPNgVTKfQvVrb6guiE/fxP+XblDNR011utopbkex2nM4dHNV6GDsng==
|
||||
version "2.1.2"
|
||||
resolved "https://registry.yarnpkg.com/tar-fs/-/tar-fs-2.1.2.tgz#425f154f3404cb16cb8ff6e671d45ab2ed9596c5"
|
||||
integrity sha512-EsaAXwxmx8UB7FRKqeozqEPop69DXcmYwTQwXvyAPF352HJsPdkVhvTaDPYqfNgruveJIJy3TA2l+2zj8LJIJA==
|
||||
dependencies:
|
||||
chownr "^1.1.1"
|
||||
mkdirp-classic "^0.5.2"
|
||||
|
||||
Reference in New Issue
Block a user