You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.2 KiB
50 lines
1.2 KiB
<template>
|
|
<router-view />
|
|
</template>
|
|
<script>
|
|
import { APP_NAME } from 'src/constants'
|
|
import _ from 'lodash'
|
|
|
|
export default {
|
|
name: 'App',
|
|
meta () {
|
|
return {
|
|
title: this.pageTitle,
|
|
titleTemplate: title => `${APP_NAME} - ${title}`
|
|
}
|
|
},
|
|
data () {
|
|
return {
|
|
pageTitle: ''
|
|
}
|
|
},
|
|
watch: {
|
|
$route (route) {
|
|
this.updateTitle(route)
|
|
}
|
|
},
|
|
async mounted () {
|
|
this.$initWait()
|
|
this.updateTitle(this.$route)
|
|
},
|
|
methods: {
|
|
updateTitle: function (route) {
|
|
if (route) {
|
|
const titleElements = []
|
|
const title = _.get(route, 'meta.title', '')
|
|
const subTitle = _.get(route, 'meta.subtitle', '')
|
|
if (title !== '') {
|
|
titleElements.push(title)
|
|
}
|
|
if (subTitle !== '') {
|
|
titleElements.push(subTitle)
|
|
}
|
|
this.pageTitle = titleElements.join(' - ') || route.name || ''
|
|
} else {
|
|
this.pageTitle = ''
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|