diff --git a/src/charts/WhatsApp_session.js b/src/charts/WhatsApp_session.js
index e24d5ea..26dd969 100644
--- a/src/charts/WhatsApp_session.js
+++ b/src/charts/WhatsApp_session.js
@@ -29,6 +29,45 @@ class WhatsApp_session extends Component {
const {whatsAppStore} = this.context;
whatsAppStore.fetchChatMsgList(whatsAppStore.selectedContact, page, pageSize);
}
+
+ renderMsgItem(chatMsg) {
+ const msgDate = new Date(chatMsg.msgtime);
+ const msgDateText = msgDate.toLocaleDateString() + ' ' + msgDate.toLocaleTimeString();
+ return (
+
+ }
+ title={chatMsg.from_name}
+ description={msgDateText}
+ />
+ {this.renderMsgContent(chatMsg)}
+
+ )
+ }
+
+ renderMsgContent(chatMsg) {
+ if (chatMsg.msgtype === 'file') {
+ return (
+ {chatMsg.content.filename}
+ )
+ } else if (chatMsg.msgtype === 'image') {
+ return (
+
+ )
+ } else if (chatMsg.msgtype === 'text') {
+ return (
+ <>{chatMsg.content.text}>
+ )
+ } else if (chatMsg.msgtype === 'link') {
+ return (
+ {chatMsg.content.title}
+ )
+ } else {
+ return (
+ <>未知消息[{chatMsg.msgtype}]>
+ )
+ }
+ }
render() {
const {whatsAppStore} = this.context;
const userList = whatsAppStore.userList;
@@ -78,16 +117,7 @@ class WhatsApp_session extends Component {
bordered={true}
itemLayout="horizontal"
dataSource={chatMsgList}
- renderItem={(chatMsg) => (
-
- }
- title={chatMsg.from_name}
- description={chatMsg.msgtime}
- />
- {chatMsg.content.text}
-
- )}
+ renderItem={(chatMsg) => this.renderMsgItem(chatMsg)}
/>