perf: 优化消息选择文本

This commit is contained in:
kuaifan 2024-09-18 23:17:18 +08:00
parent b7da689955
commit ccc60dfd77
4 changed files with 27 additions and 9 deletions

View File

@ -44,6 +44,7 @@
:hide-forward="hideForward"
:operate-visible="operateVisible"
:operate-action="operateVisible && source.id === operateItem.id"
:pointer-mouse="pointerMouse"
:is-right-msg="isRightMsg"
@on-longpress="onLongpress"
@on-view-reply="onViewReply"
@ -91,6 +92,10 @@ export default {
return {}
}
},
pointerMouse: {
type: Boolean,
default: false
},
simpleView: {
type: Boolean,
default: false

View File

@ -336,6 +336,10 @@ export default {
type: Boolean,
default: false
},
pointerMouse: {
type: Boolean,
default: false
},
isRightMsg: {
type: Boolean,
default: false
@ -389,7 +393,7 @@ export default {
},
viewClass() {
const {msgData, operateAction, operateEnter} = this;
const {msgData, operateAction, operateEnter, pointerMouse} = this;
const array = [];
if (msgData.type) {
array.push(msgData.type)
@ -400,6 +404,9 @@ export default {
array.push('operate-enter')
}
}
if (pointerMouse && array.indexOf('pointer-mouse') === -1) {
array.push('pointer-mouse')
}
return array
},

View File

@ -8,7 +8,8 @@
@dragleave.prevent="chatDragOver(false, $event)"
@touchstart="onTouchStart"
@touchmove="onTouchMove"
@touchend="onTouchEnd">
@touchend="onTouchEnd"
@pointerover="onPointerover">
<!--顶部导航-->
<div ref="nav" class="dialog-nav">
<slot name="head">
@ -188,7 +189,7 @@
:data-sources="allMsgs"
:data-component="msgItem"
:extra-props="{dialogData, operateVisible, operateItem, isMyDialog, msgId, unreadOne, scrollIng, readEnabled}"
:extra-props="{dialogData, operateVisible, operateItem, pointerMouse, isMyDialog, msgId, unreadOne, scrollIng, readEnabled}"
:estimate-size="dialogData.type=='group' ? 105 : 77"
:keeps="dialogMsgKeep"
:disabled="scrollDisabled"
@ -783,6 +784,7 @@ export default {
recordState: '',
wrapperStart: null,
pointerMouse: false,
scrollTail: 0,
scrollOffset: 0,
@ -941,9 +943,9 @@ export default {
const array = [];
array.push(...this.dialogMsgList.filter(item => this.msgFilter(item)));
if (this.msgId > 0) {
const msgItem = this.dialogMsgs.find(item => item.id == this.msgId)
if (msgItem) {
array.unshift(msgItem)
const dialogMsg = this.dialogMsgs.find(item => item.id == this.msgId)
if (dialogMsg) {
array.unshift(dialogMsg)
}
}
if (this.tempMsgList.length > 0) {
@ -1441,7 +1443,7 @@ export default {
},
operateVisible(val) {
if (!val) {
if (!val && !this.pointerMouse) {
document.getSelection().removeAllRanges();
}
},
@ -2085,6 +2087,10 @@ export default {
}
},
onPointerover({pointerType}) {
this.pointerMouse = pointerType === 'mouse';
},
pasteSend() {
if (this.__paste_send_index) {
return;

View File

@ -2366,7 +2366,7 @@ body.window-touch {
}
}
}
&.operate-enter {
&.pointer-mouse {
.dialog-head {
.dialog-content {
user-select: text;
@ -2541,7 +2541,7 @@ body.window-portrait {
}
}
}
&.operate-enter {
&.pointer-mouse {
.dialog-head {
.dialog-content {
a, img {