fix(im):同步群昵称静默更新逻辑

- 群聊侧栏从当前群成员的 displayUserName 回填「我在本群的昵称」
- WebSocket 收到 GROUP_MEMBER_NICKNAME_UPDATE 时只同步 groupStore,不再插入消息列表
- 保持与 Vue3 + EP 群昵称修改交互一致
This commit is contained in:
YunaiV
2026-06-18 06:57:24 -07:00
parent 2cbec901e1
commit 2ee25c8821
2 changed files with 18 additions and 1 deletions

View File

@@ -9,6 +9,7 @@ import { IconifyIcon as Icon } from '@vben/icons'
import { message, Popover, Tooltip } from 'ant-design-vue'
import { createCall } from '#/api/im/rtc'
import { getCurrentUserId } from '#/views/im/utils/auth'
import { ImConversationType, ImRtcCallMediaType, ImRtcCallStatus } from '#/views/im/utils/constants'
import { getClientConversationId } from '#/views/im/utils/db'
import { resolveCallEndReasonText } from '#/views/im/utils/message'
@@ -183,12 +184,14 @@ const groupInfo = computed<
return undefined
}
const group = groupStore.getGroup(conversation.targetId)
const selfMember = group?.members?.find((member) => member.userId === getCurrentUserId())
return {
id: conversation.targetId,
name: group?.name || conversation.name,
showGroupName: group?.name || conversation.name,
showImage: group?.avatar || conversation.avatar,
notice: group?.notice,
remarkNickName: selfMember?.displayUserName,
groupRemark: group?.groupRemark,
ownerId: group?.ownerUserId,
memberCount: group?.memberCount,

View File

@@ -204,6 +204,7 @@ const convertGroupMessage = (
* - 已读 / 回执READ / RECEIPT多端已读同步、对方读后回执
* - 好友变更FRIEND_*):同步 friendStore + 级联刷新私聊会话FRIEND_ADD / FRIEND_DELETE 额外插入会话气泡
* - 群个人信号GROUP_MEMBER_SETTING_UPDATE同步 groupStore + 级联刷新群聊会话
* - 群成员昵称变更GROUP_MEMBER_NICKNAME_UPDATE同步 groupStore不插入消息列表
* - 群广播事件GROUP_*):走 handleGroupMessage + applyGroupNotification 旁路(含 DISSOLVE / QUIT / KICK 自判清群)
*/
export const useImWebSocketStore = defineStore('imWebSocketStore', {
@@ -538,11 +539,15 @@ export const useImWebSocketStore = defineStore('imWebSocketStore', {
/**
* 群聊统一帧分发:按 payload.typeImContentType分到已读 / 回执 / 群个人信号 / 普通消息
*
* 1530 GROUP_MEMBER_SETTING_UPDATE 是个人信号;其它(普通消息 + 1501-1520 段位群广播事件走 handleGroupMessage 入库 + 触发 applyGroupNotification 旁路
* GROUP_MEMBER_SETTING_UPDATE / GROUP_MEMBER_NICKNAME_UPDATE 是成员资料同步信号;其它群广播事件走 handleGroupMessage 入库 + 触发 applyGroupNotification 旁路
*/
dispatchGroupFrame(websocketMessage: ImGroupMessageNotification) {
try {
switch (websocketMessage.type) {
case ImContentType.GROUP_MEMBER_NICKNAME_UPDATE: {
this.handleGroupMemberNicknameUpdate(websocketMessage)
break
}
case ImContentType.GROUP_MEMBER_SETTING_UPDATE: {
this.handleGroupMemberSettingUpdate(websocketMessage)
break
@@ -984,6 +989,15 @@ export const useImWebSocketStore = defineStore('imWebSocketStore', {
}
},
/** GROUP_MEMBER_NICKNAME_UPDATE同步成员在群里的昵称 */
handleGroupMemberNicknameUpdate(websocketMessage: ImGroupMessageNotification) {
useGroupStore().applyGroupNotification(
websocketMessage.groupId,
websocketMessage.type,
websocketMessage.content
)
},
// ==================== 心跳 / 重连 ====================
/** 心跳包:纯文本 'ping',对应服务端 'pong'(后端这层用纯字符串约定,避免 JSON 解析开销) */