fix: 修复从npm-events点击跳转至detections-performance events回退不保留状态的问题

This commit is contained in:
刘洪洪
2023-01-10 15:14:46 +08:00
parent 2bac72eb5d
commit 29916f8517

View File

@@ -151,6 +151,7 @@ export default {
return name return name
}, },
jumpPage (item) { jumpPage (item) {
this.beforeRouterPush()
this.$router.push({ this.$router.push({
path: '/detection/performanceEvent', path: '/detection/performanceEvent',
query: { query: {
@@ -158,6 +159,36 @@ export default {
eventId: item.eventId 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 () { mounted () {