From c30628681d5ff82606a2ec8aa910e5e35fd2f03c Mon Sep 17 00:00:00 2001 From: Lei OT Date: Thu, 7 Mar 2024 14:32:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B6=88=E6=81=AF=E7=B1=BB=E5=9E=8B:=20contact?= =?UTF-8?q?:=20=E5=A4=8D=E5=88=B6;=20location?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib/msgUtils.js | 15 +++++++- .../Conversations/Components/MessagesList.jsx | 35 ++++++------------- 2 files changed, 24 insertions(+), 26 deletions(-) diff --git a/src/lib/msgUtils.js b/src/lib/msgUtils.js index fdaaa5e..89c3ef1 100644 --- a/src/lib/msgUtils.js +++ b/src/lib/msgUtils.js @@ -363,7 +363,20 @@ export const whatsappMsgTypeMapped = { 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', + location: { + type: 'location', + data: (msg) => ({ + id: msg.wamid, + title: msg.location.name || '位置信息', + text: msg.location.address || '位置', + src: msg.location.url || 'https://cdn.pixabay.com/photo/2016/03/22/04/23/map-1272165_1280.png', + data: { + longitude: msg.location?.longitude, + latitude: msg.location?.latitude, + }, + originText: msg.location?.address || '', + }), + }, // contact: 'contact', // 'contact-card': 'contact-card', // 'contact-card-with-photo': 'contact-card-with-photo', diff --git a/src/views/Conversations/Components/MessagesList.jsx b/src/views/Conversations/Components/MessagesList.jsx index 18cecb2..5040359 100644 --- a/src/views/Conversations/Components/MessagesList.jsx +++ b/src/views/Conversations/Components/MessagesList.jsx @@ -6,8 +6,9 @@ import useConversationStore from '@/stores/ConversationStore'; import { useShallow } from 'zustand/react/shallow'; import { isEmpty, olog } from '@/utils/utils'; -const MessagesList = ({ reference, ...props }) => { +const MessagesList = ({ reference, contactsModalOpen, setContactsModalOpen, ...props }) => { const setReferenceMsg = useConversationStore(useShallow((state) => state.setReferenceMsg)); + olog('render message list'); const scrollToMessage = (id, index) => { const _i = index || props.dataSource.findIndex((msg) => msg.id === id); @@ -137,30 +138,14 @@ const MessagesList = ({ reference, ...props }) => { })} {...(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: () =>
复制
, - }, - ], + actionButtons: [ + { + onClickButton: () => { + navigator.clipboard.writeText(message.text); + }, + Component: () =>
复制
, + }, + ], } : {})} />