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