From bacffc94d91312fbd681c1576f49855471e4ef73 Mon Sep 17 00:00:00 2001 From: zhaoying Date: Tue, 10 Feb 2026 17:42:40 +0800 Subject: [PATCH] fix(web): FileUpload bugfix --- .../ApplicationConfig/components/Chat.tsx | 48 +++++++++---------- .../Conversation/components/FileUpload.tsx | 14 +----- web/src/views/Conversation/index.tsx | 6 +-- .../views/Workflow/components/Chat/Chat.tsx | 6 +-- 4 files changed, 26 insertions(+), 48 deletions(-) diff --git a/web/src/views/ApplicationConfig/components/Chat.tsx b/web/src/views/ApplicationConfig/components/Chat.tsx index effb34c3..794489c6 100644 --- a/web/src/views/ApplicationConfig/components/Chat.tsx +++ b/web/src/views/ApplicationConfig/components/Chat.tsx @@ -2,7 +2,7 @@ * @Author: ZhaoYing * @Date: 2026-02-03 16:27:39 * @Last Modified by: ZhaoYing - * @Last Modified time: 2026-02-10 12:18:23 + * @Last Modified time: 2026-02-10 17:40:15 */ /** * Chat debugging component for application testing @@ -366,10 +366,8 @@ const Chat: FC = ({ chatList, data, updateChatList, handleSave, sourc const handleMessageChange = (message: string) => { setMessage(message) } - const [update, setUpdate] = useState(false) const fileChange = (file?: any) => { setFileList([...fileList, file]) - setUpdate(prev => !prev) } // const handleRecordingComplete = async (file: any) => { // console.log('file', file) @@ -456,29 +454,27 @@ const Chat: FC = ({ chatList, data, updateChatList, handleSave, sourc onChange={handleMessageChange} > - - - ) - }, - ], - onClick: handleShowUpload - }} - > -
-
+ + + ) + }, + ], + onClick: handleShowUpload + }} + > +
+
{/* diff --git a/web/src/views/Conversation/components/FileUpload.tsx b/web/src/views/Conversation/components/FileUpload.tsx index b7d65f80..1e8d33aa 100644 --- a/web/src/views/Conversation/components/FileUpload.tsx +++ b/web/src/views/Conversation/components/FileUpload.tsx @@ -2,7 +2,7 @@ * @Author: ZhaoYing * @Date: 2026-02-06 21:09:42 * @Last Modified by: ZhaoYing - * @Last Modified time: 2026-02-09 16:41:31 + * @Last Modified time: 2026-02-10 17:40:08 */ /** * File Upload Component @@ -55,8 +55,6 @@ interface UploadFilesProps extends Omit { maxCount?: number; /** Custom file removal callback */ onRemove?: (file: UploadFile) => boolean | void | Promise; - /** Trigger to reset file list */ - update?: boolean; } // Mapping of file extensions to MIME types const ALL_FILE_TYPE: { @@ -109,7 +107,6 @@ const UploadFiles = forwardRef(({ isAutoUpload = true, maxCount = 1, onRemove: customOnRemove, - update, requestConfig, ...props }, ref) => { @@ -118,11 +115,6 @@ const UploadFiles = forwardRef(({ const [fileList, setFileList] = useState(propFileList); const [accept, setAccept] = useState(); - // Reset file list when update prop changes - useEffect(() => { - setFileList([]) - }, [update]) - /** * Validates file type and size before upload * @returns Upload.LIST_IGNORE to prevent upload, or true to proceed @@ -185,9 +177,7 @@ const UploadFiles = forwardRef(({ /** * Handles upload state changes */ - const handleChange: UploadProps['onChange'] = ({ fileList: newFileList, event }) => { - console.log('event', event) - setFileList(newFileList); + const handleChange: UploadProps['onChange'] = ({ fileList: newFileList }) => { if (onChange) { onChange(maxCount === 1 ? newFileList[0] : newFileList); } diff --git a/web/src/views/Conversation/index.tsx b/web/src/views/Conversation/index.tsx index fcc32bf8..825ea834 100644 --- a/web/src/views/Conversation/index.tsx +++ b/web/src/views/Conversation/index.tsx @@ -2,7 +2,7 @@ * @Author: ZhaoYing * @Date: 2026-02-03 16:58:03 * @Last Modified by: ZhaoYing - * @Last Modified time: 2026-02-09 20:20:01 + * @Last Modified time: 2026-02-10 17:41:05 */ /** * Conversation Page @@ -254,10 +254,8 @@ const Conversation: FC = () => { }) } - const [update, setUpdate] = useState(false) const fileChange = (file?: any) => { form.setFieldValue('files', [...(queryValues.files || []), file]) - setUpdate(prev => !prev) } // const handleRecordingComplete = async (file: any) => { // console.log('file', file) @@ -353,8 +351,6 @@ const Conversation: FC = () => { action={shareFileUploadUrlWithoutApiPrefix} fileType={['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'svg']} onChange={fileChange} - fileList={[]} - update={update} requestConfig={{ headers: { 'Content-Type': 'multipart/form-data', diff --git a/web/src/views/Workflow/components/Chat/Chat.tsx b/web/src/views/Workflow/components/Chat/Chat.tsx index 95f43a9c..00a0c7fb 100644 --- a/web/src/views/Workflow/components/Chat/Chat.tsx +++ b/web/src/views/Workflow/components/Chat/Chat.tsx @@ -2,7 +2,7 @@ * @Author: ZhaoYing * @Date: 2026-02-06 21:10:56 * @Last Modified by: ZhaoYing - * @Last Modified time: 2026-02-10 12:17:41 + * @Last Modified time: 2026-02-10 17:41:24 */ /** * Workflow Chat Component @@ -343,13 +343,11 @@ const Chat = forwardRef(({ appId const handleMessageChange = (message: string) => { setMessage(message) } - const [update, setUpdate] = useState(false) /** * Handles file upload from local device */ const fileChange = (file?: any) => { setFileList([...fileList, file]) - setUpdate(prev => !prev) } // const handleRecordingComplete = async (file: any) => { // console.log('file', file) @@ -517,8 +515,6 @@ const Chat = forwardRef(({ appId ) },