diff --git a/src/components/xt-chat/chat-view/components/sender-input/index.vue b/src/components/xt-chat/chat-view/components/sender-input/index.vue index 35a4967..e587a43 100644 --- a/src/components/xt-chat/chat-view/components/sender-input/index.vue +++ b/src/components/xt-chat/chat-view/components/sender-input/index.vue @@ -30,7 +30,8 @@ export default { const senderRef = ref(null); const localSearchValue = ref(props.modelValue); - // 监听外部value变化 + const isEmptyValue = computed(() => !localSearchValue.value.trim()); + watch( () => props.modelValue, (newValue) => { @@ -39,6 +40,10 @@ export default { ); const handleSubmit = () => { + if (isEmptyValue.value) { + return; + } + emit('submit', localSearchValue.value); // localSearchValue.value = '' }; @@ -65,7 +70,7 @@ export default {
@@ -83,7 +88,7 @@ export default { emit('update:modelValue', value)} + onChange={(value: string) => emit('update:modelValue', value.trim())} onSubmit={handleSubmit} class="h-full w-full mb-24px" placeholder={props.placeholder} diff --git a/src/components/xt-chat/chat-view/index.vue b/src/components/xt-chat/chat-view/index.vue index 58558dd..b584aa3 100644 --- a/src/components/xt-chat/chat-view/index.vue +++ b/src/components/xt-chat/chat-view/index.vue @@ -42,7 +42,7 @@ export default { conversationList.value.push({ role: QUESTION_ROLE, content: message, - }); + }); initSse({ message }); }; @@ -84,7 +84,6 @@ export default { agent_id: chatStore.agentInfo.agent_id, }), }); - } catch (error) { console.error('Failed to initialize SSE:', error); antdMessage.error('初始化连接失败'); @@ -128,7 +127,7 @@ export default { role: QUESTION_ROLE, content: message, }); - + initSse(newVal); } }, diff --git a/src/views/home/components/sender-input/index.vue b/src/views/home/components/sender-input/index.vue index 251aca6..efb7216 100644 --- a/src/views/home/components/sender-input/index.vue +++ b/src/views/home/components/sender-input/index.vue @@ -30,15 +30,20 @@ export default { const senderRef = ref(null); const localSearchValue = ref(props.modelValue); - // 监听外部value变化 + const isEmptyValue = computed(() => !localSearchValue.value.trim()); + watch( () => props.modelValue, (newValue) => { + console.log(newValue); localSearchValue.value = newValue || ''; }, ); const handleSubmit = () => { + if (isEmptyValue.value) { + return; + } emit('submit', localSearchValue.value); }; const handleCancel = () => { @@ -64,7 +69,7 @@ export default {
@@ -81,7 +86,7 @@ export default { emit('update:modelValue', value)} + onChange={(value: string) => emit('update:modelValue', value.trim())} onSubmit={handleSubmit} class="h-full w-full mb-24px" placeholder={props.placeholder}