|
|
@ -1,6 +1,6 @@ |
|
|
|
<template> |
|
|
|
<template> |
|
|
|
<div class="page-layout"> |
|
|
|
<div class="page-layout"> |
|
|
|
<page-header :i18n="routesI18n" :breadcrumb="breadcrumb" :title="title" :logo="logo" :avatar="avatar"> |
|
|
|
<page-header :i18n="routesI18n" :breadcrumb="breadcrumb" :title="pageTitle" :logo="logo" :avatar="avatar"> |
|
|
|
<slot name="action" slot="action"></slot> |
|
|
|
<slot name="action" slot="action"></slot> |
|
|
|
<slot slot="content" name="headerContent"></slot> |
|
|
|
<slot slot="content" name="headerContent"></slot> |
|
|
|
<div slot="content" v-if="!this.$slots.headerContent && desc"> |
|
|
|
<div slot="content" v-if="!this.$slots.headerContent && desc"> |
|
|
@ -28,22 +28,55 @@ export default { |
|
|
|
props: ['desc', 'logo', 'title', 'avatar', 'linkList', 'extraImage'], |
|
|
|
props: ['desc', 'logo', 'title', 'avatar', 'linkList', 'extraImage'], |
|
|
|
data () { |
|
|
|
data () { |
|
|
|
return { |
|
|
|
return { |
|
|
|
breadcrumb: [] |
|
|
|
page: {} |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
computed: { |
|
|
|
watch: { |
|
|
|
...mapState('setting', ['layout', 'routesI18n']) |
|
|
|
$route() { |
|
|
|
|
|
|
|
this.page = this.$route.meta.page |
|
|
|
|
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
created () { |
|
|
|
created() { |
|
|
|
this.getBreadcrumb() |
|
|
|
let i18n = this.routesI18n |
|
|
|
|
|
|
|
Object.keys(i18n).forEach(key => { |
|
|
|
|
|
|
|
this.$i18n.mergeLocaleMessage(key, i18n[key]) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
this.page = this.$route.meta.page |
|
|
|
}, |
|
|
|
}, |
|
|
|
updated () { |
|
|
|
computed: { |
|
|
|
this.getBreadcrumb() |
|
|
|
...mapState('setting', ['layout', 'routesI18n']), |
|
|
|
|
|
|
|
pageTitle() { |
|
|
|
|
|
|
|
let pageTitle = this.page && this.page.title |
|
|
|
|
|
|
|
return this.title || this.$t(pageTitle) || this.routeName |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
routeName() { |
|
|
|
|
|
|
|
return this.$t(this.$route.path.substring(1).replace(new RegExp('/', 'g'), '.') + '.name') |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
breadcrumb() { |
|
|
|
|
|
|
|
let page = this.page |
|
|
|
|
|
|
|
let breadcrumb = page && page.breadcrumb |
|
|
|
|
|
|
|
if (breadcrumb) { |
|
|
|
|
|
|
|
let i18nBreadcrumb = [] |
|
|
|
|
|
|
|
breadcrumb.forEach(item => { |
|
|
|
|
|
|
|
i18nBreadcrumb.push(this.$t(item)) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
return i18nBreadcrumb |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return this.getRouteBreadcrumb() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
methods: { |
|
|
|
getBreadcrumb () { |
|
|
|
getRouteBreadcrumb() { |
|
|
|
this.breadcrumb = this.$route.matched |
|
|
|
let routes = this.$route.matched |
|
|
|
}, |
|
|
|
let breadcrumb = [] |
|
|
|
|
|
|
|
routes.forEach(route => { |
|
|
|
|
|
|
|
let path = route.path |
|
|
|
|
|
|
|
let key = path.length == 0 ? '/home' : path |
|
|
|
|
|
|
|
breadcrumb.push(this.$t(key.substring(1).replace(new RegExp('/', 'g'), '.') + '.name')) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
return breadcrumb |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
</script> |
|
|
|
</script> |
|
|
|