diff --git a/Cunkebao/src/components/Upload/SimpleFileUpload/index.tsx b/Cunkebao/src/components/Upload/SimpleFileUpload/index.tsx index eda775ba..8ed346c4 100644 --- a/Cunkebao/src/components/Upload/SimpleFileUpload/index.tsx +++ b/Cunkebao/src/components/Upload/SimpleFileUpload/index.tsx @@ -50,7 +50,6 @@ const SimpleFileUpload: React.FC = ({ try { const fileUrl = await uploadFile(file); - console.log("上传成功,文件URL:", fileUrl); onFileUploaded?.(fileUrl); message.success("文件上传成功"); } catch (error: any) { diff --git a/Cunkebao/src/pages/pc/ckbox/weChat/components/ChatWindow/components/MessageEnter/index.tsx b/Cunkebao/src/pages/pc/ckbox/weChat/components/ChatWindow/components/MessageEnter/index.tsx index 35cb2678..750f0a7a 100644 --- a/Cunkebao/src/pages/pc/ckbox/weChat/components/ChatWindow/components/MessageEnter/index.tsx +++ b/Cunkebao/src/pages/pc/ckbox/weChat/components/ChatWindow/components/MessageEnter/index.tsx @@ -97,9 +97,58 @@ const MessageEnter: React.FC = ({ contract }) => { setInputValue(prevValue => prevValue + `[${emoji.name}]`); }; + // 根据文件格式判断消息类型 + const getMsgTypeByFileFormat = (filePath: string): number => { + const extension = filePath.toLowerCase().split(".").pop() || ""; + + // 图片格式 + const imageFormats = [ + "jpg", + "jpeg", + "png", + "gif", + "bmp", + "webp", + "svg", + "ico", + ]; + if (imageFormats.includes(extension)) { + return 3; // 图片 + } + + // 视频格式 + const videoFormats = [ + "mp4", + "avi", + "mov", + "wmv", + "flv", + "mkv", + "webm", + "3gp", + "rmvb", + ]; + if (videoFormats.includes(extension)) { + return 43; // 视频 + } + + // 其他格式默认为文件 + return 49; // 文件 + }; + const handleFileUploaded = (filePath: string) => { - console.log("文件上传成功,路径:", filePath); - // 这里可以根据需要处理文件路径,比如发送文件消息 + // msgType(1:文本 3:图片 43:视频 47:动图表情包(gif、其他表情包) 49:小程序/其他:图文、文件) + const msgType = getMsgTypeByFileFormat(filePath); + + const params = { + wechatAccountId: contract.wechatAccountId, + wechatChatroomId: contract?.chatroomId ? contract.id : 0, + wechatFriendId: contract?.chatroomId ? 0 : contract.id, + msgSubType: 0, + msgType, + content: filePath, + }; + sendCommand("CmdSendMessage", params); }; return (