mirror of
https://github.com/jumpserver/lina.git
synced 2026-01-25 22:44:13 +00:00
perf: 优化智能问答返回显示系统消息
This commit is contained in:
@@ -42,7 +42,6 @@ const {
|
||||
addMessageToActiveChat,
|
||||
newChatAndAddMessageById,
|
||||
removeLoadingMessageInChat,
|
||||
removeLoadingAndAddMessageToChat,
|
||||
updateChaMessageContentById,
|
||||
addTemporaryLoadingToChat
|
||||
} = useChat()
|
||||
@@ -120,12 +119,11 @@ export default {
|
||||
}
|
||||
},
|
||||
onChatMessage(data) {
|
||||
if (!data.message.content && data.conversation_id) {
|
||||
if (data.conversation_id) {
|
||||
setLoading(true)
|
||||
removeLoadingAndAddMessageToChat(data)
|
||||
removeLoadingMessageInChat()
|
||||
this.currentConversationId = data.conversation_id
|
||||
} else {
|
||||
updateChaMessageContentById(data.message.id, data.message.content)
|
||||
updateChaMessageContentById(data.message.id, data)
|
||||
}
|
||||
if (data.message?.type === 'finish') {
|
||||
setLoading(false)
|
||||
|
||||
@@ -59,13 +59,8 @@ export function useChat() {
|
||||
addChatMessageById(chat)
|
||||
}
|
||||
|
||||
const removeLoadingAndAddMessageToChat = (chat) => {
|
||||
store.commit('chat/removeLoadingMessageInChat')
|
||||
store.commit('chat/addMessageToActiveChat', chat)
|
||||
}
|
||||
|
||||
const updateChaMessageContentById = (id, content) => {
|
||||
store.commit('chat/updateChaMessageContentById', { id, content })
|
||||
const updateChaMessageContentById = (id, data) => {
|
||||
store.commit('chat/updateChaMessageContentById', { id, data })
|
||||
pageScroll('scrollRef')
|
||||
}
|
||||
|
||||
@@ -78,7 +73,6 @@ export function useChat() {
|
||||
addMessageToActiveChat,
|
||||
newChatAndAddMessageById,
|
||||
removeLoadingMessageInChat,
|
||||
removeLoadingAndAddMessageToChat,
|
||||
addChatMessageById,
|
||||
addTemporaryLoadingToChat,
|
||||
updateChaMessageContentById
|
||||
|
||||
@@ -38,10 +38,14 @@ const mutations = {
|
||||
}
|
||||
},
|
||||
|
||||
updateChaMessageContentById(state, { id, content }) {
|
||||
updateChaMessageContentById(state, { id, data }) {
|
||||
const chats = state.activeChat.chats || []
|
||||
const filterChat = chats.filter((chat) => chat.message.id === id)?.[0] || {}
|
||||
filterChat.message.content = content
|
||||
if (Object.keys(filterChat).length > 0) {
|
||||
filterChat.message.content = data.message.content
|
||||
} else {
|
||||
chats?.push(data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user