From 83d11f1f53cc51fd80591c56ead67493c4f2a998 Mon Sep 17 00:00:00 2001
From: rd <1344903914@qq.com>
Date: Fri, 29 Aug 2025 10:30:11 +0800
Subject: [PATCH] =?UTF-8?q?perf:=20=E8=BE=93=E5=85=A5=E7=A9=BA=E5=80=BC?=
=?UTF-8?q?=E4=B8=8D=E5=85=81=E8=AE=B8=E5=8F=91=E9=80=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../chat-view/components/sender-input/index.vue | 11 ++++++++---
src/components/xt-chat/chat-view/index.vue | 5 ++---
src/views/home/components/sender-input/index.vue | 11 ++++++++---
3 files changed, 18 insertions(+), 9 deletions(-)
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}