From ca4736fe6caab3bdeacaea0887c7c3a38cee8059 Mon Sep 17 00:00:00 2001 From: LiaoYijun Date: Fri, 21 Oct 2022 09:47:56 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/charts/Wechat_session.js | 38 ++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/src/charts/Wechat_session.js b/src/charts/Wechat_session.js index 8ea4e7f..6e9cf13 100644 --- a/src/charts/Wechat_session.js +++ b/src/charts/Wechat_session.js @@ -29,6 +29,32 @@ class Wechat_session extends Component { const {wechatStore} = this.context; wechatStore.fetchChatMsgList(wechatStore.selectedContact, page, pageSize); } + + renderMsgItem(chatMsg) { + if (chatMsg.msgtype === 'image') { + return ( + + } + title={chatMsg.from_name} + description={chatMsg.msgtime} + /> + {chatMsg.msgid} + + )} else { + return ( + + } + title={chatMsg.from_name} + description={chatMsg.msgtime} + /> + {chatMsg.content.text} + + ) + } + } + render() { const {wechatStore} = this.context; const userList = wechatStore.userList; @@ -71,6 +97,7 @@ class Wechat_session extends Component { )} /> + ( - - } - title={chatMsg.from_name} - description={chatMsg.msgtime} - /> - {chatMsg.content.text} - - )} + renderItem={(chatMsg) => this.renderMsgItem(chatMsg)} /> Date: Fri, 21 Oct 2022 11:20:21 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E8=81=8A=E5=A4=A9?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E5=A2=9E=E5=8A=A0=E6=96=87=E4=BB=B6=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/charts/Wechat_session.js | 44 +++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/src/charts/Wechat_session.js b/src/charts/Wechat_session.js index 6e9cf13..4c62d6e 100644 --- a/src/charts/Wechat_session.js +++ b/src/charts/Wechat_session.js @@ -31,26 +31,34 @@ class Wechat_session extends Component { } renderMsgItem(chatMsg) { - if (chatMsg.msgtype === 'image') { + return ( + + } + title={chatMsg.from_name} + description={chatMsg.msgtime} + /> + {this.renderMsgContent(chatMsg)} + + ) + } + + renderMsgContent(chatMsg) { + if (chatMsg.msgtype === 'file') { return ( - - } - title={chatMsg.from_name} - description={chatMsg.msgtime} - /> - {chatMsg.msgid} - - )} else { + {chatMsg.content.filename} + ) + } else if (chatMsg.msgtype === 'image') { return ( - - } - title={chatMsg.from_name} - description={chatMsg.msgtime} - /> - {chatMsg.content.text} - + {chatMsg.msgid} + ) + } else if (chatMsg.msgtype === 'text') { + return ( + <>{chatMsg.content.text} + ) + } else { + return ( + <>未知消息[{chatMsg.msgtype}] ) } } From e7001623072a63be9696668f3d18ec8a62ae3df2 Mon Sep 17 00:00:00 2001 From: LiaoYijun Date: Fri, 21 Oct 2022 11:43:04 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E4=BC=9A=E8=AF=9D?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20link=20=E7=B1=BB=E5=9E=8B=E5=A4=84?= =?UTF-8?q?=E7=90=86=20=E5=A2=9E=E5=8A=A0=E6=97=A5=E6=9C=9F=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E5=8C=96=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/charts/Wechat_session.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/charts/Wechat_session.js b/src/charts/Wechat_session.js index 4c62d6e..d158e14 100644 --- a/src/charts/Wechat_session.js +++ b/src/charts/Wechat_session.js @@ -31,12 +31,14 @@ class Wechat_session extends Component { } renderMsgItem(chatMsg) { + const msgDate = new Date(chatMsg.msgtime); + const msgDateText = msgDate.toLocaleDateString() + ' ' + msgDate.toLocaleTimeString(); return ( } title={chatMsg.from_name} - description={chatMsg.msgtime} + description={msgDateText} /> {this.renderMsgContent(chatMsg)} @@ -46,7 +48,7 @@ class Wechat_session extends Component { renderMsgContent(chatMsg) { if (chatMsg.msgtype === 'file') { return ( - {chatMsg.content.filename} + {chatMsg.content.filename} ) } else if (chatMsg.msgtype === 'image') { return ( @@ -56,6 +58,10 @@ class Wechat_session extends Component { return ( <>{chatMsg.content.text} ) + } else if (chatMsg.msgtype === 'link') { + return ( + {chatMsg.content.title} + ) } else { return ( <>未知消息[{chatMsg.msgtype}]