From bdf07155c84fc789330a808bf2024c0c91fad5f9 Mon Sep 17 00:00:00 2001 From: Phoenix <64720302+Concur-max@users.noreply.github.com> Date: Mon, 9 Jun 2025 16:48:52 +0800 Subject: [PATCH] =?UTF-8?q?fix(editor):=20=E4=BF=AE=E5=A4=8D=E6=8F=90?= =?UTF-8?q?=E5=8F=8A=E5=8A=9F=E8=83=BD=E4=B8=AD=E7=94=A8=E6=88=B7ID?= =?UTF-8?q?=E5=A4=84=E7=90=86=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复提及成员时用户ID类型转换问题,确保ID统一为字符串类型。同时为管理员添加"全体成员"提及选项,并完善提及列表的数据处理逻辑。 --- src/components/editor/CustomEditor.vue | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/components/editor/CustomEditor.vue b/src/components/editor/CustomEditor.vue index f68fd81..9fbab75 100644 --- a/src/components/editor/CustomEditor.vue +++ b/src/components/editor/CustomEditor.vue @@ -76,7 +76,9 @@ const navs = ref([ const mentionList = ref([]) const currentMentionQuery = ref('') - +setTimeout(() => { + console.log('props.members',props.members) +}, 1000) // 编辑器内容 const editorContent = ref('') const editorHtml = ref('') @@ -165,7 +167,9 @@ const showMentionList = () => { mentionList.value = props.members.filter(member => { return member.value.toLowerCase().startsWith(query) }) - + if(dialogueStore.groupInfo.is_manager){ + mentionList.value.unshift({ id: 0, nickname: '全体成员', avatar: defAvatar, value: '全体成员' }) +} showMention.value = mentionList.value.length > 0 selectedMentionIndex.value = 0 } @@ -190,6 +194,7 @@ const updateMentionPosition = (range) => { // 插入mention const insertMention = (member) => { + console.log('插入mention',member) const selection = window.getSelection() if (!selection.rangeCount) return @@ -204,7 +209,7 @@ const insertMention = (member) => { // 创建mention元素 const mentionSpan = document.createElement('span') mentionSpan.className = 'mention' - mentionSpan.setAttribute('data-user-id', member.id || member.user_id) + mentionSpan.setAttribute('data-user-id',String(member.id)) mentionSpan.textContent = `@${member.value || member.nickname}` mentionSpan.contentEditable = 'false' @@ -541,10 +546,15 @@ const sendMessage = () => { type: 1 }], mentionUids: messageData.mentionUids, - mentions: [], + mentions: messageData.mentionUids.map(uid => { + return { + atid: uid, + name: mentionList.value.find(member => member.id === uid)?.nickname || '' + } + }), quoteId: messageData.quoteId, } - + console.log('data',data) emit( 'editor-event', emitCall('text_event', data) @@ -604,7 +614,7 @@ const parseEditorContent = () => { // 处理@提及 const userId = node.getAttribute('data-user-id') if (userId) { - mentionUids.push(parseInt(userId)) + mentionUids.push(Number(userId)) } textContent += node.textContent } else if (node.tagName === 'IMG') {