fix(editor): 修复提及功能中用户ID处理问题
修复提及成员时用户ID类型转换问题,确保ID统一为字符串类型。同时为管理员添加"全体成员"提及选项,并完善提及列表的数据处理逻辑。
This commit is contained in:
parent
b905db0cfa
commit
bdf07155c8
@ -76,7 +76,9 @@ const navs = ref([
|
|||||||
|
|
||||||
const mentionList = ref([])
|
const mentionList = ref([])
|
||||||
const currentMentionQuery = ref('')
|
const currentMentionQuery = ref('')
|
||||||
|
setTimeout(() => {
|
||||||
|
console.log('props.members',props.members)
|
||||||
|
}, 1000)
|
||||||
// 编辑器内容
|
// 编辑器内容
|
||||||
const editorContent = ref('')
|
const editorContent = ref('')
|
||||||
const editorHtml = ref('')
|
const editorHtml = ref('')
|
||||||
@ -165,7 +167,9 @@ const showMentionList = () => {
|
|||||||
mentionList.value = props.members.filter(member => {
|
mentionList.value = props.members.filter(member => {
|
||||||
return member.value.toLowerCase().startsWith(query)
|
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
|
showMention.value = mentionList.value.length > 0
|
||||||
selectedMentionIndex.value = 0
|
selectedMentionIndex.value = 0
|
||||||
}
|
}
|
||||||
@ -190,6 +194,7 @@ const updateMentionPosition = (range) => {
|
|||||||
|
|
||||||
// 插入mention
|
// 插入mention
|
||||||
const insertMention = (member) => {
|
const insertMention = (member) => {
|
||||||
|
console.log('插入mention',member)
|
||||||
const selection = window.getSelection()
|
const selection = window.getSelection()
|
||||||
if (!selection.rangeCount) return
|
if (!selection.rangeCount) return
|
||||||
|
|
||||||
@ -204,7 +209,7 @@ const insertMention = (member) => {
|
|||||||
// 创建mention元素
|
// 创建mention元素
|
||||||
const mentionSpan = document.createElement('span')
|
const mentionSpan = document.createElement('span')
|
||||||
mentionSpan.className = 'mention'
|
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.textContent = `@${member.value || member.nickname}`
|
||||||
mentionSpan.contentEditable = 'false'
|
mentionSpan.contentEditable = 'false'
|
||||||
|
|
||||||
@ -541,10 +546,15 @@ const sendMessage = () => {
|
|||||||
type: 1
|
type: 1
|
||||||
}],
|
}],
|
||||||
mentionUids: messageData.mentionUids,
|
mentionUids: messageData.mentionUids,
|
||||||
mentions: [],
|
mentions: messageData.mentionUids.map(uid => {
|
||||||
|
return {
|
||||||
|
atid: uid,
|
||||||
|
name: mentionList.value.find(member => member.id === uid)?.nickname || ''
|
||||||
|
}
|
||||||
|
}),
|
||||||
quoteId: messageData.quoteId,
|
quoteId: messageData.quoteId,
|
||||||
}
|
}
|
||||||
|
console.log('data',data)
|
||||||
emit(
|
emit(
|
||||||
'editor-event',
|
'editor-event',
|
||||||
emitCall('text_event', data)
|
emitCall('text_event', data)
|
||||||
@ -604,7 +614,7 @@ const parseEditorContent = () => {
|
|||||||
// 处理@提及
|
// 处理@提及
|
||||||
const userId = node.getAttribute('data-user-id')
|
const userId = node.getAttribute('data-user-id')
|
||||||
if (userId) {
|
if (userId) {
|
||||||
mentionUids.push(parseInt(userId))
|
mentionUids.push(Number(userId))
|
||||||
}
|
}
|
||||||
textContent += node.textContent
|
textContent += node.textContent
|
||||||
} else if (node.tagName === 'IMG') {
|
} else if (node.tagName === 'IMG') {
|
||||||
|
Loading…
Reference in New Issue
Block a user