新增:动态修改标题的 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

@@ -60,10 +60,10 @@ export default {
this.updatePageHeight(0)
},
computed: {
...mapState('setting', ['layout', 'multiPage', 'pageMinHeight', 'pageWidth']),
...mapState('setting', ['layout', 'multiPage', 'pageMinHeight', 'pageWidth', 'customTitles']),
pageTitle() {
let pageTitle = this.page && this.page.title
return pageTitle === undefined ? (this.title || this.routeName) : this.$t(pageTitle)
return this.customTitle || (pageTitle && this.$t(pageTitle)) || this.title || this.routeName
},
routeName() {
const route = this.$route
@@ -96,8 +96,8 @@ export default {
breadcrumb.push(this.$t(getI18nKey(path)))
})
let pageTitle = this.page && this.page.title
if (pageTitle) {
breadcrumb[breadcrumb.length - 1] = pageTitle
if (this.customTitle || pageTitle) {
breadcrumb[breadcrumb.length - 1] = this.customTitle || pageTitle
}
return breadcrumb
},

View File

@@ -63,7 +63,7 @@
this.affixed = this.fixedTabs
},
computed: {
...mapState('setting', ['layout', 'pageWidth', 'fixedHeader', 'fixedTabs']),
...mapState('setting', ['layout', 'pageWidth', 'fixedHeader', 'fixedTabs', 'customTitles']),
lockTitle() {
return this.$t(this.fixedTabs ? 'unlock' : 'lock')
}
@@ -95,7 +95,8 @@
this.$emit('contextmenu', pageKey, e)
},
pageName(page) {
return page.title || this.$t(getI18nKey(page.keyPath))
const custom = this.customTitles.find(item => item.path === page.fullPath)
return (custom && custom.title) || page.title || this.$t(getI18nKey(page.keyPath))
}
}
}