新增:动态修改标题的 api; #150

feat: add api of dynamic modify tab title;
This commit is contained in:
chenghongxing
2020-11-28 19:47:23 +08:00
parent 23b7dfe2a4
commit ae2b7a86ef
5 changed files with 40 additions and 6 deletions

View File

@@ -9,6 +9,24 @@ const TabsPagePlugin = {
$refreshPage(pageKey) {
const event = new CustomEvent('page:refresh', {detail:{pageKey}})
window.dispatchEvent(event)
},
$openPage(route, title) {
this.$setPageTitle(route, title)
this.$router.push(route)
},
$setPageTitle(route, title) {
if (title) {
const fullPath = typeof route === 'object' ? route.fullPath : route
this.$store.commit('setting/setCustomTitle', {path: fullPath, title})
}
}
},
computed: {
customTitle() {
const customTitles = this.$store.state.setting.customTitles
const fullPath = this.$route.fullPath
const custom = customTitles.find(item => item.path === fullPath)
return custom && custom.title
}
}
})