From b905db0cfabb655eef4e0cff9f8144b37007867e Mon Sep 17 00:00:00 2001 From: Phoenix <64720302+Concur-max@users.noreply.github.com> Date: Mon, 9 Jun 2025 15:29:24 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E6=92=A4=E5=9B=9E=E9=80=BB=E8=BE=91=E5=92=8C=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=99=A8=E5=86=85=E5=AE=B9=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 调整消息菜单的撤回选项显示逻辑,区分单聊和群聊场景 - 修复编辑器内容处理,使用trimEnd替代trim避免尾部空格问题 - 移除重复的quote元素删除操作 - 优化编辑器空内容判断逻辑 --- src/components/editor/CustomEditor.vue | 14 ++++++++------ src/views/message/inner/panel/menu.ts | 15 +++++++++++++-- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/components/editor/CustomEditor.vue b/src/components/editor/CustomEditor.vue index 0ec7906..f68fd81 100644 --- a/src/components/editor/CustomEditor.vue +++ b/src/components/editor/CustomEditor.vue @@ -100,6 +100,7 @@ const handleInput = (event) => { const editorClone = target.cloneNode(true) const quoteElements = editorClone.querySelectorAll('.editor-quote') quoteElements.forEach(quote => quote.remove()) + quoteElements.forEach(quote => quote.remove()) // 处理表情图片,将其 alt 属性(表情文本)添加到文本内容中 const emojiImages = editorClone.querySelectorAll('img.editor-emoji') @@ -119,7 +120,8 @@ const handleInput = (event) => { editorContent.value = textContent // 检查是否需要清空编辑器以显示placeholder - const isEmpty = textContent.trim() === '' && + // 只有当编辑器中没有任何内容(包括空格)且没有其他元素时才清空 + const isEmpty = textContent === '' && !target.querySelector('img, .editor-file, .mention') if (isEmpty && target.innerHTML !== '') { @@ -525,14 +527,14 @@ const sendMessage = () => { if (messageData.items.length === 0 || (messageData.items.length === 1 && messageData.items[0].type === 1 && - !messageData.items[0].content.trim())) { + !messageData.items[0].content.trimEnd())) { return // 没有内容,不发送 } // 处理不同类型的消息 messageData.items.forEach(item => { // 处理文本内容 - if (item.type === 1 && item.content.trim()) { + if (item.type === 1 && item.content.trimEnd()) { const data = { items: [{ content: item.content, @@ -634,7 +636,7 @@ const parseEditorContent = () => { if (textContent.trim()) { items.push({ type: 1, - content: textContent.trim() + content: textContent.trimEnd() }) textContent = '' } @@ -674,7 +676,7 @@ const parseEditorContent = () => { if (textContent.trim()) { items.push({ type: 1, - content: textContent.trim() + content: textContent.trimEnd() }) textContent = '' } @@ -696,7 +698,7 @@ const parseEditorContent = () => { if (textContent.trim()) { items.push({ type: 1, - content: textContent.trim() + content: textContent.trimEnd() }) } diff --git a/src/views/message/inner/panel/menu.ts b/src/views/message/inner/panel/menu.ts index 28c171c..b1b8a11 100644 --- a/src/views/message/inner/panel/menu.ts +++ b/src/views/message/inner/panel/menu.ts @@ -48,9 +48,20 @@ export function useMenu() { dropdown.options.push({ label: '多选', key: 'multiSelect' }) dropdown.options.push({ label: '引用', key: 'quote' }) - if (isRevoke(uid, item)|| (dialogueStore.groupInfo as any).is_manager) { - dropdown.options.push({ label: `撤回`, key: 'revoke' }) + //如果是单聊 + if(item.talk_type===1){ + //撤回时间限制内,并且是自己发的 + if(isRevoke(uid, item)&&item.float==='right'){ + dropdown.options.push({ label: `撤回`, key: 'revoke' }) + } + //群聊 + }else if(item.talk_type===2){ + //管理员可以强制撤回所有成员信息 + if ((dialogueStore.groupInfo as any).is_manager) { + dropdown.options.push({ label: `撤回`, key: 'revoke' }) + } } + dropdown.options.push({ label: '删除', key: 'delete' })