From 27fd4b3a1490beba343eca4f73d10de35c7fbfca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8C=97=E6=9E=B3?= <7854742+wang_rumeng@user.noreply.gitee.com> Date: Sun, 24 Aug 2025 17:03:20 +0800 Subject: [PATCH] =?UTF-8?q?chatbox=20=E4=BF=AE=E5=A4=8D=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E6=BB=9A=E5=8A=A8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/SmartChatBox/InputBar.tsx | 7 +++- components/SmartChatBox/LoadMoreButton.tsx | 2 +- components/SmartChatBox/useMessages.ts | 45 +++++++++++++--------- 3 files changed, 34 insertions(+), 20 deletions(-) diff --git a/components/SmartChatBox/InputBar.tsx b/components/SmartChatBox/InputBar.tsx index 40b358b..c95d197 100644 --- a/components/SmartChatBox/InputBar.tsx +++ b/components/SmartChatBox/InputBar.tsx @@ -44,14 +44,19 @@ export function InputBar({ onSend }: InputBarProps) { const onFileChange = async (e: React.ChangeEvent) => { const file = e.target.files?.[0]; + // 保存对 input 元素的引用 + const inputElement = e.currentTarget; + if (file) { if (!file.type.startsWith('image/')) { alert('请选择图片文件'); + inputElement.value = ""; // 重置 input return; } await handleFileUpload(file); + // 使用保存的引用重置 input + inputElement.value = ""; } - e.currentTarget.value = ""; // reset }; const removeImage = () => { diff --git a/components/SmartChatBox/LoadMoreButton.tsx b/components/SmartChatBox/LoadMoreButton.tsx index 45884b7..6e98e98 100644 --- a/components/SmartChatBox/LoadMoreButton.tsx +++ b/components/SmartChatBox/LoadMoreButton.tsx @@ -11,7 +11,7 @@ export function LoadMoreButton({ onClick, loading = false }: LoadMoreButtonProps