mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 01:33:05 +00:00
feat: 历史对话增加删除
This commit is contained in:
parent
b2460303db
commit
98a42074eb
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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">
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue