perf: 移动客户端群消息通知加上群名称

This commit is contained in:
kuaifan 2022-07-19 15:50:08 +08:00
parent 444afc30e4
commit 4c6b58cbd5
3 changed files with 39 additions and 8 deletions

View File

@ -6,7 +6,7 @@
@click.stop="onClick"
@touchstart="onTouchstart"
@touchmove="onTouchmove">
<UserAvatar :userid="userid" :size="40" show-name/>
<UserAvatar :userid="userid" :size="40" show-name :name-text="title"/>
<div class="notification-desc">{{desc}}</div>
</div>
</transition>
@ -18,6 +18,7 @@ export default {
data() {
return {
userid: 0,
title: '',
desc: '',
duration: 6000,
callback: null,
@ -40,6 +41,7 @@ export default {
return;
}
this.userid = config.userid || 0;
this.title = config.title || "";
this.desc = config.desc || "";
this.duration = typeof config.duration === "number" ? config.duration : 6000;
this.callback = typeof config.callback === "function" ? config.callback : null;

View File

@ -27,7 +27,7 @@
</EAvatar>
</div>
<template v-if="showName">
<div class="avatar-name" :style="nameStyle">{{user.nickname}}</div>
<div class="avatar-name" :style="nameStyle">{{nameText || user.nickname}}</div>
</template>
</div>
</ETooltip>
@ -56,6 +56,10 @@
type: Boolean,
default: false
},
nameText: {
type: String,
default: null // showName = true
},
tooltipDisabled: {
type: Boolean,
default: false

View File

@ -485,6 +485,7 @@ export default {
...mapState([
'userInfo',
'userIsAdmin',
'cacheUserBasic',
'cacheTasks',
'cacheDialogs',
'cacheProjects',
@ -933,7 +934,7 @@ export default {
return; //
}
//
const {id, dialog_id, type, msg, userid} = data;
const {id, dialog_id, dialog_type, type, msg, userid} = data;
if (userid == this.userId) {
return; //
}
@ -949,11 +950,37 @@ export default {
return;
}
this.__notificationId = id;
const notificationFunc = (title) => {
const notificationFuncA = (title) => {
if (dialog_type === 'group') {
let tempUser = this.cacheUserBasic.find(item => item.userid == userid);
if (tempUser) {
notificationFuncB(`${title} (${tempUser.nickname})`)
} else {
this.$store.dispatch("call", {
url: 'users/basic',
data: {
userid: [userid]
},
checkRole: false
}).then(({data}) => {
tempUser = data.find(item => item.userid == userid);
if (tempUser) {
notificationFuncB(`${title} (${tempUser.nickname})`)
}
}).catch(_ => {
notificationFuncB(title)
});
}
} else {
notificationFuncB(title)
}
}
const notificationFuncB = (title) => {
if (this.__notificationId === id) {
if (this.$isEEUiApp) {
this.$refs.mobileNotification.open({
userid: userid,
title,
desc: body,
callback: () => {
this.goForward({name: 'manage-messenger'});
@ -975,11 +1002,9 @@ export default {
}
const dialog = this.cacheDialogs.find((item) => item.id == dialog_id);
if (dialog) {
notificationFunc(dialog.name)
notificationFuncA(dialog.name)
} else {
this.$store.dispatch("getDialogOne", dialog_id).then(({data}) => {
notificationFunc(data.name)
}).catch(() => {})
this.$store.dispatch("getDialogOne", dialog_id).then(({data}) => notificationFuncA(data.name)).catch(() => {})
}
},