微信聊天记录增加文件类型处理

feature/2.0-sales-trade
LiaoYijun 3 years ago
parent 361fa6207f
commit b947a26881

@ -31,26 +31,34 @@ class Wechat_session extends Component {
} }
renderMsgItem(chatMsg) { renderMsgItem(chatMsg) {
if (chatMsg.msgtype === 'image') { return (
<List.Item className='ant-list-item-no-flex'>
<List.Item.Meta
avatar={<Avatar src={chatMsg.from_avatar} />}
title={chatMsg.from_name}
description={chatMsg.msgtime}
/>
{this.renderMsgContent(chatMsg)}
</List.Item>
)
}
renderMsgContent(chatMsg) {
if (chatMsg.msgtype === 'file') {
return ( return (
<List.Item className='ant-list-item-no-flex'> <a href={chatMsg.content.fileurl}>{chatMsg.content.filename}</a>
<List.Item.Meta )
avatar={<Avatar src={chatMsg.from_avatar} />} } else if (chatMsg.msgtype === 'image') {
title={chatMsg.from_name}
description={chatMsg.msgtime}
/>
<img style={{width: '50%', height: '50%'}} alt={chatMsg.msgid} src={chatMsg.content.imageurl} />
</List.Item>
)} else {
return ( return (
<List.Item> <img style={{width: '50%', height: '50%'}} alt={chatMsg.msgid} src={chatMsg.content.imageurl} />
<List.Item.Meta )
avatar={<Avatar src={chatMsg.from_avatar} />} } else if (chatMsg.msgtype === 'text') {
title={chatMsg.from_name} return (
description={chatMsg.msgtime} <>{chatMsg.content.text}</>
/> )
{chatMsg.content.text} } else {
</List.Item> return (
<>未知消息[{chatMsg.msgtype}]</>
) )
} }
} }

Loading…
Cancel
Save