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> </ul>
</div> </div>
<ul class="chat-emoji-menu"> <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'"> <li :class="{active: type === 'emosearch'}" @click="type='emosearch'">
<i class="taskfont">&#xe6f8;</i> <i class="taskfont">&#xe6f8;</i>
</li> </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)"> <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"/> <img :title="item.name" :alt="item.name" :src="item.src"/>
</li> </li>
@ -51,9 +51,7 @@ export default {
}; };
}, },
mounted() { mounted() {
if (this.searchKey) { //
this.emosearchKey = this.searchKey;
}
}, },
watch: { watch: {
type() { type() {
@ -61,6 +59,12 @@ export default {
}, },
emosearchKey() { emosearchKey() {
this.onEmosearch() this.onEmosearch()
},
searchKey: {
handler(val) {
this.emosearchKey = val;
},
immediate: true
} }
}, },
computed: { computed: {

View File

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