diff --git a/resources/assets/js/pages/manage.vue b/resources/assets/js/pages/manage.vue index 928520e2..a5606f0a 100644 --- a/resources/assets/js/pages/manage.vue +++ b/resources/assets/js/pages/manage.vue @@ -201,7 +201,7 @@ export default { }, dialogMsgPush(data) { if (this.natificationHidden && this.natificationReady) { - const {userid, type, msg} = data; + const {id, dialog_id, type, msg} = data; let body = ''; switch (type) { case 'text': @@ -213,20 +213,26 @@ export default { default: return; } - this.$store.dispatch("getUserBasic", { - userid: userid, - success: (user) => { - this.notificationClass.replaceTitle(user.nickname); - this.notificationClass.replaceOptions({ - icon: user.userimg, - body: body, - data: data, - tag: "dialog", - requireInteraction: true - }); - this.notificationClass.userAgreed(); - } + this._notificationId = id; + this.notificationClass.replaceOptions({ + icon: $A.serverUrl('images/logo.png'), + body: body, + data: data, + tag: "dialog", + requireInteraction: true }); + let dialog = this.dialogs.find((item) => item.id == dialog_id); + if (dialog) { + this.notificationClass.replaceTitle(dialog.name); + this.notificationClass.userAgreed(); + } else { + this.$store.dispatch("getDialogOne", dialog_id).then(({data}) => { + if (this._notificationId === id) { + this.notificationClass.replaceTitle(data.name); + this.notificationClass.userAgreed(); + } + }) + } } } }, @@ -323,6 +329,7 @@ export default { if (this.notificationClass.support) { this.notificationClass.notificationEvent({ onclick: ({target}) => { + console.log("[Notification] Click", target); this.notificationClass.close(); window.focus(); // diff --git a/resources/assets/js/store/actions.js b/resources/assets/js/store/actions.js index fee947bf..b10c2e23 100644 --- a/resources/assets/js/store/actions.js +++ b/resources/assets/js/store/actions.js @@ -1093,19 +1093,30 @@ export default { }, /** - * 获取会话基础信息 + * 获取单个会话信息 * @param state * @param dispatch * @param dialog_id + * @returns {Promise} */ getDialogOne({state, dispatch}, dialog_id) { - dispatch("call", { - url: 'dialog/one', - data: { - dialog_id, - }, - }).then(result => { - dispatch("saveDialog", result.data); + return new Promise(function (resolve, reject) { + if (state.method.runNum(dialog_id) === 0) { + reject({msg: 'Parameter error'}); + return; + } + dispatch("call", { + url: 'dialog/one', + data: { + dialog_id, + }, + }).then(result => { + dispatch("saveDialog", result.data); + resolve(result); + }).catch(e => { + console.error(e); + reject(e); + }); }); }, @@ -1381,8 +1392,6 @@ export default { (function (msg) { const {mode, data} = msg; const {dialog_id} = data; - // 更新消息列表 - dispatch("saveDialogMsg", data) if (mode === "add" || mode === "chat") { // 新增任务消息数量 dispatch("increaseTaskMsgNum", dialog_id); @@ -1399,6 +1408,8 @@ export default { } state.dialogMsgPush = data; } + // 更新消息列表 + dispatch("saveDialogMsg", data) // 更新最后消息 dispatch("updateDialogLastMsg", data); })(msgDetail);