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