From 2c373c388c1e25f25973421d6e8a8bee5e2e007e Mon Sep 17 00:00:00 2001 From: kuaifan Date: Mon, 6 Jun 2022 11:08:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BC=9A=E8=AF=9D=E8=B7=AF?= =?UTF-8?q?=E7=94=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/assets/js/app.js | 8 -- .../assets/js/components/Mobile/Tabbar.vue | 6 +- resources/assets/js/components/UserAvatar.vue | 10 +- resources/assets/js/pages/manage.vue | 26 ++-- .../pages/manage/components/DialogModal.vue | 21 ++-- .../pages/manage/components/DialogWrapper.vue | 58 ++++----- .../pages/manage/components/ProjectDialog.vue | 39 +++--- .../pages/manage/components/ProjectPanel.vue | 5 - .../js/pages/manage/components/TaskDetail.vue | 2 +- .../assets/js/pages/manage/messenger.vue | 43 +++---- resources/assets/js/pages/manage/project.vue | 5 +- resources/assets/js/routes.js | 2 +- resources/assets/js/store/actions.js | 47 ++++++- resources/assets/js/store/state.js | 3 +- .../sass/pages/components/project-dialog.scss | 115 +++++++++--------- 15 files changed, 194 insertions(+), 196 deletions(-) diff --git a/resources/assets/js/app.js b/resources/assets/js/app.js index 06520ad8a..bf2755fb2 100644 --- a/resources/assets/js/app.js +++ b/resources/assets/js/app.js @@ -98,14 +98,6 @@ Vue.prototype.goForward = function(location, isReplace) { if (typeof location === 'string') { location = {name: location}; } - // 打开聊天窗口(移动端) - if (app.$store.state.windowSmall - && location.name === 'manage-messenger' - && /\d+/.test(location.params.dialogId)) { - app.$store.state.dialogModalId = location.params.dialogId; - return - } - // if (app.$store.state.routeHistorys.length === 0) { app.$store.state.routeHistorys.push(app.$route) } diff --git a/resources/assets/js/components/Mobile/Tabbar.vue b/resources/assets/js/components/Mobile/Tabbar.vue index 5cbd762bb..db36130d6 100644 --- a/resources/assets/js/components/Mobile/Tabbar.vue +++ b/resources/assets/js/components/Mobile/Tabbar.vue @@ -122,7 +122,7 @@ export default { return 'project'; } if (this.routeName === 'manage-messenger') { - if (this.$route.params.dialogId === 'contacts') { + if (this.$route.params.dialogAction === 'contacts') { return 'contacts' } else { return 'dialog' @@ -167,11 +167,11 @@ export default { break; case 'dialog': - location = {name: 'manage-messenger', params: {dialogId: 'dialog'}}; + location = {name: 'manage-messenger', params: {dialogAction: 'dialog'}}; break; case 'contacts': - location = {name: 'manage-messenger', params: {dialogId: 'contacts'}}; + location = {name: 'manage-messenger', params: {dialogAction: 'contacts'}}; break; default: diff --git a/resources/assets/js/components/UserAvatar.vue b/resources/assets/js/components/UserAvatar.vue index 34f88cbf9..039dea336 100755 --- a/resources/assets/js/components/UserAvatar.vue +++ b/resources/assets/js/components/UserAvatar.vue @@ -251,15 +251,13 @@ this.userResult(info); }, + openDialog() { + this.$store.dispatch("openDialogUserid", this.userid); + }, + onError() { return true }, - - openDialog() { - this.$store.dispatch("openDialogUserid", this.userid).then(({data}) => { - this.goForward({name: 'manage-messenger', params: {dialogId: data.id}}); - }); - } } }; diff --git a/resources/assets/js/pages/manage.vue b/resources/assets/js/pages/manage.vue index cde9264ef..f0749d165 100644 --- a/resources/assets/js/pages/manage.vue +++ b/resources/assets/js/pages/manage.vue @@ -516,7 +516,7 @@ export default { 'clientNewVersion', 'cacheTaskBrowse', - 'dialogModalId', + 'dialogIns', ]), ...mapGetters(['taskData', 'dashboardTask']), @@ -654,10 +654,7 @@ export default { if (this.routeName === 'manage-project' && !/^\d+$/.test(this.$route.params.projectId)) { return true; } - if (this.routeName === 'manage-messenger' && !/^\d+$/.test(this.$route.params.dialogId)) { - return true; - } - return ['manage-dashboard', 'manage-calendar', 'manage-file', 'manage-setting'].includes(this.routeName) + return ['manage-dashboard', 'manage-calendar', 'manage-messenger', 'manage-file', 'manage-setting'].includes(this.routeName) }, }, @@ -751,9 +748,6 @@ export default { if (path === 'file' && $A.getStorageInt("file::folderId") > 0) { location.params.folderId = $A.getStorageInt("file::folderId") } - if (path === 'messenger' && $A.getStorageInt("messenger::dialogId") > 0) { - location.params.dialogId = $A.getStorageInt("messenger::dialogId") - } this.goForward(location); }, @@ -927,10 +921,8 @@ export default { if (!this.natificationReady && !this.$isEEUiApp) { return; // 通知未准备好 } - if (!this.natificationHidden - && this.routeName === 'manage-messenger' - && (this.$route.params.dialogId == data.dialog_id || this.dialogModalId === data.dialog_id)) { - return; // 可见 且 路由匹配时 + if ($A.last(this.dialogIns)?.dialog_id === data.dialog_id) { + return; // 最后打开的会话是通知的会话时不通知 } // const {id, dialog_id, type, msg, userid} = data; @@ -956,7 +948,8 @@ export default { userid: userid, desc: body, callback: () => { - this.goForward({name: 'manage-messenger', params: {dialogId: dialog_id}}); + this.goForward({name: 'manage-messenger'}); + this.$store.dispatch('openDialog', dialog_id) } }) } else { @@ -1087,11 +1080,8 @@ export default { if (!$A.isJson(data)) { return; } - if (data.dialog_id) { - this.goForward({name: 'manage-messenger', params: {dialogId: data.dialog_id}}); - } else { - this.goForward({name: 'manage-messenger'}); - } + this.goForward({name: 'manage-messenger'}); + this.$store.dispatch('openDialog', data.dialog_id) } }, }); diff --git a/resources/assets/js/pages/manage/components/DialogModal.vue b/resources/assets/js/pages/manage/components/DialogModal.vue index 8480beb87..7c94f82f9 100644 --- a/resources/assets/js/pages/manage/components/DialogModal.vue +++ b/resources/assets/js/pages/manage/components/DialogModal.vue @@ -8,7 +8,7 @@ :beforeClose="onBeforeClose" class-name="dialog-modal" fullscreen> - + @@ -55,30 +55,25 @@ export default { }, computed: { - ...mapState(['dialogModalId']) + ...mapState(['dialogId']) }, watch: { - dialogModalId: { + dialogId: { handler(id) { - this.show = id > 0; - }, - immediate: true - }, - windowLarge: { - handler(is) { - if (is && this.dialogModalId > 0) { - this.$store.state.dialogModalId = 0; - } + this.show = id > 0 && this.windowSmall; }, immediate: true }, + windowSmall(small) { + this.show = this.dialogId > 0 && small; + } }, methods: { onBeforeClose() { return new Promise(_ => { - this.$store.state.dialogModalId = 0; + this.$store.state.dialogId = 0; }) }, } diff --git a/resources/assets/js/pages/manage/components/DialogWrapper.vue b/resources/assets/js/pages/manage/components/DialogWrapper.vue index 8375cc8e9..118826e17 100644 --- a/resources/assets/js/pages/manage/components/DialogWrapper.vue +++ b/resources/assets/js/pages/manage/components/DialogWrapper.vue @@ -294,7 +294,7 @@ export default { type: Number, default: 0 }, - desktopAutoFocus: { + autoFocus: { type: Boolean, default: false }, @@ -339,6 +339,26 @@ export default { } }, + mounted() { + if (this.$store.state.dialogMsgTransfer.time > $A.Time()) { + this.$store.state.dialogMsgTransfer.time = 0; + const {msgFile, msgRecord, msgText} = this.$store.state.dialogMsgTransfer; + this.$nextTick(() => { + if ($A.isArray(msgFile) && msgFile.length > 0) { + this.sendFileMsg(msgFile); + } else if ($A.isJson(msgRecord) && msgRecord.duration > 0) { + this.sendRecord(msgRecord); + } else if (msgText) { + this.sendMsg(msgText); + } + }); + } + }, + + beforeDestroy() { + this.$store.dispatch('forgetInDialog', this._uid) + }, + computed: { ...mapState([ 'cacheDialogs', @@ -434,35 +454,12 @@ export default { }, watch: { - '$route': { - handler (route) { - if (this.$store.state.dialogMsgTransfer.time > $A.Time()) { - this.$store.state.dialogMsgTransfer.time = 0; - const {msgFile, msgRecord, msgText} = this.$store.state.dialogMsgTransfer; - this.$nextTick(() => { - if ($A.isArray(msgFile) && msgFile.length > 0) { - this.sendFileMsg(msgFile); - } else if ($A.isJson(msgRecord) && msgRecord.duration > 0) { - this.sendRecord(msgRecord); - } else if (msgText) { - this.sendMsg(msgText); - } - }); - } - if (route.query && route.query._) { - let query = $A.cloneJSON(route.query); - delete query._; - this.goForward({query}, true); - } - }, - immediate: true - }, - dialogId: { handler(id) { if (id) { this.msgNew = 0; this.topId = -1; + // let cacheTimer = null; if (this.allMsgList.length > 0) { cacheTimer = setTimeout(_ => { @@ -476,7 +473,12 @@ export default { setTimeout(this.onToBottom, Math.max(0, 100 - (new Date().getTime() - startTime))); }).catch(_ => {}); // - if (this.windowLarge && this.desktopAutoFocus) { + this.$store.dispatch('saveInDialog', { + uid: this._uid, + dialog_id: id, + }) + // + if (this.autoFocus) { this.$nextTick(_ => { this.$refs.input.focus() }) @@ -741,7 +743,7 @@ export default { onToBottom() { this.msgNew = 0; if (this.isReady) { - this.$refs.scroller.scrollToBottom(); + this.$refs.scroller?.scrollToBottom(); } }, @@ -790,7 +792,7 @@ export default { this.createGroupShow = false; this.createGroupData = {}; this.$store.dispatch("saveDialog", data); - this.goForward({name: 'manage-messenger', params: {dialogId: data.id}}); + this.$store.dispatch('openDialog', data.id) }).catch(({msg}) => { $A.modalError(msg); }).finally(_ => { diff --git a/resources/assets/js/pages/manage/components/ProjectDialog.vue b/resources/assets/js/pages/manage/components/ProjectDialog.vue index e66d47404..a94b53afa 100644 --- a/resources/assets/js/pages/manage/components/ProjectDialog.vue +++ b/resources/assets/js/pages/manage/components/ProjectDialog.vue @@ -1,33 +1,30 @@