From c0ca50edf653e795e1d9ce1d4eac8975f9f7fab7 Mon Sep 17 00:00:00 2001 From: kuaifan Date: Sun, 29 May 2022 18:38:31 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E8=B7=AF=E7=94=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/assets/js/App.vue | 151 +++--------------- resources/assets/js/app.js | 37 +++-- .../manage/components/ChatInput/index.vue | 1 - .../pages/manage/components/DialogWrapper.vue | 11 +- .../pages/manage/components/ProjectPanel.vue | 11 +- resources/assets/js/pages/manage/project.vue | 6 +- resources/assets/js/routes.js | 4 - resources/assets/js/store/state.js | 4 + 8 files changed, 76 insertions(+), 149 deletions(-) diff --git a/resources/assets/js/App.vue b/resources/assets/js/App.vue index 4846bcd52..990cba9d9 100755 --- a/resources/assets/js/App.vue +++ b/resources/assets/js/App.vue @@ -1,10 +1,8 @@ + + - - diff --git a/resources/assets/js/app.js b/resources/assets/js/app.js index 92adfad68..3242be30c 100644 --- a/resources/assets/js/app.js +++ b/resources/assets/js/app.js @@ -92,23 +92,40 @@ if (!isElectron && !isEEUiApp) { }); } -// 加载函数 +// 加载路由 Vue.prototype.goForward = function(location, isReplace) { - if (typeof location === 'string') location = {name: location}; + if (typeof location === 'string') { + location = {name: location}; + } + if (app.$store.state.routeHistorys.length === 0) { + app.$store.state.routeHistorys.push(app.$route) + } if (isReplace === true) { - app.$router.replace(location).then(() => {}).catch(() => {}); + app.$router.replace(location).then(to => { + app.$store.state.routeHistorys.pop(); + app.$store.state.routeHistorys.push(to); + }).catch(_ => {}); } else { - app.$router.push(location).then(() => {}).catch(() => {}); + app.$router.push(location).then(to => { + const length = app.$store.state.routeHistorys.push(to) + length > 120 && app.$store.state.routeHistorys.splice(length - 100) + app.$store.state.routeHistoryLast = length >= 2 ? app.$store.state.routeHistorys[length - 2] : {}; + }).catch(_ => {}); } }; -// 返回函数 -Vue.prototype.goBack = function (number) { - let history = $A.jsonParse(window.sessionStorage['__history__'] || '{}'); - if ($A.runNum(history['::count']) > 2) { - app.$router.go(typeof number === 'number' ? number : -1); +// 返回路由 +Vue.prototype.goBack = function () { + if (app.$store.state.routeHistorys.length > 1) { + app.$router.back(); + // + app.$store.state.routeHistorys.pop(); + const length = app.$store.state.routeHistorys.length; + app.$store.state.routeHistoryLast = length >= 2 ? app.$store.state.routeHistorys[length - 2] : {}; } else { - app.$router.replace(typeof number === "object" ? number : {path: '/'}).catch(_ => {}); + app.$router.replace({path: '/'}).catch(_ => {}); + app.$store.state.routeHistorys = []; + app.$store.state.routeHistoryLast = {}; } }; diff --git a/resources/assets/js/pages/manage/components/ChatInput/index.vue b/resources/assets/js/pages/manage/components/ChatInput/index.vue index 8b9534333..0054ab7e8 100755 --- a/resources/assets/js/pages/manage/components/ChatInput/index.vue +++ b/resources/assets/js/pages/manage/components/ChatInput/index.vue @@ -519,7 +519,6 @@ export default { // Clipboard Matcher (保留图片跟空格,清除其余所以样式) this.quill.clipboard.addMatcher(Node.ELEMENT_NODE, (node, delta) => { delta.ops = delta.ops.map(op => { - console.log(op); const obj = { attributes: {}, insert: op.insert diff --git a/resources/assets/js/pages/manage/components/DialogWrapper.vue b/resources/assets/js/pages/manage/components/DialogWrapper.vue index 551040a65..b5dfd6417 100644 --- a/resources/assets/js/pages/manage/components/DialogWrapper.vue +++ b/resources/assets/js/pages/manage/components/DialogWrapper.vue @@ -8,7 +8,7 @@ @dragleave.prevent="chatDragOver(false, $event)">
-
+
{{msgUnreadOnly}}
@@ -698,6 +698,15 @@ export default { this.msgNew = 0; } }, 100) + }, + + onBack() { + const {name, params} = this.$store.state.routeHistoryLast; + if (name === this.$route.name && /\d+/.test(params.dialogId)) { + this.goForward({name: this.$route.name}); + } else { + this.goBack(); + } } } } diff --git a/resources/assets/js/pages/manage/components/ProjectPanel.vue b/resources/assets/js/pages/manage/components/ProjectPanel.vue index 8f8ce1e56..b7a9a613f 100644 --- a/resources/assets/js/pages/manage/components/ProjectPanel.vue +++ b/resources/assets/js/pages/manage/components/ProjectPanel.vue @@ -3,7 +3,7 @@
-
+

{{projectData.name}}

@@ -1438,6 +1438,15 @@ export default { } } this.$store.dispatch('toggleProjectParameter', data); + }, + + onBack() { + const {name, params} = this.$store.state.routeHistoryLast; + if (name === this.$route.name && /\d+/.test(params.projectId)) { + this.goForward({name: this.$route.name, params: {projectId: 'all'}}); + } else { + this.goBack(); + } } } } diff --git a/resources/assets/js/pages/manage/project.vue b/resources/assets/js/pages/manage/project.vue index 4b9f0bd97..098016d4a 100644 --- a/resources/assets/js/pages/manage/project.vue +++ b/resources/assets/js/pages/manage/project.vue @@ -4,7 +4,7 @@ - +
@@ -24,10 +24,6 @@ export default { ...mapState(['cacheProjects', 'wsOpenNum']), ...mapGetters(['projectData']), - routeName() { - return this.$route.name - }, - projectId() { const {projectId} = this.$route.params; return parseInt(/^\d+$/.test(projectId) ? projectId : 0); diff --git a/resources/assets/js/routes.js b/resources/assets/js/routes.js index dd00827bb..0f48a6175 100755 --- a/resources/assets/js/routes.js +++ b/resources/assets/js/routes.js @@ -7,9 +7,6 @@ export default [ { name: 'manage', path: '/manage', - meta: { - slide: false - }, component: () => import('./pages/manage.vue'), children: [ { @@ -94,7 +91,6 @@ export default [ { name: 'valid-email', path: '/single/valid/email', - meta: {title: '验证绑定邮箱'}, component: () => import('./pages/single/validEmail.vue') }, { diff --git a/resources/assets/js/store/state.js b/resources/assets/js/store/state.js index aa920da55..915a87f2b 100644 --- a/resources/assets/js/store/state.js +++ b/resources/assets/js/store/state.js @@ -7,6 +7,10 @@ const stateData = { // 浏览器宽度≤768返回true windowMax768: window.innerWidth <= 768, + // 路由记录 + routeHistorys: [], + routeHistoryLast: {}, + // 加载状态 loadDashboardTasks: false, loadUserBasic: false,