From dbdec912cea76b0ea76518a784a75abbeb20562c Mon Sep 17 00:00:00 2001 From: wangyifeng <812766448@qq.com> Date: Sat, 31 May 2025 03:53:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A5=E5=85=A5=E6=9C=89=E4=BA=BA@=E4=BD=A0?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=EF=BC=8C=E5=B9=B6=E5=AE=9E=E7=8E=B0=E7=83=AD?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=EF=BC=9B=E6=8E=A5=E5=85=A5=E7=BE=A4=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E6=9B=B4=E6=96=B0=E3=80=81=E5=8F=8C=E5=9C=BA=E6=99=AF?= =?UTF-8?q?=E4=B8=8B=E7=9A=84=E7=BE=A4=E8=81=8A=E8=A7=A3=E6=95=A3=E3=80=81?= =?UTF-8?q?=E9=80=80=E7=BE=A4=E6=B6=88=E6=81=AF=E6=9B=B4=E6=96=B0=E7=BE=A4?= =?UTF-8?q?=E8=81=8A=E8=AE=BE=E7=BD=AE=E6=8C=89=E9=92=AE=E7=82=B9=E5=87=BB?= =?UTF-8?q?=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/event/talk.js | 64 ++++++++++++++++++- src/store/modules/dialogue.js | 24 +++++++ src/utils/talk.js | 2 + src/views/message/inner/IndexSider.vue | 3 +- src/views/message/inner/TalkItem.vue | 1 + src/views/message/inner/panel/PanelHeader.vue | 36 +++++++---- 6 files changed, 112 insertions(+), 18 deletions(-) diff --git a/src/event/talk.js b/src/event/talk.js index 7826004..8a1db18 100644 --- a/src/event/talk.js +++ b/src/event/talk.js @@ -94,7 +94,7 @@ class Talk extends Base { useSettingsStore().isPromptTone && palyMusic() } - handle() { + async handle() { // 不是自己发送的消息则需要播放提示音 if (!this.isCurrSender()) { this.play() @@ -102,7 +102,18 @@ class Talk extends Base { // 判断会话列表是否存在,不存在则创建 if (useTalkStore().findTalkIndex(this.getIndexName()) == -1) { - return this.addTalkItem() + if (this.resource.msg_type == 1102) { + //被邀请进入群聊时,需要热更新会话列表 + await useTalkStore().loadTalkList() + } else if (this.resource.msg_type == 1106) { + //群解散时,需要热更新会话列表 + await useTalkStore().loadTalkList() + } else if (this.resource.msg_type == 1104 || this.resource.msg_type == 1115) { + //群成员被移出时,需要热更新会话列表 + await useTalkStore().loadTalkList() + } else { + return this.addTalkItem() + } } // 判断当前是否正在和好友对话 @@ -169,10 +180,42 @@ class Talk extends Base { let record = this.resource // 群成员变化的消息,需要更新群成员列表 - if ([1102, 1103, 1104].includes(record.msg_type)) { + if ([1102, 1103, 1104, 1115].includes(record.msg_type)) { useDialogueStore().updateGroupMembers() } + //群解散时,需要更新群成员权限 + if ([1106].includes(record.msg_type)) { + useDialogueStore().updateDismiss(true) + } + + //群成员被移出时,需要更新群成员权限 + if ([1104, 1115].includes(record.msg_type)) { + if (this.resource?.extra?.members?.length > 0) { + const isMeQuit = this.resource.extra.members.find( + (item) => item.user_id === this.getAccountId() + ) + if (isMeQuit) { + useDialogueStore().updateQuit(true) + } + } + } + + // 群信息变更时,需要更新群信息 + if ([1116].includes(record.msg_type)) { + // 更新会话信息 + useDialogueStore().updateDialogueTalk({ + username: record.extra.group_name, + avatar: record.extra.group_avatar + }) + //更新会话列表中的会话信息 + useTalkStore().updateItem({ + index_name: this.getIndexName(), + name: record.extra.group_name, + avatar: record.extra.group_avatar + }) + } + useDialogueStore().addDialogueRecord(formatTalkRecord(this.getAccountId(), this.resource)) if (!this.isCurrSender()) { @@ -221,6 +264,21 @@ class Talk extends Base { msg_text: this.getTalkText(), updated_at: parseTime(new Date()) }) + //收到新消息时,同时判断是否有人@我 + if (this.resource.msg_type === 1 && this.resource?.extra?.mentions?.length > 0) { + const findMention = this.resource?.extra?.mentions?.find( + (mention) => mention === this.getAccountId() + ) + //有人@我或者@所有人,则更新会话列表 + if (findMention || this.resource?.extra?.mentions?.includes(0)) { + // useTalkStore().loadTalkList() + useTalkStore().updateItem({ + index_name: this.getIndexName(), + msg_text: this.getTalkText(), + atsign_num: 1 + }) + } + } } } diff --git a/src/store/modules/dialogue.js b/src/store/modules/dialogue.js index 0ba545b..b235bc2 100644 --- a/src/store/modules/dialogue.js +++ b/src/store/modules/dialogue.js @@ -49,6 +49,12 @@ export const useDialogueStore = defineStore('dialogue', { // 是否显示编辑器 isShowEditor: false, + //是否已被解散 + isDismiss: false, + + //是否退群/移出群 + isQuit: false, + // 是否显示会话列表 isShowSessionList: true, groupInfo: {} , @@ -80,6 +86,16 @@ export const useDialogueStore = defineStore('dialogue', { this.online = status }, + // 更新群解散状态 + updateDismiss(isDismiss) { + this.isDismiss = isDismiss + }, + + // 更新群成员退出状态 + updateQuit(isQuit) { + this.isQuit = isQuit + }, + // 更新对话信息 setDialogue(data = {}) { this.online = data.is_online == 1 @@ -95,6 +111,9 @@ export const useDialogueStore = defineStore('dialogue', { this.records = [] this.unreadBubble = 0 this.isShowEditor = data?.is_robot === 0 + + this.isDismiss = data?.is_dismiss === 1 ? true : false + this.isQuit = data?.is_quit === 1 ? true : false // 只在手动切换会话时清空 specifiedMsg // if (this.isManualSwitch) { @@ -292,6 +311,11 @@ export const useDialogueStore = defineStore('dialogue', { record.extra.url = videoInfo.url // record.extra.cover = videoInfo.cover } + }, + + // 更新会话信息 + updateDialogueTalk(params){ + Object.assign(this.talk, params) } } }) diff --git a/src/utils/talk.js b/src/utils/talk.js index 941c1a5..4377eaa 100644 --- a/src/utils/talk.js +++ b/src/utils/talk.js @@ -39,6 +39,8 @@ export function formatTalkItem(params) { is_top: 0, is_online: 0, is_robot: 0, + is_dismiss: 0, + is_quit: 0, unread_num: 0, content: '......', draft_text: '', diff --git a/src/views/message/inner/IndexSider.vue b/src/views/message/inner/IndexSider.vue index 5193042..f737c24 100644 --- a/src/views/message/inner/IndexSider.vue +++ b/src/views/message/inner/IndexSider.vue @@ -401,7 +401,8 @@ const onTabTalk = (item: ISession, follow = false) => { }).then(() => { talkStore.updateItem({ index_name: item.index_name, - unread_num: 0 + unread_num: 0, + atsign_num: 0 }) }) } diff --git a/src/views/message/inner/TalkItem.vue b/src/views/message/inner/TalkItem.vue index fca0330..905f015 100644 --- a/src/views/message/inner/TalkItem.vue +++ b/src/views/message/inner/TalkItem.vue @@ -51,6 +51,7 @@ const labelColor=[ diff --git a/src/views/message/inner/panel/PanelHeader.vue b/src/views/message/inner/panel/PanelHeader.vue index 80c36ab..bcc5f55 100644 --- a/src/views/message/inner/panel/PanelHeader.vue +++ b/src/views/message/inner/panel/PanelHeader.vue @@ -19,7 +19,7 @@ defineProps({ type: Boolean, default: false }, - avatar:{ + avatar: { type: String, default: '' }, @@ -46,19 +46,22 @@ const onSetMenu = () => { /> -->
- +
- - {{ username }} - ({{ num }}) + {{ username }} + ({{ num }}) +
- -

@@ -80,8 +83,13 @@ const onSetMenu = () => { :size="18" class="icon" @click="emit('evnet', 'group')" + v-show="!dialogueStore.isDismiss && !dialogueStore.isQuit" > - +

@@ -156,7 +164,7 @@ const onSetMenu = () => { text-align: center; &.color { - color: #462AA0; + color: #462aa0; } .online-status { @@ -168,7 +176,7 @@ const onSetMenu = () => { vertical-align: middle; border-radius: 50%; position: relative; - background-color: #462AA0; + background-color: #462aa0; margin-right: 5px; &:after { @@ -177,7 +185,7 @@ const onSetMenu = () => { left: -1px; width: 100%; height: 100%; - border: 1px solid #462AA0; + border: 1px solid #462aa0; border-radius: 50%; -webkit-animation: antStatusProcessing 1.2s ease-in-out infinite; animation: antStatusProcessing 1.2s ease-in-out infinite;