feat: 删除多余的内容

This commit is contained in:
ChenZhaoYu
2023-02-09 15:18:30 +08:00
parent d796e10ec6
commit 93f4af22a2
15 changed files with 37 additions and 761 deletions

View File

@@ -25,7 +25,7 @@ defineProps<Props>()
{{ date }}
</span>
<div class="p-2 mt-2 rounded-md" :class="[user ? 'bg-[#d2f9d1]' : 'bg-[#f4f6f8]']">
<span class="leading-relaxed" :class="error ?? 'text-red-500'" v-html="message" />
<span class="leading-relaxed" :class="[{ 'text-red-500': error }]" v-html="message" />
</div>
</div>
</div>

View File

@@ -96,7 +96,12 @@ function addMessage(message: string, user = false, error = false) {
</main>
<footer class="p-4">
<div class="flex items-center justify-between space-x-2">
<NInput v-model:value="value" placeholder="Type a message" :disabled="loading" @keyup="handleEnter" />
<NInput
v-model:value="value"
placeholder="Type a message"
:disabled="loading"
@keyup="handleEnter"
/>
<NButton type="primary" :loading="loading" @click="handleSubmit">
<SvgIcon icon="ri:send-plane-fill" />
</NButton>

View File

@@ -1,12 +1,14 @@
import axios from 'axios'
async function fetchChatAPI(message: string) {
const url = `${import.meta.env.VITE_GLOB_API_URL}/chat`
if (!message || message.trim() === '')
return Promise.reject(new Error('Message is empty'))
try {
const { status, data } = await axios.post(
'http://192.168.110.170:3002/chat',
url,
{ message },
)