perf[Breadcrumb]: refine getBreadcrumb function

This commit is contained in:
Pan 2019-04-16 14:18:50 +08:00
parent 4ee334ad83
commit 3678bd18fb
1 changed files with 11 additions and 4 deletions

View File

@ -31,16 +31,23 @@ export default {
methods: {
generateTitle,
getBreadcrumb() {
// only show routes with name
let matched = this.$route.matched.filter(item => item.name)
// only show routes with meta.title
let matched = this.$route.matched.filter(item => item.meta && item.meta.title)
const first = matched[0]
if (first && first.name.trim().toLocaleLowerCase() !== 'Dashboard'.toLocaleLowerCase()) {
if (!this.isDashboard(first)) {
matched = [{ path: '/dashboard', meta: { title: 'dashboard' }}].concat(matched)
}
this.levelList = matched.filter(item => item.meta && item.meta.title && item.meta.breadcrumb !== false)
},
isDashboard(route) {
const name = route && route.name
if (!name) {
return false
}
return name.trim().toLocaleLowerCase() === 'Dashboard'.toLocaleLowerCase()
},
pathCompile(path) {
// To solve this problem https://github.com/PanJiaChen/vue-element-admin/issues/561
const { params } = this.$route