Bladeren bron

Merge remote-tracking branch 'origin/dev_suwenjiang' into dev_suwenjiang

suwenjiang 1 maand geleden
bovenliggende
commit
7d2fd289ed

+ 1 - 1
src/pages/chat/chat-message/index.vue

@@ -95,7 +95,7 @@ const handleSendStatus = () => {
     } else {
       sendStatus.value = 'success'
     }
-  }, 2 * 1000)
+  }, 10 * 1000)
 }
 
 onMounted(() => {

+ 1 - 1
src/pages/chat/chat-message/link-message/handle.js

@@ -1,5 +1,5 @@
 
-const IN_STATION_LINK = []// 站内链接
+const IN_STATION_LINK = ['xiaoyaotravel.com']// 站内链接
 export const findHyperlinks = (text) => {
   try {
     const urlPattern = /https?:\/\/[^\s]+/g;

+ 8 - 5
src/pages/chat/chat-message/link-message/index.vue

@@ -46,11 +46,14 @@ onMounted(() => {
         </NuxtLink>
       </template>
     </div>
-    <div
-      class="bg-[#F3F3F3] rounded-[25px] px-12 py-4 text-black-9 mt-4 text-sm w-max grid place-items-center"
-    >
-      转自 第三方链接
-    </div>
+    <template v-if="linkInfo">
+      <div v-if="linkInfo.isInStation"
+           class="bg-[#F3F3F3] rounded-[25px] px-12 py-4 text-black-9 mt-4 text-sm w-max grid place-items-center"
+      >
+        转自 第三方链接
+      </div>
+    </template>
+
   </div>
 </template>
 

+ 10 - 8
src/pages/chat/group-chat.vue

@@ -124,8 +124,7 @@ const getChatList = async (type = 'init') => {
     })
     pageNum.value = page;
     await handleResponse(res);
-    currConversationChatList.value = handleChatList(res.data?.data)
-    console.log(currConversationChatList.value, 'currConversationChatList')
+    currConversationChatList.value = chatsStore.handleMessageList(res.data?.data)
     if (type === 'init') await scrollToBottom()
   } catch (e) {
     console.error(e)
@@ -133,9 +132,6 @@ const getChatList = async (type = 'init') => {
 
   }
 }
-const handleChatList = (list = []) => {
-  return (list ?? []).filter(o => isValidJson(o.messageContent)).map(o => JSON.parse(o.messageContent));
-}
 
 // 发送文本消息
 const sendTextMessage = async (text) => {
@@ -271,11 +267,17 @@ onMounted(() => {
   initGroupId()
 
   XYWebSocket.SocketEventsBus.on(XYWebSocket.SocketEvents.chatEvent, async (chat) => {
+    console.log('订阅群聊消息', chat)
     const isCurrGroupId = chat.groupId && chat.groupId === groupId.value;
     const isOtherUserMessage = chat.sendUserId && chatsStore.isRealMessage(chat.sendUserId);
-    if (isCurrGroupId && isOtherUserMessage) {
-      currConversationChatList.value.push(chat)
-      await scrollToBottom()
+    if(isCurrGroupId) {
+      if (isOtherUserMessage) {
+        currConversationChatList.value.push(chat)
+        await scrollToBottom()
+      }
+      if(!isOtherUserMessage) {
+        await getChatList('init')
+      }
     }
   })
 })

+ 11 - 6
src/pages/chat/single-chat.vue

@@ -35,7 +35,7 @@
       <!--  <van-pull-refresh v-model="refreshing" @refresh="loadMore" class="flex-1">
             </van-pull-refresh>-->
       <div class="h-70 w-full bg-[#fff]"></div>
-      <div class="fixed bottom-0 left-0 right-0 w-full">
+      <div class="fixed bottom-0 left-0 right-0 w-full bg-[#fff]">
         <ChatInput :operates="['image']" @focus="scrollToBottom" @send="handleSendMessage"></ChatInput>
       </div>
     </template>
@@ -146,7 +146,6 @@ const sendTextMessage = async (text) => {
     currConversationChatList.value.push(msg)
     await scrollToBottom()
     await chatsStore.sendSocketMessage(msg)
-    await getChatList('init')
   } catch (e) {
     console.log(e, '2')
   } finally {
@@ -267,13 +266,19 @@ function getLocalId() {
 onMounted(() => {
   initGroupId()
   XYWebSocket.SocketEventsBus.on(XYWebSocket.SocketEvents.chatEvent, async (chat) => {
-    console.log(chat, '单聊页面消息订阅')
+    console.log('单聊页面消息订阅', chat)
     const isCurrGroupId = chat.groupId && chat.groupId === groupId.value;
     const isOtherUserMessage = chat.sendUserId && chatsStore.isRealMessage(chat.sendUserId)
-    if (isCurrGroupId && isOtherUserMessage) {
-      currConversationChatList.value.push(chat)
-      await scrollToBottom()
+    if(isCurrGroupId) {
+      if (isOtherUserMessage) {
+        currConversationChatList.value.push(chat)
+        await scrollToBottom()
+      }
+      if(!isOtherUserMessage) {
+        await getChatList('init')
+      }
     }
+
   })
 })
 

+ 0 - 1
src/stores/useChats.js

@@ -45,7 +45,6 @@ export const useChatsStore = defineStore('chats', () => {
   }
 
   const isRealMessage = (sendUserId) => {
-    console.log(userInfo.value.pass, 'userInfo.value.pass')
     return sendUserId !== userInfo.value.pass
   }
 

+ 1 - 3
src/utils/XYWebSocket.ts

@@ -44,11 +44,9 @@ export namespace XYWebSocket {
                 if (!e) return;
                 if (!e.data) return;
                 const messagePackage = JSON.parse(e.data) || {};
+                SocketEventsBus.emit(SocketEvents.chatEvent, messagePackage)
                 console.log('---------接收---------', messagePackage, '-----------消息包------');
                 const {web_request_id = null} = messagePackage.map || {};
-
-                SocketEventsBus.emit(SocketEvents.chatEvent, messagePackage)
-
                 // 处理自己本地发送的消息
                 if (web_request_id && this.eventPoll.has(web_request_id)) {
                     const eventItem = this.eventPoll.get(web_request_id)!;