From 5a0444234f3024bc0bd42dd3c2e80c0dbc071d52 Mon Sep 17 00:00:00 2001 From: lq Date: Thu, 26 Jun 2025 10:09:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/views/chat.blade.php | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/resources/views/chat.blade.php b/resources/views/chat.blade.php index a3450a87..b2722599 100644 --- a/resources/views/chat.blade.php +++ b/resources/views/chat.blade.php @@ -673,20 +673,23 @@ }) .then(response => { console.log('请求成功:', response.data); - // 添加消息到UI(自己的消息) - addMessage({ - userId: currentUser.id, - name: currentUser.name, - avatarColor: currentUser.avatarColor, - text: text, - timestamp: new Date(), - type: 'sent' - }); - // 清空输入框 - messageInput.value = ''; + let res = response.data; + if (res.code === 200) { + // 添加消息到UI(自己的消息) + addMessage({ + userId: currentUser.id, + name: currentUser.name, + avatarColor: currentUser.avatarColor, + text: text, + timestamp: new Date(), + type: 'sent' + }); + // 清空输入框 + messageInput.value = ''; - // 重新聚焦输入框 - messageInput.focus(); + // 重新聚焦输入框 + messageInput.focus(); + } }) .catch(error => { console.error('请求出错:', error);