From a0b476da7ae83ae1a829cdafaf1083085995a980 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=A1=E5=A4=8D=E4=B9=A0?= <2353956224@qq.com> Date: Thu, 26 Feb 2026 16:43:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E7=A1=AE=E8=AE=A4=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/pk-mini/goeasy.js | 22 ++++++++++++++ src/views/pk-mini/Message.vue | 54 ++++++++++++++++++++++++++++++++++- 2 files changed, 75 insertions(+), 1 deletion(-) diff --git a/src/utils/pk-mini/goeasy.js b/src/utils/pk-mini/goeasy.js index 185aadb..0d929cc 100644 --- a/src/utils/pk-mini/goeasy.js +++ b/src/utils/pk-mini/goeasy.js @@ -263,5 +263,27 @@ export function goEasyMessageRead(data) { }) } +// 删除会话 +export function goEasyRemoveConversation(conversation) { + if (!isGoEasyEnabled()) { + return Promise.reject(new Error('GoEasy 未启用')) + } + + const goeasy = getPkGoEasy() + const im = goeasy.im + return new Promise((resolve, reject) => { + im.removeConversation({ + conversation: conversation, + onSuccess: function () { + resolve(true) + }, + onFailed: function (error) { + console.log('删除会话失败,code:' + error.code + ',error:' + error.content) + reject(error) + } + }) + }) +} + // 导出 GoEasy 常量(用于事件监听) export { GoEasy } diff --git a/src/views/pk-mini/Message.vue b/src/views/pk-mini/Message.vue index 771e04a..669a8e4 100644 --- a/src/views/pk-mini/Message.vue +++ b/src/views/pk-mini/Message.vue @@ -21,6 +21,11 @@
{{ item.lastMessage?.payload?.text || '' }}
+ ×
暂无会话
@@ -92,13 +97,14 @@ import { goEasySendMessage, goEasySendImageMessage, goEasyMessageRead, + goEasyRemoveConversation, getPkGoEasy, GoEasy } from '@/utils/pk-mini/goeasy' import PictureMessage from '@/components/pk-mini/chat/PictureMessage.vue' import MiniPKMessage from '@/components/pk-mini/chat/MiniPKMessage.vue' import VoiceMessage from '@/components/pk-mini/chat/VoiceMessage.vue' -import { ElMessage } from 'element-plus' +import { ElMessage, ElMessageBox } from 'element-plus' import { pkUnreadStore } from '@/stores/pk-mini/notice.js' const defaultAvatar = 'https://vv-1317974657.cos.ap-shanghai.myqcloud.com/util/default-avatar.png' @@ -229,6 +235,29 @@ async function handleFileSelect(event) { } } +async function removeConversation(item, index) { + try { + await ElMessageBox.confirm('确定删除该会话吗?', '删除会话', { + confirmButtonText: '删除', + cancelButtonText: '取消', + type: 'warning' + }) + } catch { + return + } + try { + await goEasyRemoveConversation(item) + chatList.value.splice(index, 1) + if (selectedChat.value === item) { + selectedChat.value = null + messagesList.value = [] + } + } catch (e) { + console.error('删除会话失败', e) + ElMessage.error('删除会话失败') + } +} + onMounted(() => { currentUser.value = getMainUserData() || {} if (isGoEasyEnabled()) { @@ -491,6 +520,29 @@ onUnmounted(() => { margin-bottom: 20px; } +.conversation-item:hover .conv-delete, +.conversation-item.active .conv-delete { + display: flex; +} + +.conv-delete { + display: none; + align-items: center; + justify-content: center; + width: 20px; + height: 20px; + border-radius: 50%; + font-size: 16px; + line-height: 1; + color: #94a3b8; + flex-shrink: 0; + margin-left: 4px; + &:hover { + background-color: #fee2e2; + color: #ef4444; + } +} + .empty-tip { text-align: center; padding: 50px;