【解决todo】AI 对话前后,增加加载中页面

pull/453/head
cherishsince 2024-05-21 13:56:11 +08:00
parent 8ca3d26cbb
commit 8b0d598d8a
2 changed files with 34 additions and 4 deletions

View File

@ -0,0 +1,15 @@
<!-- message 加载页面 -->
<template>
<div class="message-loading" >
<el-skeleton animated />
</div>
</template>
<script setup lang="ts">
</script>
<style scoped lang="scss">
.message-loading {
padding: 30px 30px;
}
</style>

View File

@ -35,8 +35,9 @@
<el-main class="main-container" > <el-main class="main-container" >
<div > <div >
<div class="message-container" > <div class="message-container" >
<Message v-if="list.length > 0" ref="messageRef" :list="list" @on-delete-success="handlerMessageDelete" /> <MessageLoading v-if="listLoading" />
<ChatEmpty v-if="list.length === 0" @on-prompt="doSend"/> <Message v-if="!listLoading && list.length > 0" ref="messageRef" :list="list" @on-delete-success="handlerMessageDelete" />
<ChatEmpty v-if="!listLoading && list.length === 0" @on-prompt="doSend"/>
</div> </div>
</div> </div>
</el-main> </el-main>
@ -90,6 +91,7 @@
import Conversation from './Conversation.vue' import Conversation from './Conversation.vue'
import Message from './Message.vue' import Message from './Message.vue'
import ChatEmpty from './ChatEmpty.vue' import ChatEmpty from './ChatEmpty.vue'
import MessageLoading from './MessageLoading.vue'
import {ChatMessageApi, ChatMessageVO} from '@/api/ai/chat/message' import {ChatMessageApi, ChatMessageVO} from '@/api/ai/chat/message'
import {ChatConversationApi, ChatConversationVO} from '@/api/ai/chat/conversation' import {ChatConversationApi, ChatConversationVO} from '@/api/ai/chat/conversation'
import {useClipboard} from '@vueuse/core' import {useClipboard} from '@vueuse/core'
@ -112,6 +114,11 @@ const displayedText = ref('');
const textSpeed = ref<number>(50); // Typing speed in milliseconds const textSpeed = ref<number>(50); // Typing speed in milliseconds
const textRoleRunning = ref<boolean>(false); // Typing speed in milliseconds const textRoleRunning = ref<boolean>(false); // Typing speed in milliseconds
// chat message
const list = ref<ChatMessageVO[]>([]) //
const listLoading = ref<boolean>(false) //
const listLoadingTime = ref<any>() // time
// () // ()
const messageRef = ref() const messageRef = ref()
const isComposing = ref(false) // const isComposing = ref(false) //
@ -177,8 +184,6 @@ const textRoll = async () => {
} }
}; };
/** chat message 列表 */
const list = ref<ChatMessageVO[]>([]) //
// ============ ============== // ============ ==============
@ -354,6 +359,10 @@ const stopStream = async () => {
*/ */
const getMessageList = async () => { const getMessageList = async () => {
try { try {
// time
listLoadingTime.value = setTimeout(() => {
listLoading.value = true
}, 60)
if (activeConversationId.value === null) { if (activeConversationId.value === null) {
return return
} }
@ -365,6 +374,12 @@ const getMessageList = async () => {
scrollToBottom() scrollToBottom()
}) })
} finally { } finally {
// time
if (listLoadingTime.value) {
clearTimeout(listLoadingTime.value)
}
//
listLoading.value = false
} }
} }