perf: 优化回复消息自动@逻辑

This commit is contained in:
kuaifan 2024-06-01 12:34:49 +08:00
parent eb7d93af87
commit 7c4c7eea9c
2 changed files with 27 additions and 1 deletions

View File

@ -288,6 +288,10 @@ export default {
type: String, type: String,
default: "top" default: "top"
}, },
replyMsgAutoMention: {
type: Boolean,
default: true
},
}, },
data() { data() {
return { return {
@ -1314,7 +1318,22 @@ export default {
cancelQuote() { cancelQuote() {
if (this.quoteUpdate) { if (this.quoteUpdate) {
//
this.$emit('input', '') this.$emit('input', '')
} else {
//
if (this.$refs.editor.firstChild.querySelectorAll('img').length === 0) {
const quoteDiv = document.createElement('div')
quoteDiv.innerHTML = this.$refs.editor.firstChild.innerHTML
quoteDiv.querySelectorAll("span.mention").forEach(span => {
if (span.getAttribute("data-id") == this.quoteData.userid) {
span.innerHTML = "";
}
})
if (!quoteDiv.innerText.replace(/\s/g, '')) {
this.$emit('input', '')
}
}
} }
this.setQuote(0) this.setQuote(0)
}, },
@ -1323,7 +1342,10 @@ export default {
if (this.dialogData.type !== 'group') { if (this.dialogData.type !== 'group') {
return return
} }
if (this.quoteUpdate || !this.quoteData) { if (this.quoteUpdate || !this.quoteData || !this.replyMsgAutoMention) {
return
}
if (data.bot && !$A.rightExists(data.email, '@bot.system')) {
return return
} }
if (this.userId === data.userid || this.quoteData.userid !== data.userid) { if (this.userId === data.userid || this.quoteData.userid !== data.userid) {

View File

@ -263,6 +263,7 @@
:emoji-bottom="windowPortrait" :emoji-bottom="windowPortrait"
:maxlength="200000" :maxlength="200000"
:placeholder="$L('输入消息...')" :placeholder="$L('输入消息...')"
:reply-msg-auto-mention="replyMsgAutoMention"
@on-focus="onEventFocus" @on-focus="onEventFocus"
@on-blur="onEventBlur" @on-blur="onEventBlur"
@on-more="onEventMore" @on-more="onEventMore"
@ -861,6 +862,7 @@ export default {
selectedTextStatus: false, // selectedTextStatus: false, //
scrollToBottomRefresh: false, // scrollToBottomRefresh: false, //
androidKeyboardVisible: false, // Android androidKeyboardVisible: false, // Android
replyMsgAutoMention: false, // @
} }
}, },
@ -1490,6 +1492,7 @@ export default {
this.positionShow = false this.positionShow = false
this.msgPrepared = false this.msgPrepared = false
this.scrollToBottomRefresh = false this.scrollToBottomRefresh = false
this.replyMsgAutoMention = false
this.allMsgs = this.allMsgList this.allMsgs = this.allMsgList
this.errorId = 0 this.errorId = 0
// //
@ -3030,6 +3033,7 @@ export default {
}, },
onReply(type) { onReply(type) {
this.replyMsgAutoMention = true
this.setQuote(this.operateItem.id, type) this.setQuote(this.operateItem.id, type)
this.inputFocus() this.inputFocus()
}, },