From 4c6b58cbd53e6f6c0c32584c7a1262b86c09b32a Mon Sep 17 00:00:00 2001 From: kuaifan Date: Tue, 19 Jul 2022 15:50:08 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E7=A7=BB=E5=8A=A8=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E7=AB=AF=E7=BE=A4=E6=B6=88=E6=81=AF=E9=80=9A=E7=9F=A5=E5=8A=A0?= =?UTF-8?q?=E4=B8=8A=E7=BE=A4=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../js/components/Mobile/Notification.vue | 4 +- resources/assets/js/components/UserAvatar.vue | 6 ++- resources/assets/js/pages/manage.vue | 37 ++++++++++++++++--- 3 files changed, 39 insertions(+), 8 deletions(-) diff --git a/resources/assets/js/components/Mobile/Notification.vue b/resources/assets/js/components/Mobile/Notification.vue index 1498291cf..e1f7e682a 100644 --- a/resources/assets/js/components/Mobile/Notification.vue +++ b/resources/assets/js/components/Mobile/Notification.vue @@ -6,7 +6,7 @@ @click.stop="onClick" @touchstart="onTouchstart" @touchmove="onTouchmove"> - +
{{desc}}
@@ -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; diff --git a/resources/assets/js/components/UserAvatar.vue b/resources/assets/js/components/UserAvatar.vue index a93dbce43..c34139fb3 100755 --- a/resources/assets/js/components/UserAvatar.vue +++ b/resources/assets/js/components/UserAvatar.vue @@ -27,7 +27,7 @@ @@ -56,6 +56,10 @@ type: Boolean, default: false }, + nameText: { + type: String, + default: null // showName = true 时有效,留空就显示会员昵称 + }, tooltipDisabled: { type: Boolean, default: false diff --git a/resources/assets/js/pages/manage.vue b/resources/assets/js/pages/manage.vue index 773ad7c41..b27fc42d3 100644 --- a/resources/assets/js/pages/manage.vue +++ b/resources/assets/js/pages/manage.vue @@ -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(() => {}) } },