fix: 修复chartTabs组件由其他界面进入时还保留上次状态

This commit is contained in:
刘洪洪
2023-01-10 15:01:55 +08:00
parent dfcc03f11a
commit 2bac72eb5d

View File

@@ -230,6 +230,26 @@ export default {
},
beforeUnmount () {
clearTimeout(this.timer)
const path = this.$router.currentRoute.value.path
const list = window.currentChartTabList
if (list && this.router !== 'noRouter') {
if (list[1]) {
// 去其他界面,清除状态
if (path !== list[0].path && path !== list[1].path) {
window.currentChartTabList = null
} else if (path === this.tabsData[0].path) {
// 场景为在本界面点击tabs通过遮罩菜单栏又进入该界面则初始化状态默认选中第一个
// 缺点点击第一个tabs时没有过渡效果后续会跟进解决
window.currentChartTabList = [
{ path: list[1].path, index: list[1].index },
{ path: this.tabsData[0].path, index: '0' }
]
}
} else if (path !== list[0].path) {
// 避免刷新页面之后又点击菜单栏进入该界面,还保留上次点击状态
window.currentChartTabList = null
}
}
}
}
</script>