mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-16 05:52:49 +00:00
perf: 优化消息输入框内选择文本
This commit is contained in:
parent
28bc303fcf
commit
5e4f99da6c
@ -7,7 +7,8 @@
|
|||||||
@dragover.prevent="chatDragOver(true, $event)"
|
@dragover.prevent="chatDragOver(true, $event)"
|
||||||
@dragleave.prevent="chatDragOver(false, $event)"
|
@dragleave.prevent="chatDragOver(false, $event)"
|
||||||
@touchstart="onTouchStart"
|
@touchstart="onTouchStart"
|
||||||
@touchmove="onTouchMove">
|
@touchmove="onTouchMove"
|
||||||
|
@touchend="onTouchEnd">
|
||||||
<!--顶部导航-->
|
<!--顶部导航-->
|
||||||
<div class="dialog-nav" :style="navStyle">
|
<div class="dialog-nav" :style="navStyle">
|
||||||
<slot name="head">
|
<slot name="head">
|
||||||
@ -662,11 +663,13 @@ export default {
|
|||||||
msgReady: false, // 消息准备完成
|
msgReady: false, // 消息准备完成
|
||||||
unreadMsgId: 0, // 最早未读消息id
|
unreadMsgId: 0, // 最早未读消息id
|
||||||
toBottomReGetMsg: false, // 滚动到底部重新获取消息
|
toBottomReGetMsg: false, // 滚动到底部重新获取消息
|
||||||
|
selectionRange: false, // 是否选择文本
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
this.msgSubscribe = Store.subscribe('dialogMsgChange', this.onMsgChange);
|
this.msgSubscribe = Store.subscribe('dialogMsgChange', this.onMsgChange);
|
||||||
|
document.addEventListener('selectionchange', this.onSelectionchange);
|
||||||
},
|
},
|
||||||
|
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
@ -677,6 +680,7 @@ export default {
|
|||||||
this.msgSubscribe.unsubscribe();
|
this.msgSubscribe.unsubscribe();
|
||||||
this.msgSubscribe = null;
|
this.msgSubscribe = null;
|
||||||
}
|
}
|
||||||
|
document.removeEventListener('selectionchange', this.onSelectionchange);
|
||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
@ -1166,9 +1170,6 @@ export default {
|
|||||||
if (tail <= 55) {
|
if (tail <= 55) {
|
||||||
requestAnimationFrame(this.onToBottom)
|
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() {
|
getTempId() {
|
||||||
return this.tempId++
|
return this.tempId++
|
||||||
},
|
},
|
||||||
@ -1668,6 +1674,10 @@ export default {
|
|||||||
|
|
||||||
onTouchStart(e) {
|
onTouchStart(e) {
|
||||||
this.wrapperStart = null;
|
this.wrapperStart = null;
|
||||||
|
if (this.selectionRange) {
|
||||||
|
this.wrapperStart = window.scrollY
|
||||||
|
return
|
||||||
|
}
|
||||||
if (this.$refs.scroller.$el.contains(e.target)) {
|
if (this.$refs.scroller.$el.contains(e.target)) {
|
||||||
// 聊天内容区域
|
// 聊天内容区域
|
||||||
this.wrapperStart = Object.assign(this.scrollInfo(), {
|
this.wrapperStart = Object.assign(this.scrollInfo(), {
|
||||||
@ -1692,6 +1702,9 @@ export default {
|
|||||||
|
|
||||||
onTouchMove(e) {
|
onTouchMove(e) {
|
||||||
if (this.footerPaddingBottom > 0 || (this.windowPortrait && this.windowScrollY > 0)) {
|
if (this.footerPaddingBottom > 0 || (this.windowPortrait && this.windowScrollY > 0)) {
|
||||||
|
if (typeof this.wrapperStart === 'number') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (this.wrapperStart === null) {
|
if (this.wrapperStart === null) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
return;
|
return;
|
||||||
@ -1710,6 +1723,12 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onTouchEnd() {
|
||||||
|
if ($A.isIos()) {
|
||||||
|
$A.scrollToView(this.$refs.footer)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
pasteSend() {
|
pasteSend() {
|
||||||
if (this.__paste_send_index) {
|
if (this.__paste_send_index) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user