perf: 优化表情发送后搜索关键词逻辑

This commit is contained in:
kuaifan 2022-11-18 16:07:31 +08:00
parent 374d3b85cf
commit c1381d5f67
2 changed files with 27 additions and 8 deletions

View File

@ -14,12 +14,12 @@
</ul>
</div>
<ul class="chat-emoji-menu">
<li :class="{active: type === 'emoji'}" @click="type='emoji'">
<span class="no-dark-content">&#128512;</span>
</li>
<li :class="{active: type === 'emosearch'}" @click="type='emosearch'">
<i class="taskfont">&#xe6f8;</i>
</li>
<li :class="{active: type === 'emoji'}" @click="type='emoji'">
<span class="no-dark-content">&#128512;</span>
</li>
<li v-for="item in emoticonList" :class="{active: type === 'emoticon' && emoticonPath == item.path}" @click="onEmoticon(item.path)">
<img :title="item.name" :alt="item.name" :src="item.src"/>
</li>
@ -51,9 +51,7 @@ export default {
};
},
mounted() {
if (this.searchKey) {
this.emosearchKey = this.searchKey;
}
//
},
watch: {
type() {
@ -61,6 +59,12 @@ export default {
},
emosearchKey() {
this.onEmosearch()
},
searchKey: {
handler(val) {
this.emosearchKey = val;
},
immediate: true
}
},
computed: {

View File

@ -425,7 +425,19 @@ export default {
showEmoji(val) {
if (val) {
let text = this.value.replace(/&nbsp;/g," ")
text = text.replace(/<[^>]+>/g, "")
if (text
&& text.indexOf(" ") === -1
&& text.length >= 1
&& text.length <= 4) {
this.emojiQuickKey = text;
} else {
this.emojiQuickKey = "";
}
//
this.showMore = false;
this.emojiQuickShow = false;
if (this.quill) {
const range = this.quill.selection.savedRange;
this.rangeIndex = range ? range.index : 0
@ -712,7 +724,6 @@ export default {
&& text.length <= 4
&& $A.isArray(window.emoticonData)) {
//
this.emojiQuickKey = text;
this.emojiQuickItems = [];
let baseUrl = $A.apiUrl("../images/emoticon")
window.emoticonData.some(data => {
@ -888,8 +899,9 @@ export default {
},
hidePopover() {
this.showEmoji = false;
this.showMore = false;
this.showEmoji = false;
this.emojiQuickShow = false;
},
onClickCover() {
@ -942,6 +954,9 @@ export default {
}
} else if (item.type === 'emoticon') {
this.$emit('on-send', `<img class="emoticon" data-asset="${item.asset}" data-name="${item.name}" src="${item.src}"/>`)
if (item.asset === "emosearch") {
this.$emit('input', "")
}
if (this.windowLarge) {
this.showEmoji = false;
}