【解决todo】AI 对话增加加载中。

This commit is contained in:
cherishsince 2024-05-21 14:24:21 +08:00
parent 8b0d598d8a
commit 6a03b7637e

View File

@ -24,7 +24,10 @@
<!-- 左中间对话列表 -->
<div class="conversation-list">
<!-- TODO @fain置顶聊天记录一星期钱30天前前端对数据重新做一下分组或者后端接口改一下 -->
<el-empty v-if="loading" description="." :v-loading="loading" />
<!-- TODO done @fain置顶聊天记录一星期钱30天前前端对数据重新做一下分组或者后端接口改一下 -->
<div v-for="conversationKey in Object.keys(conversationMap)" :key="conversationKey">
<div class="conversation-item classify-title" v-if="conversationMap[conversationKey].length">
<el-text class="mx-1" size="small" tag="b">{{ conversationKey }}</el-text>
@ -102,6 +105,8 @@ const activeConversationId = ref<string | null>(null) // 选中的对话,默
const conversationList = ref([] as ChatConversationVO[]) //
const conversationMap = ref<any>({}) // ()
const drawer = ref<boolean>(false) //
const loading = ref<boolean>(false) //
const loadingTime = ref<any>() //
// props
const props = defineProps({
@ -147,25 +152,38 @@ const handleConversationClick = async (id: string) => {
* 对话 - 获取列表
*/
const getChatConversationList = async () => {
// 1
const res = await ChatConversationApi.getChatConversationMyList()
// 2
res.sort((a, b) => {
return b.createTime - a.createTime
})
conversationList.value = res
// 3
if (!activeId?.value) {
await handleConversationClick(res[0].id)
try {
// 0
loadingTime.value = setTimeout(() => {
loading.value = true
}, 50)
// 1
const res = await ChatConversationApi.getChatConversationMyList()
// 2
res.sort((a, b) => {
return b.createTime - a.createTime
})
conversationList.value = res
// 3
if (!activeId?.value) {
await handleConversationClick(res[0].id)
}
// 4
if (conversationList.value.length === 0) {
activeConversationId.value = null
conversationMap.value = {}
return
}
// 5(30)
conversationMap.value = await conversationTimeGroup(conversationList.value)
} finally {
//
if (loadingTime.value) {
clearTimeout(loadingTime.value)
}
//
loading.value = false
}
// 4
if (conversationList.value.length === 0) {
activeConversationId.value = null
conversationMap.value = {}
return
}
// 5(30)
conversationMap.value = await conversationTimeGroup(conversationList.value)
}
const conversationTimeGroup = async (list: ChatConversationVO[]) => {