mirror of
https://github.com/jumpserver/lina.git
synced 2025-09-25 22:36:23 +00:00
perf: 优化新建聊天不重新创建socket
This commit is contained in:
@@ -80,7 +80,6 @@ export default {
|
||||
this.inputValue = ''
|
||||
},
|
||||
onSelectChange(value) {
|
||||
this.inputValue = value
|
||||
this.$emit('select-prompt', value)
|
||||
}
|
||||
}
|
||||
|
@@ -37,6 +37,7 @@ import { getInputFocus, useChat } from '../../useChat.js'
|
||||
|
||||
const {
|
||||
setLoading,
|
||||
clearChats,
|
||||
addChatMessageById,
|
||||
addMessageToActiveChat,
|
||||
newChatAndAddMessageById,
|
||||
@@ -179,6 +180,12 @@ export default {
|
||||
onSelectPromptHandle(value) {
|
||||
this.prompt = value
|
||||
this.currentConversationId = ''
|
||||
this.showIntroduction = false
|
||||
this.onSendHandle(value)
|
||||
},
|
||||
onNewChat() {
|
||||
clearChats()
|
||||
this.initChatMessage()
|
||||
},
|
||||
onStopHandle() {
|
||||
this.$axios.post(
|
||||
|
@@ -73,7 +73,7 @@ export default {
|
||||
onNewChat() {
|
||||
this.active = 'chat'
|
||||
this.$nextTick(() => {
|
||||
this.$refs.component?.init()
|
||||
this.$refs.component?.onNewChat()
|
||||
getInputFocus()
|
||||
})
|
||||
}
|
||||
|
@@ -23,6 +23,10 @@ export function useChat() {
|
||||
store.commit('chat/addChatToStore', data)
|
||||
}
|
||||
|
||||
const clearChats = () => {
|
||||
store.commit('chat/clearChats')
|
||||
}
|
||||
|
||||
const addMessageToActiveChat = (chat) => {
|
||||
store.commit('chat/addMessageToActiveChat', chat)
|
||||
}
|
||||
@@ -69,6 +73,7 @@ export function useChat() {
|
||||
chatStore,
|
||||
setLoading,
|
||||
onNewChat,
|
||||
clearChats,
|
||||
getInputFocus,
|
||||
addMessageToActiveChat,
|
||||
newChatAndAddMessageById,
|
||||
|
@@ -1,7 +1,6 @@
|
||||
|
||||
const state = {
|
||||
loading: false,
|
||||
tabNum: 0,
|
||||
activeTab: 0,
|
||||
chatsStore: [],
|
||||
activeChat: {}
|
||||
@@ -24,6 +23,10 @@ const mutations = {
|
||||
state.activeChat.chats?.push(chat)
|
||||
},
|
||||
|
||||
clearChats(state) {
|
||||
state.activeChat.chats = []
|
||||
},
|
||||
|
||||
removeLoadingMessageInChat(state) {
|
||||
const { chats } = state.activeChat
|
||||
const length = chats?.length
|
||||
|
Reference in New Issue
Block a user