From 5e4f99da6c6bcab8422d0091d210d709b58ce9bf Mon Sep 17 00:00:00 2001 From: Pang Date: Sun, 17 Dec 2023 16:26:58 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E8=BE=93=E5=85=A5=E6=A1=86=E5=86=85=E9=80=89=E6=8B=A9=E6=96=87?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/manage/components/DialogWrapper.vue | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/resources/assets/js/pages/manage/components/DialogWrapper.vue b/resources/assets/js/pages/manage/components/DialogWrapper.vue index d5f3e1d00..ba3695f4e 100644 --- a/resources/assets/js/pages/manage/components/DialogWrapper.vue +++ b/resources/assets/js/pages/manage/components/DialogWrapper.vue @@ -7,7 +7,8 @@ @dragover.prevent="chatDragOver(true, $event)" @dragleave.prevent="chatDragOver(false, $event)" @touchstart="onTouchStart" - @touchmove="onTouchMove"> + @touchmove="onTouchMove" + @touchend="onTouchEnd">
@@ -662,11 +663,13 @@ export default { msgReady: false, // 消息准备完成 unreadMsgId: 0, // 最早未读消息id toBottomReGetMsg: false, // 滚动到底部重新获取消息 + selectionRange: false, // 是否选择文本 } }, mounted() { this.msgSubscribe = Store.subscribe('dialogMsgChange', this.onMsgChange); + document.addEventListener('selectionchange', this.onSelectionchange); }, beforeDestroy() { @@ -677,6 +680,7 @@ export default { this.msgSubscribe.unsubscribe(); this.msgSubscribe = null; } + document.removeEventListener('selectionchange', this.onSelectionchange); }, computed: { @@ -1166,9 +1170,6 @@ export default { if (tail <= 55) { requestAnimationFrame(this.onToBottom) } - if (this.$refs.input.isFocus) { - $A.scrollToView(this.$refs.footer) - } } }, @@ -1431,6 +1432,11 @@ export default { } }, + onSelectionchange() { + const selectionType = window.getSelection().type; + this.selectionRange = selectionType === "Range" + }, + getTempId() { return this.tempId++ }, @@ -1668,6 +1674,10 @@ export default { onTouchStart(e) { this.wrapperStart = null; + if (this.selectionRange) { + this.wrapperStart = window.scrollY + return + } if (this.$refs.scroller.$el.contains(e.target)) { // 聊天内容区域 this.wrapperStart = Object.assign(this.scrollInfo(), { @@ -1692,6 +1702,9 @@ export default { onTouchMove(e) { if (this.footerPaddingBottom > 0 || (this.windowPortrait && this.windowScrollY > 0)) { + if (typeof this.wrapperStart === 'number') { + return; + } if (this.wrapperStart === null) { e.preventDefault(); return; @@ -1710,6 +1723,12 @@ export default { } }, + onTouchEnd() { + if ($A.isIos()) { + $A.scrollToView(this.$refs.footer) + } + }, + pasteSend() { if (this.__paste_send_index) { return;