diff --git a/client/web/src/components/AvatarPicker.tsx b/client/web/src/components/AvatarPicker.tsx index 81ed343b..3fb75183 100644 --- a/client/web/src/components/AvatarPicker.tsx +++ b/client/web/src/components/AvatarPicker.tsx @@ -30,6 +30,9 @@ export const AvatarPicker: React.FC = React.memo((props) => { const handleSelectFile = (e: React.ChangeEvent) => { if (e.target.files && e.target.files.length > 0) { const pickedFile = e.target.files[0]; + if (!pickedFile) { + return; + } if (isGIF(pickedFile)) { updateAvatar(URL.createObjectURL(pickedFile)); diff --git a/client/web/src/components/ChatBox/ChatInputBox/ChatDropArea.tsx b/client/web/src/components/ChatBox/ChatInputBox/ChatDropArea.tsx index 1fe1bfce..3060217e 100644 --- a/client/web/src/components/ChatBox/ChatInputBox/ChatDropArea.tsx +++ b/client/web/src/components/ChatBox/ChatInputBox/ChatDropArea.tsx @@ -12,6 +12,10 @@ export const ChatDropArea: React.FC = React.memo(() => { const handleDrop = useMemoizedFn((files: File[]) => { const file = files[0]; + if (!file) { + return; + } + if (file.type.startsWith('image/')) { // 发送图片 uploadMessageImage(file).then(({ url, width, height }) => {