From 2c816afbd2f4676c732b1453f11d6af30a90147f Mon Sep 17 00:00:00 2001 From: ChenZhaoYu <790348264@qq.com> Date: Sun, 12 Feb 2023 10:29:21 +0800 Subject: [PATCH] =?UTF-8?q?pref:=20=E5=8F=96=E6=B6=88=20`disabled`=20?= =?UTF-8?q?=E4=BB=A5=E4=BD=BF=20`input`=20=E7=84=A6=E7=82=B9=E8=BF=9E?= =?UTF-8?q?=E7=BB=AD=E8=BE=93=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/Chat/index.vue | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/views/Chat/index.vue b/src/views/Chat/index.vue index 03e9a55..3fed308 100644 --- a/src/views/Chat/index.vue +++ b/src/views/Chat/index.vue @@ -15,7 +15,7 @@ const scrollRef = ref() const ms = useMessage() -const value = ref('') +const prompt = ref('') const loading = ref(false) @@ -45,17 +45,19 @@ function handleEnter(event: KeyboardEvent) { } async function handleSubmit() { - if (!value.value) { + const message = prompt.value.trim() + + if (!message || !message.length) { ms.warning('Please enter a message') return } - addMessage(value.value, true) + addMessage(message, true) + prompt.value = '' try { loading.value = true - const { text } = await fetchChatAPI(value.value) - value.value = '' + const { text } = await fetchChatAPI(message) addMessage(text, false) } catch (error: any) { @@ -104,7 +106,7 @@ function addMessage(message: string, reversal = false) {