fix: 优化消息撤回逻辑和编辑器内容处理

- 调整消息菜单的撤回选项显示逻辑,区分单聊和群聊场景
- 修复编辑器内容处理,使用trimEnd替代trim避免尾部空格问题
- 移除重复的quote元素删除操作
- 优化编辑器空内容判断逻辑
This commit is contained in:
Phoenix 2025-06-09 15:29:24 +08:00
parent 5340461a7e
commit b905db0cfa
2 changed files with 21 additions and 8 deletions

View File

@ -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()
})
}

View File

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