From cf5e126eaace88ec8bfc2ba780b8342fc4338a62 Mon Sep 17 00:00:00 2001 From: kuaifan Date: Fri, 14 Mar 2025 19:53:00 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E5=BC=95=E7=94=A8?= =?UTF-8?q?=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../manage/components/ChatInput/index.vue | 40 ++++++++++--------- .../pages/manage/components/DialogUpload.vue | 10 ++--- .../pages/manage/components/DialogWrapper.vue | 18 +++++---- .../assets/js/pages/manage/messenger.vue | 2 +- resources/assets/js/store/actions.js | 19 +++++++++ resources/assets/js/store/getters.js | 12 +++++- resources/assets/js/store/mutations.js | 34 ++++++++++++++-- resources/assets/js/store/state.js | 3 +- 8 files changed, 101 insertions(+), 37 deletions(-) diff --git a/resources/assets/js/pages/manage/components/ChatInput/index.vue b/resources/assets/js/pages/manage/components/ChatInput/index.vue index d3d427c74..ecbeb9823 100755 --- a/resources/assets/js/pages/manage/components/ChatInput/index.vue +++ b/resources/assets/js/pages/manage/components/ChatInput/index.vue @@ -548,7 +548,7 @@ export default { 'isModKey', ]), - ...mapGetters(['getDialogDraft']), + ...mapGetters(['getDialogDraft', 'getDialogQuote']), isEnterSend({cacheKeyboard}) { if (this.$isEEUiApp) { @@ -687,16 +687,16 @@ export default { return this.dialogId > 0 ? (this.cacheDialogs.find(({id}) => id == this.dialogId) || {}) : {}; }, - quoteUpdate() { - return this.dialogData.extra_quote_type === 'update' + draftData() { + return this.getDialogDraft(this.dialogId)?.content || '' }, quoteData() { - const {extra_quote_id} = this.dialogData; - if (extra_quote_id) { - return this.dialogMsgs.find(item => item.id === extra_quote_id) - } - return null; + return this.getDialogQuote(this.dialogId)?.content || null + }, + + quoteUpdate() { + return this.getDialogQuote(this.dialogId)?.type === 'update' }, chatInputBoxStyle({iOSDevices, fullInput, viewportHeight}) { @@ -705,10 +705,6 @@ export default { style.height = Math.max(100, viewportHeight - 70) + 'px' } return style - }, - - inputDraft() { - return this.getDialogDraft(this.dialogId) } }, watch: { @@ -750,7 +746,7 @@ export default { this.loadInputDraft() }, - inputDraft() { + draftData() { if (this.isFocus) { return } @@ -1214,12 +1210,12 @@ export default { }, loadInputDraft() { - if (this.simpleMode || !this.inputDraft) { + if (this.simpleMode || !this.draftData) { this.$emit('input', '') return } this.pasteClean = false - this.$emit('input', this.inputDraft) + this.$emit('input', this.draftData) this.$nextTick(_ => this.pasteClean = true) }, @@ -1718,10 +1714,18 @@ export default { }, setQuote(id, type = 'reply') { - this.dialogId > 0 && this.$store.dispatch("saveDialog", { + if (this.dialogId <= 0) { + return + } + const content = this.dialogMsgs.find(item => item.id == id && item.dialog_id == this.dialogId) + if (!content) { + this.$store.dispatch("removeDialogQuote", this.dialogId); + return + } + this.$store.dispatch("saveDialogQuote", { id: this.dialogId, - extra_quote_id: id, - extra_quote_type: type === 'update' ? 'update' : 'reply' + type: type === 'update' ? 'update' : 'reply', + content }); }, diff --git a/resources/assets/js/pages/manage/components/DialogUpload.vue b/resources/assets/js/pages/manage/components/DialogUpload.vue index 11ef27902..b2ed3a0ab 100644 --- a/resources/assets/js/pages/manage/components/DialogUpload.vue +++ b/resources/assets/js/pages/manage/components/DialogUpload.vue @@ -18,7 +18,7 @@