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

View File

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

View File

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

View File

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