wkw 1 kuukausi sitten
vanhempi
sitoutus
b2e13c21b1

+ 0 - 2
src/router/router.guards.js

@@ -21,8 +21,6 @@ export function createRouterGuards(router) {
   const walletStore = useWalletStore();
   // 路由拦截
   router.beforeEach(async (to, from, next) => {
-
-
     if (import.meta.env.VITE_DAPP_BUILD == "1") {
       if (mainPath.includes(from.path) && paths.includes(to.path) && to.path != '/login') {
         // 停止跳转

+ 110 - 99
src/stores/modules/webSocketStore.js

@@ -591,8 +591,9 @@ export const useWebSocketStore = defineStore("webSocketStore", {
       let index = systemStore.ImsessionList.findIndex(val=> val.uuid == sessionId);
       // 已读未读
       let unReadNum = 0;
-      const ts = message.timestamp || Math.floor(Date.now() / 1000);
-      const time = new Date(ts).toISOString().replace("T", " ").split(".")[0];
+      const ts = message.timestamp || Math.floor(Date.now());
+
+      const time = new Date(ts).toLocaleString().replaceAll("/", "-");
       // 消息类型映射
       const mapSet = {
         [MsgType.MSG_TYPE.FILE]: '[文件]',
@@ -607,7 +608,8 @@ export const useWebSocketStore = defineStore("webSocketStore", {
         // [Constant.REJECT_VIDEO_ONLINE]: '[对方拒绝]',
       };
       // 检测最新消息
-      let lastMsg = message.contentType === MsgType.MSG_TYPE.TEXT || message.contentType === MsgType.MSG_TYPE.NOTICE ? (msg?msg.content : message.content) : (mapSet[message.contentType] || '[语音视频]');
+      // let lastMsg = message.contentType === MsgType.MSG_TYPE.TEXT || message.contentType === MsgType.MSG_TYPE.NOTICE ? (msg?msg.content : message.content) : (mapSet[message.contentType] || '[语音视频]');
+      let lastMsg = msg ? msg.content : message.content;
       // 阅后即焚消息
       if(message.isTemp){
         lastMsg = '[阅后即焚]';
@@ -617,7 +619,7 @@ export const useWebSocketStore = defineStore("webSocketStore", {
 
       // 修改群公告信息
       if (message.nickname) {
-        ext.nickname = message.nickname
+        ext.sessionName = message.nickname
       }
       if (message.notice) {
         ext.notice = message.notice
@@ -628,12 +630,12 @@ export const useWebSocketStore = defineStore("webSocketStore", {
       if (message.stick || message.stick === 0) {
         ext.stick = message.stick
       }
-
       // 更新
       if(index >= 0){
         systemStore.ImsessionList = systemStore.ImsessionList.map((item, i)=>{
-          if(i == index){
-            return { ...item, ...ext, unReadNum: item.unReadNum + 1, message: lastMsg, lastTime: time};
+          if (item.uuid == sessionId){
+            console.log('111', item, lastMsg, lastMsg,item.message)
+            return { ...item, ...ext, unReadNum: item.unReadNum + 1, message: lastMsg || item.message, updatedAt: time};
           }
           return item;
         })
@@ -661,97 +663,96 @@ export const useWebSocketStore = defineStore("webSocketStore", {
     },
 
     // 更新缓存里面的会话列表  type:0 发送者   1:接收者
-    updateSessionList(payload,type = 0,msg) {
-      const walletStore = useWalletStore();
-      const message = {...payload};
-      console.log('缓存中的列表数据', message, msg)
-      const systemStore = useSystemStore();
-      const selfUuid = useWalletStore().account; // 当前用户ID
-      let sessions = systemStore.ImsessionList ? [...systemStore.ImsessionList] : [];
-      const mapSet = {
-        [MsgType.MSG_TYPE.FILE]: '[文件]',
-        [MsgType.MSG_TYPE.IMAGE]: '[图片]',
-        [MsgType.MSG_TYPE.AUDIO]: '[音频]',
-        [MsgType.MSG_TYPE.VIDEO]: '[视频]',
-        [MsgType.MSG_TYPE.AUDIO_ONLINE]: '[语音通话]',
-        [MsgType.MSG_TYPE.VIDEO_ONLINE]: '[视频通话]',
-        // [Constant.CANCELL_AUDIO_ONLINE]:'[通话结束]',
-        // [Constant.REJECT_AUDIO_ONLINE]: '[对方拒绝]',
-        // [Constant.CANCELL_VIDEO_ONLINE]: '[通话结束]',
-        // [Constant.REJECT_VIDEO_ONLINE]: '[对方拒绝]',
-
-      };
-      // console.log(sessions, sessions.length)
-      let lastMsg = message.contentType === MsgType.MSG_TYPE.TEXT || message.contentType === MsgType.MSG_TYPE.NOTICE ? (msg?msg.content : message.content) : (mapSet[message.contentType] || '[语音视频]');
-      if ([MsgType.MESSAGE_REVOKE, MsgType.MESSAGE_REVOKE_GROUP].includes(message.messageType)){
-        console.log(211111)
-        lastMsg = `${message.from == walletStore.account ? '你' : (message.fromUsername || '对方')}撤回了一条消息`
-      }
-
-      let index = -1;
-      let uuid = type == 0 ? message.to : message.from;
-      index = sessions.findIndex(s => (s.uuid || s.id) === uuid);
-      if (message.messageType === 2 && type == 0 && index < 0){
-        systemStore.needRefreshIm = true;
-        return;
-      }
-      // 过滤无效的消息体
-      if (!uuid) {
-        return;
-      }
-      // if (message.messageType === 2) {
-      //   // 群聊
-      //   index = sessions.findIndex(s => (s.uuid || s.id) === message.to);
-      // } else {
-        // 单聊
-        // if (message.from === selfUuid) {
-        //   index = sessions.findIndex(s => (s.uuid || s.id) === message.to);
-        // } else {
-        //   index = sessions.findIndex(s => (s.uuid || s.id) === message.from);
-        // }
-      // }
-      let unReadNum = 0;
-      const ts = message.timestamp || Math.floor(Date.now() / 1000);
-      const time = new Date(ts).toISOString().replace("T", " ").split(".")[0];
-      if (index > -1) {
-        // 如果退群和踢人需要将用户头像移除
-        // let avatar = sessions[index].avatar;
-        // if (message.messageType == MsgType.EXIT_GROUP || message.messageType == MsgType.REMOVE_GROUP){
-        //   avatar = avatar.filter(val=>{
-        //     return !message.avatar.includes(val);
-        //   })
-        // }
-        unReadNum = sessions[index].unReadNum + 1;
-        // 更新已有会话
-        const updated = {
-          ...sessions[index],
-          message: lastMsg,
-          updatedAt: time,
-          unReadNum: type == 0 ? 0 : unReadNum
-          // avatar
-        };
-        sessions.splice(index, 1);
-        sessions.unshift(updated);
-      } else {
-        const isSelfSend = message.from === selfUuid;
-        const newSession = {
-          // uuid: message.messageType === 2 ? message.to : (isSelfSend ? message.to : message.from),
-          uuid,
-          name: message.toUsername || message.fromUsername || message.to || message.from,
-          type: message.messageType == 2?'group':'user',
-          message: lastMsg,
-          updatedAt: time,
-          avatar: message.avatar || '',
-          unReadNum: type == 0 ? 0 : unReadNum
-        };
-        sessions.unshift(newSession);
-      }
-      systemStore.ImsessionList = [...sessions];
-      // if(type != 0){
-      //   this.needRefreshIm +=1;
-      // }
-      this.needRefreshIm += 1;
-    },
+    // updateSessionList(payload,type = 0,msg) {
+    //   const walletStore = useWalletStore();
+    //   const message = {...payload};
+    //   console.log('缓存中的列表数据', message, msg)
+    //   const systemStore = useSystemStore();
+    //   const selfUuid = useWalletStore().account; // 当前用户ID
+    //   let sessions = systemStore.ImsessionList ? [...systemStore.ImsessionList] : [];
+    //   const mapSet = {
+    //     [MsgType.MSG_TYPE.FILE]: '[文件]',
+    //     [MsgType.MSG_TYPE.IMAGE]: '[图片]',
+    //     [MsgType.MSG_TYPE.AUDIO]: '[音频]',
+    //     [MsgType.MSG_TYPE.VIDEO]: '[视频]',
+    //     [MsgType.MSG_TYPE.AUDIO_ONLINE]: '[语音通话]',
+    //     [MsgType.MSG_TYPE.VIDEO_ONLINE]: '[视频通话]',
+    //     // [Constant.CANCELL_AUDIO_ONLINE]:'[通话结束]',
+    //     // [Constant.REJECT_AUDIO_ONLINE]: '[对方拒绝]',
+    //     // [Constant.CANCELL_VIDEO_ONLINE]: '[通话结束]',
+    //     // [Constant.REJECT_VIDEO_ONLINE]: '[对方拒绝]',
+
+    //   };
+    //   // console.log(sessions, sessions.length)
+    //   let lastMsg = message.contentType === MsgType.MSG_TYPE.TEXT || message.contentType === MsgType.MSG_TYPE.NOTICE ? (msg?msg.content : message.content) : (mapSet[message.contentType] || '[语音视频]');
+    //   if ([MsgType.MESSAGE_REVOKE, MsgType.MESSAGE_REVOKE_GROUP].includes(message.messageType)){
+    //     lastMsg = `${message.from == walletStore.account ? '你' : (message.fromUsername || '对方')}撤回了一条消息`
+    //   }
+
+    //   let index = -1;
+    //   let uuid = type == 0 ? message.to : message.from;
+    //   index = sessions.findIndex(s => (s.uuid || s.id) === uuid);
+    //   if (message.messageType === 2 && type == 0 && index < 0){
+    //     systemStore.needRefreshIm = true;
+    //     return;
+    //   }
+    //   // 过滤无效的消息体
+    //   if (!uuid) {
+    //     return;
+    //   }
+    //   // if (message.messageType === 2) {
+    //   //   // 群聊
+    //   //   index = sessions.findIndex(s => (s.uuid || s.id) === message.to);
+    //   // } else {
+    //     // 单聊
+    //     // if (message.from === selfUuid) {
+    //     //   index = sessions.findIndex(s => (s.uuid || s.id) === message.to);
+    //     // } else {
+    //     //   index = sessions.findIndex(s => (s.uuid || s.id) === message.from);
+    //     // }
+    //   // }
+    //   let unReadNum = 0;
+    //   const ts = message.timestamp || Math.floor(Date.now() / 1000);
+    //   const time = new Date(ts).toISOString().replace("T", " ").split(".")[0];
+    //   if (index > -1) {
+    //     // 如果退群和踢人需要将用户头像移除
+    //     // let avatar = sessions[index].avatar;
+    //     // if (message.messageType == MsgType.EXIT_GROUP || message.messageType == MsgType.REMOVE_GROUP){
+    //     //   avatar = avatar.filter(val=>{
+    //     //     return !message.avatar.includes(val);
+    //     //   })
+    //     // }
+    //     unReadNum = sessions[index].unReadNum + 1;
+    //     // 更新已有会话
+    //     const updated = {
+    //       ...sessions[index],
+    //       message: lastMsg,
+    //       updatedAt: time,
+    //       unReadNum: type == 0 ? 0 : unReadNum
+    //       // avatar
+    //     };
+    //     sessions.splice(index, 1);
+    //     sessions.unshift(updated);
+    //   } else {
+    //     const isSelfSend = message.from === selfUuid;
+    //     const newSession = {
+    //       // uuid: message.messageType === 2 ? message.to : (isSelfSend ? message.to : message.from),
+    //       uuid,
+    //       name: message.toUsername || message.fromUsername || message.to || message.from,
+    //       type: message.messageType == 2?'group':'user',
+    //       message: lastMsg,
+    //       updatedAt: time,
+    //       avatar: message.avatar || '',
+    //       unReadNum: type == 0 ? 0 : unReadNum
+    //     };
+    //     sessions.unshift(newSession);
+    //   }
+    //   systemStore.ImsessionList = [...sessions];
+    //   // if(type != 0){
+    //   //   this.needRefreshIm +=1;
+    //   // }
+    //   this.needRefreshIm += 1;
+    // },
 
 
     // ************ 接收方 方法 ************//
@@ -808,7 +809,17 @@ export const useWebSocketStore = defineStore("webSocketStore", {
       // 处理群置顶
       if (message.messageType === MsgType.MESSAGE_STICKY_GROUP) {
       }
-      
+      if (message.messageType != MsgType.DELETE_GROUP){
+        // 更新群成员列表
+        this.fetchGroupMembers(true);
+      }
+      // 处理@群成员
+      if (message.messageType == MsgType.MESSAGE_CC_GROUP){
+        let ccArr = msg?.cc.split(',');
+        if (this.groupMembersList && this.groupMembersList[message.from]) {
+          this.isassign = this.groupMembersList[message.from].filter(val => ccArr.includes(val.userId + '')).find(val => val.uuid == message.to)
+        }
+      } 
     },
 
     // 语音视频通知

+ 10 - 5
src/views/im/chat/index.vue

@@ -7,7 +7,7 @@
     <!-- 顶部导航 -->
     <div class="header-chat">
       <svg-icon class="page-icon" name="lf-arrow" @click="goBack" />
-      <div class="header-title" v-if="wsStore.toUserInfo.type == 'group'">{{ wsStore.toUserInfo.nickname || '群聊' }}({{ groupMembersArr.length }})</div>
+      <div class="header-title" v-if="wsStore.toUserInfo.type == 'group'">{{ wsStore.toUserInfo.sessionName || '群聊' }}({{ groupMembersArr.length }})</div>
       <div v-else class="header-title">{{ wsStore.toUserInfo.nickname }}</div>
       <svg-icon class="page-icon" name="more" @click="goDetail" />
     </div>
@@ -332,14 +332,14 @@ const atList = ref();
 const showBurn = ref(false)  // 阅后即焚是否开启
 const showNotice = ref(false);
 const noticeRead = ref(false);
-const groupMembersArr = ref([]);
+// const groupMembersArr = ref([]);
 
 const currentMsg = ref('');
 const showActionSheet = ref(false)
 const actions = ref([])
 
 const formatAvatarUrl = (item) => {
-  const url = item?.sender?.avatar || item?.avatar || ''
+  const url = item?.sender?.avatar || item?.fromAvatar || ''
   if (/^https?:\/\//.test(url)) {
     return url
   }
@@ -755,7 +755,7 @@ const sendMessage = () => {
   // 检测消息@成员
   let cc = [];
   if(ccMsg.value.length>0 && wsStore.toUserInfo.type != 'user'){
-    const matchs = text.value.match(/(@([^ ]+) )/ig);
+    const matchs = text.value.match(/(@([^ ]+) )/ig) || [];
     cc = ccMsg.value.filter(val=> matchs.includes(`@${val.nickname} `)).map(val=>val.userId);
     // 检测@所有人
     if(matchs.includes(`@所有人 `)){
@@ -858,11 +858,16 @@ const formatTime = (timestamp) => {
   const m = date.getMinutes().toString().padStart(2, "0");
   return `${h}:${m}`;
 };
+const groupMembersArr = computed(() => wsStore.groupMembersList[wsStore.toUserInfo.uuid] || []);
 
 // 页面生命周期
 onMounted(async () => {
   wsStore.toUserInfo.uuid = route.query.uuid;
-  groupMembersArr.value = await wsStore.fetchGroupMembers();
+  if (!wsStore.groupMembersList[wsStore.toUserInfo.uuid]) {
+    // 没有缓存,发请求
+    wsStore.groupMembersList[wsStore.toUserInfo.uuid] = await wsStore.fetchGroupMembers(true);
+  }
+  // groupMembersArr.value = wsStore.groupMembersList[wsStore.toUserInfo.uuid];
   await wsStore.getMessages({
     uuid: wsStore.toUserInfo.type == 'user'?walletStore.account : route.query.uuid,
     messageType: wsStore.toUserInfo.type == 'user'?1:2, //1:个人  2:群组

+ 10 - 7
src/views/im/components/CallController/index.vue

@@ -4,7 +4,7 @@
     <div class="caller-info" v-if="rtcStore.streamType == 'audio'">
       <img
         class="avatar"
-        :src="rtcStore.imSate.callAvatar || defaultAvatar"
+        :src="formatAvatarUrl(rtcStore.imSate.callAvatar || defaultAvatar)"
         alt="头像"
       />
       <div class="name">{{ rtcStore.imSate.callName || "未知用户" }}</div>
@@ -29,7 +29,7 @@
       >
         <img
           class="avatar"
-          :src="rtcStore.imSate.callAvatar || defaultAvatar"
+          :src="formatAvatarUrl(rtcStore.imSate.callAvatar || defaultAvatar)"
           alt="头像"
         />
         <div class="name">{{ rtcStore.imSate.callName || "未知用户" }}</div>
@@ -58,11 +58,6 @@
         {{ callDuration }}
       </div>
     </div>
-
-
-
-
-
     <div class="btn-group">
       <template v-if="rtcStore.isCaller">
         <button class="btn hangup" @click="hangupCall">取消</button>
@@ -88,6 +83,7 @@ import { useWalletStore } from "@/stores/modules/walletStore.js";
 import * as Constant from "@/common/constant/Constant";
 import { soundVoice } from "@/utils/notifications.js";
 import { MESSAGE_TYPE_USER } from "@/common/constant/msgType";
+const IM_PATH = import.meta.env.VITE_IM_PATH_FIlE;
 
 const wsStore = useWebSocketStore();
 const rtcStore = useWebRTCStore();
@@ -100,6 +96,13 @@ let startTime = null;
 const inCall = ref(false);
 const defaultAvatar = "https://example.com/default-avatar.png";
 
+const formatAvatarUrl = (url) => {
+  if (/^https?:\/\//.test(url)) {
+    return url
+  }
+  return IM_PATH + url
+}
+
 // 视频流引用
 const mainVideo = ref(null);
 const pipVideo = ref(null);

+ 1 - 1
src/views/im/detail/addMember/index.vue

@@ -144,7 +144,7 @@ const submit = async () => {
                     messageType: MsgType.INVITATION_GROUP,
                 };
                 wsStore.sendMessage(message);
-                await wsStore.fetchGroupMembers(true)
+                // await wsStore.fetchGroupMembers(true)
                 // systemStore.needRefreshIm = true;
                 // router.push('im')
                 // router.push({

+ 1 - 1
src/views/im/detail/deleteMember/index.vue

@@ -143,7 +143,7 @@
             messageType:REMOVE_GROUP
           };
           wsStore.sendMessage(message);
-          await wsStore.fetchGroupMembers(true)
+          // await wsStore.fetchGroupMembers(true)
           // systemStore.needRefreshIm = true;
           // router.push('im')
           // router.push({

+ 11 - 20
src/views/im/detail/index.vue

@@ -205,9 +205,9 @@ const systemStore = useSystemStore();
 const groupMembers = ref([]); //显示部分成员
 const groupMembersNum = ref([]); //全部成员
 const information = reactive({
-    name: wsStore.toUserInfo.nickname || '群聊',
+    name: wsStore.toUserInfo.sessionName || '群聊',
     notice: wsStore.toUserInfo.notice,
-    nickname: ''
+    nickname: wsStore.toUserInfo.nickname
 });
 const type = ref(1); //1:修改群聊名称  2:修改我的群昵称
 const disturb = ref(wsStore.toUserInfo?.slience === 1 || wsStore.toUserInfo?.slience === true)
@@ -224,12 +224,12 @@ const fetchGroupMembers = async () => {
         const res = await groupList(wsStore.toUserInfo.uuid);
         groupMembers.value = (res.data || []).slice(0, 8);
         groupMembersNum.value = res.data || [];
-        const dataInfo = groupMembersNum.value.find(
-            m => m.uuid === walletStore.account
-        );
-        if (dataInfo) {
-            information.nickname = dataInfo.nickname || ''; // 群个人昵称
-        }
+        // const dataInfo = groupMembersNum.value.find(
+        //     m => m.uuid === walletStore.account
+        // );
+        // if (dataInfo) {
+        //     information.nickname = dataInfo.nickname || ''; // 群个人昵称
+        // }
     } catch (e) {
         console.error('获取群成员失败', e);
     }
@@ -261,7 +261,7 @@ const popConfirm = () => {
         showUpdateName.value = false;
         if (type.value == 1) {
             information.name = newName.value;
-            wsStore.toUserInfo.nickname = newName.value;
+            wsStore.toUserInfo.sessionName = newName.value;
             // 修改群聊名称接口
             funSelectGroupName({
                 name: newName.value,
@@ -289,15 +289,6 @@ const popConfirm = () => {
             if (selfInMembers) {
                 selfInMembers.nickname = newName.value;
             }
-            //缓存的聊天信息数据也要做更改
-            // wsStore.messages = wsStore.messages.map(
-            //     m => {
-            //         if(m.uuid === walletStore.account){
-            //             m.nickname = newName.value;
-            //         }
-            //         return m
-            //     }
-            // );
         }
     }, 1000);
 };
@@ -367,7 +358,7 @@ const popExit = async () => {
         wsStore.sendMessage(message);
     }
     try {
-        const res = await action(walletStore.account, wsStore.toUserInfo.id);
+        const res = await action(walletStore.account, wsStore.toUserInfo.groupId);
         if (res.code === 200) {
             showToast(successMsg);
             if (!isAdmin.value) {
@@ -382,7 +373,7 @@ const popExit = async () => {
                 wsStore.sendMessage(message);
             }
             systemStore.needRefreshIm = true;
-            await wsStore.fetchGroupMembers(true)
+            // await wsStore.fetchGroupMembers(true)
             router.push('im');
         } else {
             showToast(failMsg);

+ 30 - 33
src/views/im/hook/messagesHook.js

@@ -77,14 +77,15 @@ export const setMessageHook = (message, wsStore) => {
       wsStore.deleteMessage(message, msg.msgId, message.to);
     }
     // 更新会话列表
-    wsStore.updateSessionNewMessage({...message, content: msg && !msg.isTemp?'[消息已销毁]':`${message.from == walletStore.account ? '你' : (message.fromUsername || '对方')}撤回了一条消息`}, message.to);
+    wsStore.updateSessionNewMessage({...message, ...msg, content: msg && !msg.isTemp?'[消息已销毁]':`${message.from == walletStore.account ? '你' : (message.fromUsername || '对方')}撤回了一条消息`}, message.to);
   }
   
   // 语音和视频挂断/拒接消息处理
   if ([Constant.CANCELL_AUDIO_ONLINE, Constant.CANCELL_VIDEO_ONLINE, Constant.REJECT_AUDIO_ONLINE, Constant.REJECT_VIDEO_ONLINE].includes(message.contentType)) {
     wsStore.pushMessage({
       ...message,
-      toUsername: message.to,
+      align:'right',
+      // toUsername: message.to,
       content:message.contentType === Constant.REJECT_AUDIO_ONLINE || message.contentType === Constant.REJECT_VIDEO_ONLINE?'[对方拒绝]':'[通话结束]',
       sender: wsStore.toUserInfo.sender || {
         uuid: walletStore.account,
@@ -97,7 +98,8 @@ export const setMessageHook = (message, wsStore) => {
   if (message.contentType == MsgType.MSG_TYPE.TEXT) {
     wsStore.pushMessage(formatMessageExt({
       ...message,
-      toUsername: message.friendUsername
+      // toUsername: message.friendUsername
+      align: 'right',
     }, msg), message.to);
   }
   // 音频消息
@@ -106,7 +108,8 @@ export const setMessageHook = (message, wsStore) => {
     const url = URL.createObjectURL(blob);
     wsStore.pushMessage(formatMessageExt({
       ...message,
-      toUsername: message.to,
+      // toUsername: message.to,
+      align: 'right',
       localUrl: url,
     }, msg), message.to);
   }
@@ -116,7 +119,8 @@ export const setMessageHook = (message, wsStore) => {
     const url = URL.createObjectURL(blob);
     wsStore.pushMessage(formatMessageExt({
       ...message,
-      toUsername: message.to,
+      // toUsername: message.to,
+      align: 'right',
       localUrl: url,
     }, msg), message.to);
   }
@@ -173,26 +177,9 @@ export const handleMessageHook = async (payload, wsStore) => {
       wsStore.deleteMessage(message, msg.msgId);
     }
     // 更新会话列表
-    wsStore.updateSessionNewMessage({...message, content: msg && !msg.isTemp?'[消息已销毁]':`${message.from == walletStore.account ? '你' : (message.fromUsername || '对方')}撤回了一条消息`}, message.from);
+    wsStore.updateSessionNewMessage({...message, ...msg, content: msg && !msg.isTemp?'[消息已销毁]':`${message.from == walletStore.account ? '你' : (message.fromUsername || '对方')}撤回了一条消息`}, message.from);
   }
 
-  // 兼容图片
-  // message.avatar = formatAvatarUrl(message.avatar);
-
-  // 同步更新会话列表缓存
-
-  // if ((MsgType.MSG_TYPE_MAP.indexOf(message.contentType) >= 0 && !message.type) || msgType.includes(message.contentType)) {
-  //   // 处理群头像兼容
-  //   const avatar = message.avatar;
-  //   if (Array.isArray(wsStore.toUserInfo.avatar)) {
-  //     message.avatar = wsStore.toUserInfo.avatar.map(val => formatAvatarUrl(val))
-  //   }
-  //   // 更新会话列表
-  //   wsStore.updateSessionList(message, 1, msg);
-  //   // 还原
-  //   message.avatar = avatar;
-  // }
-
   // 接收好友系统消息
   if(MsgType.MSG_TYPE_FRIEND.includes(message.messageType)){
     // 好友系统功能消息
@@ -206,6 +193,7 @@ export const handleMessageHook = async (payload, wsStore) => {
     wsStore.listenGroupSystemMessage(message, msg); 
     // 群系统消息转换
     let newContent = msg?msg.content:message.content;
+    let contentType = MsgType.MSG_TYPE.NOTICE;
     // 处理群通知
     if (message.messageType === MsgType.MESSAGE_NOTICE_GROUP) {
       newContent = `管理员修改了群${msg.notice?'公告':'名称'}`;
@@ -217,11 +205,16 @@ export const handleMessageHook = async (payload, wsStore) => {
         message.notice = msg.notice;
       }
     }
+    // 如果是@群成员
+    if(message.messageType == MsgType.MESSAGE_CC_GROUP){
+      contentType = MsgType.MSG_TYPE.TEXT
+    }
     wsStore.pushMessage({
       ...message,
-      toUsername: message.to,
+      // toUsername: message.to,
+      align: 'left',
       content: newContent,
-      contentType: MsgType.MSG_TYPE.NOTICE,
+      contentType,
       messageType: MsgType.MESSAGE_TYPE_GROUP
     });
     notifications(wsStore);
@@ -232,7 +225,8 @@ export const handleMessageHook = async (payload, wsStore) => {
   if ([Constant.CANCELL_AUDIO_ONLINE, Constant.CANCELL_VIDEO_ONLINE, Constant.REJECT_AUDIO_ONLINE, Constant.REJECT_VIDEO_ONLINE].includes(message.contentType)) {
     wsStore.pushMessage({
       ...message,
-      toUsername: message.to,
+      align: 'left',
+      // toUsername: message.to,
       content:message.contentType === Constant.REJECT_AUDIO_ONLINE || message.contentType === Constant.REJECT_VIDEO_ONLINE?'[对方拒绝]':'[通话结束]',
       sender: wsStore.toUserInfo.sender || {
         uuid: walletStore.account,
@@ -244,13 +238,14 @@ export const handleMessageHook = async (payload, wsStore) => {
 
   // 文本消息
   if (message.contentType === MsgType.MSG_TYPE.TEXT) {
-    let ccArr = msg?.cc.split(',');
-    if (wsStore.groupMembersList && wsStore.groupMembersList[message.from]) {
-      wsStore.isassign = wsStore.groupMembersList[message.from].filter(val => ccArr.includes(val.userId + '')).find(val => val.uuid == message.to)
-    }
+    // let ccArr = msg?.cc.split(',');
+    // if (wsStore.groupMembersList && wsStore.groupMembersList[message.from]) {
+    //   wsStore.isassign = wsStore.groupMembersList[message.from].filter(val => ccArr.includes(val.userId + '')).find(val => val.uuid == message.to)
+    // }
     wsStore.pushMessage(formatMessageExt({
       ...message,
-      toUsername: message.to,
+      // toUsername: message.to,
+      align: 'left',
     }, msg));
     notifications(wsStore);
     return
@@ -265,7 +260,8 @@ export const handleMessageHook = async (payload, wsStore) => {
     wsStore.pushMessage(formatMessageExt({
       ...message,
       file: audioUrl,
-      toUsername: message.to,
+      // toUsername: message.to,
+      align: 'left',
     }, msg));
     notifications(wsStore);
     return
@@ -277,7 +273,8 @@ export const handleMessageHook = async (payload, wsStore) => {
     wsStore.pushMessage(formatMessageExt({
       ...message,
       file: url,
-      toUsername: message.to,
+      // toUsername: message.to,
+      align: 'left',
     }, msg));
     notifications(wsStore);
     return

+ 3 - 1
src/views/im/index.vue

@@ -131,7 +131,9 @@ watch(
   () => wsStore.chatRefresh,
   (newVal,oldVal) => {
     if (newVal !== oldVal) {
-      getuserList(true)
+      setTimeout(() => {
+        getuserList(true)
+      }, 500);
     }
   }
 );