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

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

@ -31,7 +31,6 @@ class Wechat_session extends Component {
} }
renderMsgItem(chatMsg) { renderMsgItem(chatMsg) {
if (chatMsg.msgtype === 'image') {
return ( return (
<List.Item className='ant-list-item-no-flex'> <List.Item className='ant-list-item-no-flex'>
<List.Item.Meta <List.Item.Meta
@ -39,18 +38,27 @@ class Wechat_session extends Component {
title={chatMsg.from_name} title={chatMsg.from_name}
description={chatMsg.msgtime} description={chatMsg.msgtime}
/> />
<img style={{width: '50%', height: '50%'}} alt={chatMsg.msgid} src={chatMsg.content.imageurl} /> {this.renderMsgContent(chatMsg)}
</List.Item> </List.Item>
)} else { )
}
renderMsgContent(chatMsg) {
if (chatMsg.msgtype === 'file') {
return ( return (
<List.Item> <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} return (
description={chatMsg.msgtime} <img style={{width: '50%', height: '50%'}} alt={chatMsg.msgid} src={chatMsg.content.imageurl} />
/> )
{chatMsg.content.text} } else if (chatMsg.msgtype === 'text') {
</List.Item> return (
<>{chatMsg.content.text}</>
)
} else {
return (
<>未知消息[{chatMsg.msgtype}]</>
) )
} }
} }

Loading…
Cancel
Save