mirror of
https://github.com/Chanzhaoyu/chatgpt-web.git
synced 2025-07-21 03:44:21 +00:00
pref: 取消 disabled
以使 input
焦点连续输入
This commit is contained in:
@@ -15,7 +15,7 @@ const scrollRef = ref<HTMLDivElement>()
|
|||||||
|
|
||||||
const ms = useMessage()
|
const ms = useMessage()
|
||||||
|
|
||||||
const value = ref('')
|
const prompt = ref('')
|
||||||
|
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
|
|
||||||
@@ -45,17 +45,19 @@ function handleEnter(event: KeyboardEvent) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function handleSubmit() {
|
async function handleSubmit() {
|
||||||
if (!value.value) {
|
const message = prompt.value.trim()
|
||||||
|
|
||||||
|
if (!message || !message.length) {
|
||||||
ms.warning('Please enter a message')
|
ms.warning('Please enter a message')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
addMessage(value.value, true)
|
addMessage(message, true)
|
||||||
|
prompt.value = ''
|
||||||
|
|
||||||
try {
|
try {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
const { text } = await fetchChatAPI(value.value)
|
const { text } = await fetchChatAPI(message)
|
||||||
value.value = ''
|
|
||||||
addMessage(text, false)
|
addMessage(text, false)
|
||||||
}
|
}
|
||||||
catch (error: any) {
|
catch (error: any) {
|
||||||
@@ -104,7 +106,7 @@ function addMessage(message: string, reversal = false) {
|
|||||||
</main>
|
</main>
|
||||||
<footer class="p-4">
|
<footer class="p-4">
|
||||||
<div class="flex items-center justify-between space-x-2">
|
<div class="flex items-center justify-between space-x-2">
|
||||||
<NInput v-model:value="value" :disabled="loading" placeholder="Type a message..." @keypress="handleEnter" />
|
<NInput v-model:value="prompt" placeholder="Type a message..." @keypress="handleEnter" />
|
||||||
<NButton type="primary" :loading="loading" @click="handleSubmit">
|
<NButton type="primary" :loading="loading" @click="handleSubmit">
|
||||||
<template #icon>
|
<template #icon>
|
||||||
<Icon icon="ri:send-plane-fill" />
|
<Icon icon="ri:send-plane-fill" />
|
||||||
|
Reference in New Issue
Block a user