diff --git a/docker-compose.yml b/docker-compose.yml index b89aba407..50a0ab3ee 100755 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -150,7 +150,7 @@ services: approve: container_name: "dootask-approve-${APP_ID}" - image: "hitosea2020/go-approve:0.1.1" + image: "hitosea2020/go-approve:0.1.2" environment: TZ: "Asia/Shanghai" MYSQL_HOST: "${DB_HOST}" diff --git a/resources/assets/js/pages/manage/components/DialogWrapper.vue b/resources/assets/js/pages/manage/components/DialogWrapper.vue index f8b3c27df..4aabf4995 100644 --- a/resources/assets/js/pages/manage/components/DialogWrapper.vue +++ b/resources/assets/js/pages/manage/components/DialogWrapper.vue @@ -652,9 +652,18 @@ export default { } }, + mounted() { + this.msgSubscribe = Store.subscribe('dialogMsgUpdate', this.updateMsg); + }, + beforeDestroy() { this.$store.dispatch('forgetInDialog', this._uid) this.$store.dispatch('closeDialog', this.dialogId) + // + if (this.msgSubscribe) { + this.msgSubscribe.unsubscribe(); + this.msgSubscribe = null; + } }, computed: { @@ -1334,6 +1343,17 @@ export default { this.sendMsg(`

${item.label}

`) }, + updateMsg(data) { + const item = this.allMsgs.find(({type, id}) => type == "text" && id == data.id) + if (item) { + const {tail} = this.scrollInfo() + item.msg.text = data.text + if (tail <= 45) { + this.onToBottom() + } + } + }, + getTempId() { return this.tempId++ }, diff --git a/resources/assets/js/store/actions.js b/resources/assets/js/store/actions.js index a89d984b0..c9503c606 100644 --- a/resources/assets/js/store/actions.js +++ b/resources/assets/js/store/actions.js @@ -2852,14 +2852,22 @@ export default { streamDialogMsg({state, dispatch}, streamUrl) { const sse = new EventSource(streamUrl) sse.addEventListener("update", e => { - const item = state.dialogMsgs.find(({type, id}) => type == "text" && id == e.lastEventId) - if (item) { - item.msg.text = e.data - } + Store.set('dialogMsgUpdate', { + id: e.lastEventId, + text: e.data + }); }) - sse.addEventListener("done", e => { + sse.addEventListener("done", _ => { + const index = state.dialogSseList.findIndex(item => sse === item.sse) + if (index > -1) { + state.dialogSseList.splice(index, 1) + } sse.close() }) + state.dialogSseList.push({sse, time: $A.Time()}) + if (state.dialogSseList.length > 10) { + state.dialogSseList.shift().sse.close() + } }, /** *****************************************************************************************/ diff --git a/resources/assets/js/store/state.js b/resources/assets/js/store/state.js index 2da281f87..a621a1804 100644 --- a/resources/assets/js/store/state.js +++ b/resources/assets/js/store/state.js @@ -110,6 +110,7 @@ export default { dialogHistory: [], dialogDraftTimer: {}, dialogMsgTransfer: {time: 0}, + dialogSseList: [], // 搜索关键词(主要用于移动端判断滑动返回) messengerSearchKey: {dialog: '', contacts: ''},