fix(editor): 修复提及功能中用户ID处理问题

修复提及成员时用户ID类型转换问题,确保ID统一为字符串类型。同时为管理员添加"全体成员"提及选项,并完善提及列表的数据处理逻辑。
This commit is contained in:
Phoenix 2025-06-09 16:48:52 +08:00
parent b905db0cfa
commit bdf07155c8

View File

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