feat: 历史对话增加删除

This commit is contained in:
wangdan-fit2cloud 2024-06-13 15:15:07 +08:00
parent b2460303db
commit 98a42074eb
5 changed files with 75 additions and 15 deletions

View File

@ -186,6 +186,18 @@ const getChatLogClient: (
)
}
/**
*
* @param application_id, chat_id,
*/
const delChatClientLog: (
application_id: string,
chat_id: string,
loading?: Ref<boolean>
) => Promise<Result<boolean>> = (application_id, chat_id, loading) => {
return del(`${prefix}/${application_id}/chat/client/${chat_id}`, undefined, {}, loading)
}
export default {
getChatLog,
delChatLog,
@ -195,5 +207,6 @@ export default {
getRecordDetail,
delMarkRecord,
exportChatLog,
getChatLogClient
getChatLogClient,
delChatClientLog
}

View File

@ -96,7 +96,6 @@
plain
size="small"
@click="openParagraph(item)"
:disabled="!item.paragraph_list || item.paragraph_list?.length === 0"
>引用分段{{ item.paragraph_list?.length || 0 }}</el-button
>
<el-tag type="info" effect="plain" class="mr-8 mt-8">

View File

@ -48,6 +48,18 @@ const useLogStore = defineStore({
reject(error)
})
})
},
async asyncDelChatClientLog(id: string, chatId: string, loading?: Ref<boolean>) {
return new Promise((resolve, reject) => {
logApi
.delChatClientLog(id, chatId, loading)
.then((data) => {
resolve(data)
})
.catch((error) => {
reject(error)
})
})
}
}
})

View File

@ -43,9 +43,16 @@
@click="clickListHandle"
>
<template #default="{ row }">
<auto-tooltip :content="row.abstract">
{{ row.abstract }}
</auto-tooltip>
<div class="flex-between">
<auto-tooltip :content="row.abstract">
{{ row.abstract }}
</auto-tooltip>
<div @click.stop>
<el-button text @click.stop="deleteLog(row)">
<el-icon><Delete /></el-icon>
</el-button>
</div>
</div>
</template>
<template #empty>
<div class="text-center">
@ -92,6 +99,18 @@ const paginationConfig = reactive({
const currentRecordList = ref<any>([])
const currentChatId = ref('new') // Id 'new'
function deleteLog(row: any) {
log.asyncDelChatClientLog(applicationDetail.value.id, row.id, left_loading).then(() => {
if (currentChatId.value === row.id) {
currentChatId.value = 'new'
paginationConfig.current_page = 1
paginationConfig.total = 0
currentRecordList.value = []
}
getChatLog(applicationDetail.value.id)
})
}
function handleScroll(event: any) {
if (
currentChatId.value !== 'new' &&
@ -289,7 +308,7 @@ onMounted(() => {
padding-top: 38px;
}
.ai-chat__content {
padding-bottom: 104px
padding-bottom: 104px;
}
}
}

View File

@ -25,9 +25,16 @@
@click="clickListHandle"
>
<template #default="{ row }">
<auto-tooltip :content="row.abstract">
{{ row.abstract }}
</auto-tooltip>
<div class="flex-between">
<auto-tooltip :content="row.abstract">
{{ row.abstract }}
</auto-tooltip>
<div @click.stop>
<el-button text @click.stop="deleteLog(row)">
<el-icon><Delete /></el-icon>
</el-button>
</div>
</div>
</template>
<template #empty>
<div class="text-center">
@ -69,7 +76,7 @@
</el-dropdown>
</span>
</div>
<div class="right-height chat-width">
<div class="right-height">
<!-- 对话 -->
<AiChat
ref="AiChatRef"
@ -80,7 +87,8 @@
:chatId="currentChatId"
@refresh="refresh"
@scroll="handleScroll"
></AiChat>
>
</AiChat>
</div>
</div>
</div>
@ -143,6 +151,19 @@ const currentRecordList = ref<any>([])
const currentChatId = ref('new') // Id 'new'
const currentChatName = ref('新建对话')
function deleteLog(row: any) {
log.asyncDelChatClientLog(applicationDetail.value.id, row.id, left_loading).then(() => {
if (currentChatId.value === row.id) {
currentChatId.value = 'new'
currentChatName.value = '新建对话'
paginationConfig.value.current_page = 1
paginationConfig.value.total = 0
currentRecordList.value = []
}
getChatLog(applicationDetail.value.id)
})
}
function handleScroll(event: any) {
if (
currentChatId.value !== 'new' &&
@ -362,10 +383,6 @@ onMounted(() => {
}
}
.chat-width {
max-width: var(--app-chat-width, 860px);
margin: 0 auto;
}
.collapse {
display: none;
}