From fa9c3b4f2f19a290f023eb2480385c11dc008ac9 Mon Sep 17 00:00:00 2001 From: Pang Date: Sat, 16 Dec 2023 22:19:55 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E8=BE=93=E5=85=A5?= =?UTF-8?q?=E7=A9=BA=E6=8D=A2=E8=A1=8C=E6=97=B6=E7=9A=84=E5=85=BC=E5=AE=B9?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/manage/components/ChatInput/index.vue | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/resources/assets/js/pages/manage/components/ChatInput/index.vue b/resources/assets/js/pages/manage/components/ChatInput/index.vue index 973c0ef92..b53a26f5c 100755 --- a/resources/assets/js/pages/manage/components/ChatInput/index.vue +++ b/resources/assets/js/pages/manage/components/ChatInput/index.vue @@ -405,11 +405,8 @@ export default { }, editorStyle() { - const {wrapperWidth, editorHeight, value} = this; + const {wrapperWidth, editorHeight} = this; const style = {}; - if (value.length < 10) { - style.height = '30px'; - } if (wrapperWidth > 0 && editorHeight > 0 && (wrapperWidth < 280 || editorHeight > 40)) { @@ -515,7 +512,7 @@ export default { this.quill.setText('') } } - this.$store.dispatch("saveDialogDraft", {id: this.dialogId, extra_draft_content: val}) + this.$store.dispatch("saveDialogDraft", {id: this.dialogId, extra_draft_content: this.filterInvalidLine(val)}) }, // Watch disabled change @@ -752,8 +749,6 @@ export default { this.quill.deleteText(this.maxlength, this.quill.getLength()); } let html = this.$refs.editor.firstChild.innerHTML - html = html.replace(/^(

\s*<\/p>)+|(

\s*<\/p>)+$/gi, '') - html = html.replace(/^(

<\/p>)+|(

<\/p>)+$/gi, '') this.updateEmojiQuick(html) this._content = html this.$emit('input', this._content) @@ -1071,6 +1066,9 @@ export default { onSend(type) { setTimeout(_ => { + if (this.filterInvalidLine(this.value) === '') { + return + } this.hidePopover('send') this.rangeIndex = 0 this.clearSearchKey() @@ -1659,6 +1657,11 @@ export default { } return false }, + + filterInvalidLine(content) { + let value = (content + '').replace(/^(

\s*<\/p>)+|(

\s*<\/p>)+$/gi, '') + return value.replace(/^(

<\/p>)+|(

<\/p>)+$/gi, '') + }, } }