From 7002f72cbf8410b5d08e9bfb2aff2f31617a3768 Mon Sep 17 00:00:00 2001 From: Lei OT Date: Wed, 6 Mar 2024 17:12:07 +0800 Subject: [PATCH] =?UTF-8?q?todo:=20=E8=81=94=E7=B3=BB=E4=BA=BA=E7=82=B9?= =?UTF-8?q?=E5=87=BB=E5=8F=91=E9=80=81=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib/msgUtils.js | 12 +++++++- .../Conversations/Components/MessagesList.jsx | 28 +++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/src/lib/msgUtils.js b/src/lib/msgUtils.js index c361500..fdaaa5e 100644 --- a/src/lib/msgUtils.js +++ b/src/lib/msgUtils.js @@ -334,7 +334,7 @@ export const whatsappMsgTypeMapped = { }), }, // unsupported: { type: 'system', data: (msg) => ({ text: 'Message type is currently not supported.' }) }, - unsupported: { type: 'text', data: (msg) => ({ text: '[暂不支持此消息类型]' }) }, + unsupported: { type: 'text', data: (msg) => ({ text: `[暂不支持此消息类型](${msg.id})` }) }, reaction: { type: 'text', data: (msg) => ({ id: msg.wamid, text: msg.reaction?.emoji || '' }), @@ -353,6 +353,16 @@ export const whatsappMsgTypeMapped = { message: msg.document?.caption || msg.document?.filename || '', }), }, + contacts: { + type: 'meetingLink', + data: (msg) => ({ + id: msg.wamid, + meetingID: msg.wamid, + title: msg.contacts.length === 1 ? `联系人` : `${msg.contacts.length} 位联系人`, + text: msg.contacts.map(ele => `${ele.name.formatted_name}: ${ele.phones[0].wa_id}`).join('\n'), + data: msg.contacts.map(ele => ({ id: ele.phones[0].wa_id, wa_id: ele.phones[0].wa_id, name: ele.name.formatted_name })), + }), + }, // location: 'location', // contact: 'contact', // 'contact-card': 'contact-card', diff --git a/src/views/Conversations/Components/MessagesList.jsx b/src/views/Conversations/Components/MessagesList.jsx index a70fb89..18cecb2 100644 --- a/src/views/Conversations/Components/MessagesList.jsx +++ b/src/views/Conversations/Components/MessagesList.jsx @@ -135,6 +135,34 @@ const MessagesList = ({ reference, ...props }) => { replyButton: ['text', 'document', 'image'].includes(message.whatsapp_msg_type) ? true : false, className: 'whitespace-pre-wrap', })} + {...(message.type === 'meetingLink' + ? { + actionButtons: + message.data.length === 1 + ? [ + { + onClickButton: () => { + alert(`发消息 ${message.text}`); + }, + Component: () =>
发消息
, + }, + ] + : [ + { + onClickButton: () => { + alert(`${message.text}`); + }, + Component: () =>
查看
, // 弹窗查看和发消息 + }, + { + onClickButton: () => { + navigator.clipboard.writeText(message.text); + }, + Component: () =>
复制
, + }, + ], + } + : {})} /> // ))}