fix:修复点击不同 tab 标签时刷新页面后 tab 标签丢失或变为同一个的问题

This commit is contained in:
zhaojisen
2024-05-21 14:22:05 +08:00
committed by 老广
parent acfc1fc942
commit 4f215cbc49
6 changed files with 13 additions and 26 deletions

View File

@@ -56,8 +56,6 @@
import Page from '../Page/'
import { toSentenceCase } from '@/utils/common'
const ACTIVE_TAB_KEY = 'tab'
export default {
name: 'TabPage',
components: {
@@ -125,18 +123,22 @@ export default {
}
}
},
created() {
activated() {
this.iActiveMenu = this.getPropActiveTab()
},
mounted() {
this.iActiveMenu = this.getPropActiveTab()
},
methods: {
handleTabClick(tab) {
this.$emit('tab-click', tab)
this.$emit('update:activeMenu', tab.name)
this.$cookie.set(ACTIVE_TAB_KEY, tab.name, 1)
if (this.$router.currentRoute.query[ACTIVE_TAB_KEY]) {
this.$cookie.set(this.$route.path, tab.name, 1)
if (this.$router.currentRoute.query[this.$route.path]) {
this.$router.push({
query: { ...this.$route.query, [ACTIVE_TAB_KEY]: '' }
query: { ...this.$route.query, [this.$route.path]: '' }
})
}
},
@@ -144,8 +146,8 @@ export default {
let activeTab = ''
const preActiveTabs = [
this.$route.query[ACTIVE_TAB_KEY],
this.$cookie.get(ACTIVE_TAB_KEY),
this.$route.query[this.$route.path],
this.$cookie.get(this.$route.path),
this.activeMenu
]

View File

@@ -32,6 +32,3 @@ export default {
}
}
</script>
<style scoped>
</style>

View File

@@ -33,6 +33,3 @@ export default {
}
}
</script>
<style scoped>
</style>

View File

@@ -101,7 +101,3 @@ export default {
}
}
</script>
<style scoped>
</style>

View File

@@ -165,7 +165,3 @@ export default {
}
}
</script>
<style lang="scss" scoped>
</style>

View File

@@ -44,6 +44,9 @@ export default {
return this.$t('RoleList')
}
},
activated() {
this.switchGlobalOrg(this.config.activeMenu === 'OrgRoleList')
},
mounted() {
this.switchGlobalOrg(this.config.activeMenu === 'OrgRoleList')
},
@@ -63,7 +66,3 @@ export default {
}
}
</script>
<style scoped>
</style>