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') {