From bdfd604fd9bd8130bc62b79ff5c5b9188ae19817 Mon Sep 17 00:00:00 2001 From: wangyifeng <812766448@qq.com> Date: Tue, 27 May 2025 18:49:48 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E6=8E=A5=E5=85=A5=E4=BC=9A=E8=AF=9D?= =?UTF-8?q?=E7=BD=AE=E9=A1=B6=E3=80=81=E4=BC=9A=E8=AF=9D=E5=85=8D=E6=89=93?= =?UTF-8?q?=E6=89=B0=E5=8A=9F=E8=83=BD=E5=88=B0=E8=81=8A=E5=A4=A9=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E9=A1=B5=E9=9D=A2=EF=BC=9B=E6=8E=A5=E5=85=A5=E9=80=80?= =?UTF-8?q?=E5=87=BA=E7=BE=A4=E8=81=8A=E3=80=81=E8=A7=A3=E6=95=A3=E7=BE=A4?= =?UTF-8?q?=E8=81=8A=E5=8A=9F=E8=83=BD=EF=BC=8C=E5=B9=B6=E8=A7=A3=E5=86=B3?= =?UTF-8?q?=E5=8E=86=E5=8F=B2=E9=81=97=E7=95=99=E9=97=AE=E9=A2=98=EF=BC=9A?= =?UTF-8?q?=E7=BE=A4=E4=B8=BB=E4=B8=8D=E8=83=BD=E9=80=80=E7=BE=A4=EF=BC=88?= =?UTF-8?q?=E6=99=AE=E9=80=9A=E7=BE=A4=EF=BC=89=EF=BC=9B=E6=8E=A5=E5=85=A5?= =?UTF-8?q?=E6=96=B0=E7=89=88socket=E6=B6=88=E6=81=AF=E7=9B=91=E5=90=AC?= =?UTF-8?q?=E7=94=A8=E4=BA=8E=E5=A4=84=E7=90=86=E6=B6=88=E6=81=AF=E5=B7=B2?= =?UTF-8?q?=E8=AF=BB=E5=9B=9E=E6=89=A7=EF=BC=8C=E8=AF=BB=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E8=A7=86=E8=A7=92=E4=BE=9D=E7=84=B6=E6=B2=BF=E7=94=A8=E6=97=A7?= =?UTF-8?q?=E7=89=88=E8=BD=AE=E8=AF=A2=E6=96=B9=E6=A1=88=E9=98=B2=E6=AD=A2?= =?UTF-8?q?=E4=B8=A2=E5=A4=B1=E6=97=A2=E6=9C=89=E6=95=B0=E6=8D=AE=EF=BC=9B?= =?UTF-8?q?=E6=9F=A5=E8=A7=86=E8=A7=92=E9=87=87=E7=94=A8=E6=96=B0=E7=89=88?= =?UTF-8?q?=E7=9B=91=E5=90=ACsocket=E6=B6=88=E6=81=AF=E6=96=B9=E6=A1=88?= =?UTF-8?q?=E4=BB=A3=E6=9B=BF=E8=BD=AE=E8=AF=A2=E6=8E=A5=E5=8F=A3=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/group/GroupPanel.vue | 122 +++++- .../system/SysGroupMemberKickedMessage.vue | 2 +- src/connect.ts | 8 + .../message/inner/panel/PanelContent.vue | 388 +++++++++++++++++- src/views/message/inner/panel/PanelFooter.vue | 4 +- 5 files changed, 477 insertions(+), 47 deletions(-) diff --git a/src/components/group/GroupPanel.vue b/src/components/group/GroupPanel.vue index 2642fd5..cb0d03e 100644 --- a/src/components/group/GroupPanel.vue +++ b/src/components/group/GroupPanel.vue @@ -11,13 +11,14 @@ import { ServeSecedeGroup, ServeUpdateGroupCard, ServeGetGroupNotices, - ServeEditGroup + ServeEditGroup, + ServeDismissGroup } from '@/api/group' import { useInject } from '@/hooks' import customModal from '@/components/common/customModal.vue' import avatarModule from '@/components/avatar-module/index.vue' import UserCardModal from '@/components/user/UserCardModal.vue' -import { ServeEmptyMessage } from '@/api/chat' +import { ServeEmptyMessage, ServeTopTalkList, ServeSetNotDisturb } from '@/api/chat' import { parseTime } from '@/utils/datetime' const userStore = useUserStore() @@ -48,6 +49,12 @@ const props = defineProps({ } }) +const talkParams = reactive({ + isTop: computed(() => talkStore.findItem(props.talkType + '_' + props.gid)?.is_top), + isDisturb: computed(() => talkStore.findItem(props.talkType + '_' + props.gid)?.is_disturb), + sessionId: computed(() => talkStore.findItem(props.talkType + '_' + props.gid)?.id) +}) + watch(props, () => { if (props.talkType === 2) { loadDetail() @@ -98,7 +105,8 @@ const state = reactive({ }, //群公告信息 editGroupName: false, //是否编辑群名称 editGroupNameValue: '', //编辑中的群名称 - chatSettingOperateType: '' //聊天设置操作类型 + chatSettingOperateType: '', //聊天设置操作类型 + isLastAdmin: false //是否是最后一个管理员 }) const members = ref([]) @@ -177,17 +185,36 @@ const onClose = () => { emit('close') } -const onSignOut = () => { +const onSignOut = (closeLoading) => { ServeSecedeGroup({ group_id: props.gid - }).then((res) => { - if (res.code == 200) { - window['$message'].success('已退出群聊') - onClose() - } else { - window['$message'].error(res.message) - } }) + .then((res) => { + closeLoading() + if (res.code == 200) { + window['$message'].success('已退出群聊') + state.isShowModal = false + onClose() + } else { + window['$message'].error(res.message || res.msg) + } + }) + .catch((err) => { + closeLoading() + window['$message'].error(err.message) + }) +} + +const onDismiss = async (closeLoading) => { + const { code, message } = await ServeDismissGroup({ group_id: props.gid }) + closeLoading() + if (code === 200) { + onClose() + state.isShowModal = false + window['$message'].success('群聊已解散') + } else { + window['$message'].info(message) + } } const onChangeRemark = () => { @@ -236,8 +263,18 @@ const handleModalConfirm = (closeLoading) => { closeLoading() window['$message'].error(err.message) }) - } else if (state.chatSettingOperateType == 'quit'){ + } else if (state.chatSettingOperateType == 'quit') { //退出群聊 + if (state.isLastAdmin) { + //如果是最后一个管理员,则退出同时解散群聊 + onDismiss(closeLoading) + } else { + //如果不是最后一个管理员,则退出群聊 + onSignOut(closeLoading) + } + } else if (state.chatSettingOperateType == 'dismiss') { + //解散群聊 + onDismiss(closeLoading) } } @@ -256,12 +293,15 @@ const showChatSettingOperateModal = (type: string) => { break case 'quit': state.chatSettingOperateHint = '确定退出群聊' - const findAdmin = groupMemberList.value.find((item) => item.leader === 2 || item.leader === 1) - const isLastAdmin = findAdmin && findAdmin.user_id === userStore.uid - if (isLastAdmin) { - state.chatSettingOperateSubHint = '退出后,本群将被解散' - } else { + const findOtherAdmin = groupMemberList.value.find( + (item) => (item.leader === 2 || item.leader === 1) && item.user_id !== userStore.uid + ) + if (findOtherAdmin) { + state.isLastAdmin = false state.chatSettingOperateSubHint = '退出后,聊天记录将被清空' + } else { + state.isLastAdmin = true + state.chatSettingOperateSubHint = '退出后,本群将被解散' } break } @@ -380,6 +420,42 @@ const handleEditGroupNameConfirm = () => { } }) } + +//设置会话置顶 +const onTopChange = (value: boolean) => { + ServeTopTalkList({ + list_id: talkParams.sessionId, + type: value ? 1 : 2 + }).then(({ code, message }) => { + if (code == 200) { + talkStore.updateItem({ + index_name: props.talkType + '_' + props.gid, + is_top: talkParams.isTop == 0 ? 1 : 0 + }) + } else { + window['$message'].error(message) + } + }) +} + +//设置会话免打扰 +const onDisturbChange = (value: boolean) => { + ServeSetNotDisturb({ + talk_type: props.talkType, + receiver_id: props.gid, + is_disturb: value ? 1 : 0 + }).then(({ code, message }) => { + if (code == 200) { + window['$message'].success('设置成功!') + talkStore.updateItem({ + index_name: props.talkType + '_' + props.gid, + is_disturb: value ? 1 : 0 + }) + } else { + window['$message'].error(message) + } + }) +} - 踢出群聊 + 移出群聊 diff --git a/src/connect.ts b/src/connect.ts index 9bf730f..96e1458 100644 --- a/src/connect.ts +++ b/src/connect.ts @@ -85,6 +85,7 @@ class Connect { this.onImContactStatus() this.onImMessageRevoke() this.onImMessageKeyboard() + this.onImMessageListenReadIncr() } onPing() { @@ -131,6 +132,13 @@ class Connect { this.conn.on('im.message.revoke', (data: any) => new EventRevoke(data)) } + onImMessageListenReadIncr() { + // 消息已读回执监听事件 + this.conn.on('im.message.listen.read.incr', (data: any) => { + console.error('====接收到了新版已读回执增量=====', data) + }) + } + onImContactApply() { // 好友申请事件 this.conn.on('im.contact.apply', (data: any) => { diff --git a/src/views/message/inner/panel/PanelContent.vue b/src/views/message/inner/panel/PanelContent.vue index f37fd7d..0491063 100644 --- a/src/views/message/inner/panel/PanelContent.vue +++ b/src/views/message/inner/panel/PanelContent.vue @@ -1,5 +1,5 @@