From 8e23ba7789539086f718e5f4113e839c1067b7db Mon Sep 17 00:00:00 2001 From: Lei OT Date: Tue, 19 Mar 2024 15:16:55 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=88=A4=E6=96=AD=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E6=94=AF=E6=8C=81=20window.Notification?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit perf: 移动端 style: Emoji popover --- src/lib/msgUtils.js | 4 +++ src/views/AuthApp.jsx | 7 +++- .../Components/ConversationsList.jsx | 12 +++++-- .../Conversations/Components/Input/Emoji.jsx | 11 ++++-- .../Components/Input/Template.jsx | 35 +++++++++++-------- .../Components/MessagesWrapper.jsx | 2 +- src/views/Conversations/Conversations.css | 3 ++ 7 files changed, 54 insertions(+), 20 deletions(-) diff --git a/src/lib/msgUtils.js b/src/lib/msgUtils.js index ea6ae58..2718924 100644 --- a/src/lib/msgUtils.js +++ b/src/lib/msgUtils.js @@ -527,6 +527,10 @@ export const whatsappError = { * 系统弹窗通知 */ export const handleNotification = (title, _options) => { + if (!("Notification" in window)) { + alert("This browser does not support desktop notification"); + return false; + } var notification; const options = { requireInteraction: true, // 设置手动关闭 diff --git a/src/views/AuthApp.jsx b/src/views/AuthApp.jsx index 631d184..74fe21c 100644 --- a/src/views/AuthApp.jsx +++ b/src/views/AuthApp.jsx @@ -26,7 +26,12 @@ function AuthApp() { state.disconnectWebsocket, ]); useEffect(() => { - Notification.requestPermission(); + if (!("Notification" in window)) { + alert("This browser does not support desktop notification"); + return false; + } else { + Notification.requestPermission(); + } if (loginUser.userId > 0) { connectWebsocket(loginUser.userId); fetchInitialData(loginUser.userId); // userIdStr diff --git a/src/views/Conversations/Components/ConversationsList.jsx b/src/views/Conversations/Components/ConversationsList.jsx index 83c0736..0631632 100644 --- a/src/views/Conversations/Components/ConversationsList.jsx +++ b/src/views/Conversations/Components/ConversationsList.jsx @@ -18,8 +18,7 @@ const Conversations = ({ mobile }) => { const navigate = useNavigate(); const userId = useAuthStore((state) => state.loginUser.userId); const initialState = useConversationStore((state) => state.initialState); - const activeConversations = useConversationStore((state) => state.activeConversations); - const [currentConversation, setCurrentConversation, updateCurrentConversation] = useConversationStore((state) => [state.currentConversation, state.setCurrentConversation, state.updateCurrentConversation]); + const [currentConversation, setCurrentConversation] = useConversationStore((state) => [state.currentConversation, state.setCurrentConversation]); const conversationsList = useConversationStore((state) => state.conversationsList); const addToConversationList = useConversationStore((state) => state.addToConversationList); const delConversationitem = useConversationStore((state) => state.delConversationitem); @@ -27,6 +26,15 @@ const Conversations = ({ mobile }) => { const [tabSelectedConversation, setTabSelectedConversation] = useState({}); const [tabCnt, setTabCnt] = useState(-1); + useEffect(() => { + if (mobile !== undefined) { + setCurrentConversation({}); + } + + return () => {}; + }, []) + + const [dataSource, setDataSource] = useState(conversationsList); useEffect(() => { setDataSource(conversationsList); diff --git a/src/views/Conversations/Components/Input/Emoji.jsx b/src/views/Conversations/Components/Input/Emoji.jsx index a885db3..1797dbf 100644 --- a/src/views/Conversations/Components/Input/Emoji.jsx +++ b/src/views/Conversations/Components/Input/Emoji.jsx @@ -17,12 +17,19 @@ const InputTemplate = ({ mobile, disabled = false, inputEmoji }) => { overlayInnerStyle={{ padding: 0, borderRadius: '8px' }} forceRender={true} content={} - // title='😃' + title={ +
+
Emoji
+ +
+ } trigger='click' open={openPopup} onOpenChange={setOpenPopup}> diff --git a/src/views/Conversations/Components/Input/Template.jsx b/src/views/Conversations/Components/Input/Template.jsx index 8049cf8..18fc013 100644 --- a/src/views/Conversations/Components/Input/Template.jsx +++ b/src/views/Conversations/Components/Input/Template.jsx @@ -126,23 +126,26 @@ const InputTemplate = ({ mobile, disabled = false, invokeSendMessage }) => { return ( <> - { - setSearchContent(e.target.value); - handleSearchTemplates(e.target.value); - }} - placeholder='搜索名称' - /> +
+ { + setSearchContent(e.target.value); + handleSearchTemplates(e.target.value); + }} + placeholder='搜索名称' + /> + +
{ } description={ <> -
+
{renderForm({ tempItem: item })}
{item.components?.footer?.[0] ?
{item.components.footer[0].text || ''}
: null}
@@ -175,7 +178,11 @@ const InputTemplate = ({ mobile, disabled = false, invokeSendMessage }) => { /> } - title='🙋打招呼' + // title={ + //
+ //
🙋打招呼
+ // + //
} trigger='click' open={openTemplates} onOpenChange={setOpenTemplates}> diff --git a/src/views/Conversations/Components/MessagesWrapper.jsx b/src/views/Conversations/Components/MessagesWrapper.jsx index fc217e4..cc2157e 100644 --- a/src/views/Conversations/Components/MessagesWrapper.jsx +++ b/src/views/Conversations/Components/MessagesWrapper.jsx @@ -39,7 +39,7 @@ const MessagesWrapper = () => { updateCurrentConversation({ lasttime: thisLastTime, loadNextPage }); return () => {}; - }, [activeMessages, currentConversation.sn]); + }, [currentConversation.sn]); const getFirstPageMessages = async (item) => { diff --git a/src/views/Conversations/Conversations.css b/src/views/Conversations/Conversations.css index 6961c4b..9805296 100644 --- a/src/views/Conversations/Conversations.css +++ b/src/views/Conversations/Conversations.css @@ -178,6 +178,9 @@ .chatwindow-wrapper .rce-mbox .rce-mbox-reply { background-color: rgba(236, 236, 236, 0.7); } +.chatwindow-wrapper.epr-main.EmojiPickerReact{ + border: none; +} .chatwindow-wrapper .rce-mbox .epr-emoji-img, .chatwindow-wrapper .rce-mbox .epr-emoji-native {