mirror of
https://gitee.com/hhyykk/ipms-sjy-ui.git
synced 2025-02-08 14:44:58 +08:00
【解决todo】AI 对话增加加载中。
This commit is contained in:
parent
8b0d598d8a
commit
6a03b7637e
@ -24,7 +24,10 @@
|
|||||||
|
|
||||||
<!-- 左中间:对话列表 -->
|
<!-- 左中间:对话列表 -->
|
||||||
<div class="conversation-list">
|
<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 v-for="conversationKey in Object.keys(conversationMap)" :key="conversationKey">
|
||||||
<div class="conversation-item classify-title" v-if="conversationMap[conversationKey].length">
|
<div class="conversation-item classify-title" v-if="conversationMap[conversationKey].length">
|
||||||
<el-text class="mx-1" size="small" tag="b">{{ conversationKey }}</el-text>
|
<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 conversationList = ref([] as ChatConversationVO[]) // 对话列表
|
||||||
const conversationMap = ref<any>({}) // 对话分组 (置顶、今天、三天前、一星期前、一个月前)
|
const conversationMap = ref<any>({}) // 对话分组 (置顶、今天、三天前、一星期前、一个月前)
|
||||||
const drawer = ref<boolean>(false) // 角色仓库抽屉
|
const drawer = ref<boolean>(false) // 角色仓库抽屉
|
||||||
|
const loading = ref<boolean>(false) // 加载中
|
||||||
|
const loadingTime = ref<any>() // 加载中定时器
|
||||||
|
|
||||||
// 定义组件 props
|
// 定义组件 props
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
@ -147,25 +152,38 @@ const handleConversationClick = async (id: string) => {
|
|||||||
* 对话 - 获取列表
|
* 对话 - 获取列表
|
||||||
*/
|
*/
|
||||||
const getChatConversationList = async () => {
|
const getChatConversationList = async () => {
|
||||||
// 1、获取 对话数据
|
try {
|
||||||
const res = await ChatConversationApi.getChatConversationMyList()
|
// 0、加载中
|
||||||
// 2、排序
|
loadingTime.value = setTimeout(() => {
|
||||||
res.sort((a, b) => {
|
loading.value = true
|
||||||
return b.createTime - a.createTime
|
}, 50)
|
||||||
})
|
// 1、获取 对话数据
|
||||||
conversationList.value = res
|
const res = await ChatConversationApi.getChatConversationMyList()
|
||||||
// 3、默认选中
|
// 2、排序
|
||||||
if (!activeId?.value) {
|
res.sort((a, b) => {
|
||||||
await handleConversationClick(res[0].id)
|
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[]) => {
|
const conversationTimeGroup = async (list: ChatConversationVO[]) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user