diff --git a/resources/assets/js/pages/manage/components/DialogWrapper.vue b/resources/assets/js/pages/manage/components/DialogWrapper.vue index 556006bbd..7185751df 100644 --- a/resources/assets/js/pages/manage/components/DialogWrapper.vue +++ b/resources/assets/js/pages/manage/components/DialogWrapper.vue @@ -799,11 +799,14 @@ export default { }, mounted() { + this.subMsgListener() this.msgSubscribe = Store.subscribe('dialogMsgChange', this.onMsgChange); document.addEventListener('selectionchange', this.onSelectionchange); }, beforeDestroy() { + this.subMsgListener(true) + // this.$store.dispatch('forgetInDialog', this._uid) this.$store.dispatch('closeDialog', this.dialogId) // @@ -1427,6 +1430,29 @@ export default { }, methods: { + /** + * 订阅消息(用于独立窗口) + * @param unsubscribe + */ + subMsgListener(unsubscribe = false) { + if (!$A.isSubElectron) { + return + } + if (unsubscribe) { + this.$store.dispatch('websocketMsgListener', 'DialogWrapper') + } else { + this.$store.dispatch('websocketMsgListener', { + name: 'DialogWrapper', + callback: (msgDetail) => { + const {type, mode, data} = msgDetail; + if (type === 'dialog' && mode === 'add') { + this.tempMsgs.push(data) + } + } + }) + } + }, + /** * 发送消息 * @param text diff --git a/resources/assets/js/store/actions.js b/resources/assets/js/store/actions.js index ba121283e..7fa7fedfc 100644 --- a/resources/assets/js/store/actions.js +++ b/resources/assets/js/store/actions.js @@ -3878,6 +3878,10 @@ export default { * @param params {name, callback} */ websocketMsgListener({state}, params) { + if (typeof params === "string") { + state.wsListener[params] && delete state.wsListener[params]; + return; + } const {name, callback} = params; if (typeof callback === "function") { state.wsListener[name] = callback;