From 29916f851798fd6d8bdf4060b2dec7b3c51ba50f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=B4=AA=E6=B4=AA?= <2498601771@qq.com> Date: Tue, 10 Jan 2023 15:14:46 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=BB=8Enpm-events?= =?UTF-8?q?=E7=82=B9=E5=87=BB=E8=B7=B3=E8=BD=AC=E8=87=B3detections-perform?= =?UTF-8?q?ance=20events=E5=9B=9E=E9=80=80=E4=B8=8D=E4=BF=9D=E7=95=99?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../charts2/charts/npm/NpmRecentEvents.vue | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/views/charts2/charts/npm/NpmRecentEvents.vue b/src/views/charts2/charts/npm/NpmRecentEvents.vue index 3196e0a3..b9c7db4f 100644 --- a/src/views/charts2/charts/npm/NpmRecentEvents.vue +++ b/src/views/charts2/charts/npm/NpmRecentEvents.vue @@ -151,6 +151,7 @@ export default { return name }, jumpPage (item) { + this.beforeRouterPush() this.$router.push({ path: '/detection/performanceEvent', query: { @@ -158,6 +159,36 @@ export default { eventId: item.eventId } }) + }, + /** + * 在路由跳转前,即下钻前将路由数据保存起来,确保回退和前进保留当时状态 + */ + beforeRouterPush () { + const currentRouter = this.$_.cloneDeep(this.$route.query) + const historyList = this.$_.cloneDeep(this.$store.getters.getRouterHistoryList) + + const tempObj = { + t: currentRouter.t, + query: currentRouter, + path: this.$_.cloneDeep(this.$route.path), + params: this.$_.cloneDeep(this.$route.params) + } + if (historyList.length > 0) { + let flag = true + historyList.forEach((item, index) => { + if (item.t === currentRouter.t) { + historyList[index] = tempObj + flag = false + } + if (!flag) { + return true + } + }) + if (flag) historyList.push(tempObj) + } else { + historyList.push(tempObj) + } + this.$store.commit('setRouterHistoryList', historyList) } }, mounted () {