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

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

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

Loading…
Cancel
Save