From f947fa8d36442f3eabd070815c25e7518c4d6068 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Chuailei000=E2=80=9D?= <2280131253@qq.com> Date: Fri, 15 Dec 2023 11:00:47 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E6=96=B0=E5=BB=BA?= =?UTF-8?q?=E8=81=8A=E5=A4=A9=E4=B8=8D=E9=87=8D=E6=96=B0=E5=88=9B=E5=BB=BA?= =?UTF-8?q?socket?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Apps/ChatAi/components/ChitChat/ChatInput.vue | 1 - src/components/Apps/ChatAi/components/ChitChat/index.vue | 7 +++++++ src/components/Apps/ChatAi/index.vue | 2 +- src/components/Apps/ChatAi/useChat.js | 5 +++++ src/store/modules/chat.js | 5 ++++- 5 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/components/Apps/ChatAi/components/ChitChat/ChatInput.vue b/src/components/Apps/ChatAi/components/ChitChat/ChatInput.vue index 47098c816..97e58b8dc 100644 --- a/src/components/Apps/ChatAi/components/ChitChat/ChatInput.vue +++ b/src/components/Apps/ChatAi/components/ChitChat/ChatInput.vue @@ -80,7 +80,6 @@ export default { this.inputValue = '' }, onSelectChange(value) { - this.inputValue = value this.$emit('select-prompt', value) } } diff --git a/src/components/Apps/ChatAi/components/ChitChat/index.vue b/src/components/Apps/ChatAi/components/ChitChat/index.vue index bfceb60c5..51f928028 100644 --- a/src/components/Apps/ChatAi/components/ChitChat/index.vue +++ b/src/components/Apps/ChatAi/components/ChitChat/index.vue @@ -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( diff --git a/src/components/Apps/ChatAi/index.vue b/src/components/Apps/ChatAi/index.vue index a28b43964..d2addf3be 100644 --- a/src/components/Apps/ChatAi/index.vue +++ b/src/components/Apps/ChatAi/index.vue @@ -73,7 +73,7 @@ export default { onNewChat() { this.active = 'chat' this.$nextTick(() => { - this.$refs.component?.init() + this.$refs.component?.onNewChat() getInputFocus() }) } diff --git a/src/components/Apps/ChatAi/useChat.js b/src/components/Apps/ChatAi/useChat.js index a94e86213..269aa09d2 100644 --- a/src/components/Apps/ChatAi/useChat.js +++ b/src/components/Apps/ChatAi/useChat.js @@ -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, diff --git a/src/store/modules/chat.js b/src/store/modules/chat.js index b679c6825..f90062288 100644 --- a/src/store/modules/chat.js +++ b/src/store/modules/chat.js @@ -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