perf: 点击会话消息头像@

This commit is contained in:
kuaifan 2023-03-04 15:01:30 +08:00
parent abe953f234
commit 1f7fca0c78
4 changed files with 46 additions and 5 deletions

View File

@ -295,17 +295,16 @@
onClickOpen() { onClickOpen() {
if (this.clickOpenDialog) { if (this.clickOpenDialog) {
this.openDialog() this.openDialog()
} else {
this.$emit('open-dialog', this.userid)
} }
}, },
openDialog() { openDialog() {
this.$store.dispatch("showSpinner", 600)
this.$store.dispatch("openDialogUserid", this.userid).then(_ => { this.$store.dispatch("openDialogUserid", this.userid).then(_ => {
this.goForward({name: 'manage-messenger'}) this.goForward({name: 'manage-messenger'})
}).catch(({msg}) => { }).catch(({msg}) => {
$A.modalError(msg) $A.modalError(msg)
}).finally(_ => {
this.$store.dispatch("hiddenSpinner")
}); });
}, },

View File

@ -1022,6 +1022,13 @@ export default {
} }
}, },
addMention(data) {
if (!this.quill) {
return;
}
this.quill.getModule("mention").insertItem(data, true);
},
getProjectId() { getProjectId() {
let object = null; let object = null;
if (this.dialogId > 0) { if (this.dialogId > 0) {

View File

@ -22,7 +22,12 @@
</div> </div>
<template v-else> <template v-else>
<div class="dialog-avatar"> <div class="dialog-avatar">
<UserAvatar :userid="source.userid" tooltip-disabled :click-open-dialog="dialogData.type == 'group'" :size="30"/> <UserAvatar
v-longpress="{callback: onMention, delay: 300}"
@open-dialog="onOpenDialog"
:userid="source.userid"
:size="30"
tooltip-disabled/>
</div> </div>
<DialogView <DialogView
:msg-data="source" :msg-data="source"
@ -48,10 +53,12 @@
<script> <script>
import {mapState} from "vuex"; import {mapState} from "vuex";
import DialogView from "./DialogView"; import DialogView from "./DialogView";
import longpress from "../../../directives/longpress";
export default { export default {
name: "DialogItem", name: "DialogItem",
components: {DialogView}, components: {DialogView},
directives: {longpress},
props: { props: {
source: { source: {
type: Object, type: Object,
@ -169,6 +176,21 @@ export default {
}) })
}, },
onOpenDialog(userid) {
if (this.dialogData.type != 'group') {
return
}
this.$store.dispatch("openDialogUserid", userid).then(_ => {
this.goForward({name: 'manage-messenger'})
}).catch(({msg}) => {
$A.modalError(msg)
});
},
onMention() {
this.dispatch("on-mention", this.source)
},
onLongpress(e) { onLongpress(e) {
this.dispatch("on-longpress", e) this.dispatch("on-longpress", e)
}, },

View File

@ -125,6 +125,7 @@
@range="onRange" @range="onRange"
@totop="onPrevPage" @totop="onPrevPage"
@on-mention="onMention"
@on-longpress="onLongpress" @on-longpress="onLongpress"
@on-view-reply="onViewReply" @on-view-reply="onViewReply"
@on-view-text="onViewText" @on-view-text="onViewText"
@ -569,7 +570,8 @@ export default {
'cacheDialogs', 'cacheDialogs',
'wsOpenNum', 'wsOpenNum',
'touchBackInProgress', 'touchBackInProgress',
'dialogIns' 'dialogIns',
'cacheUserBasic'
]), ]),
...mapGetters(['isLoad']), ...mapGetters(['isLoad']),
@ -1777,6 +1779,17 @@ export default {
} }
}, },
onMention(data) {
const user = this.cacheUserBasic.find(({userid}) => userid == data.userid);
if (user) {
this.$refs.input.addMention({
denotationChar: "@",
id: user.userid,
value: user.nickname,
})
}
},
onLongpress({event, el, msgData}) { onLongpress({event, el, msgData}) {
this.operateVisible = this.operateItem.id === msgData.id; this.operateVisible = this.operateItem.id === msgData.id;
this.operateItem = $A.isJson(msgData) ? msgData : {}; this.operateItem = $A.isJson(msgData) ? msgData : {};