fix: i18n problem of dynamic route; 🐛
修复:动态路由的国际化问题;
This commit is contained in:
@@ -22,6 +22,8 @@
|
||||
<script>
|
||||
import PageHeader from '@/components/page/header/PageHeader'
|
||||
import {mapState, mapMutations} from 'vuex'
|
||||
import {getI18nKey} from '@/utils/routerUtil'
|
||||
|
||||
export default {
|
||||
name: 'PageLayout',
|
||||
components: {PageHeader},
|
||||
@@ -64,7 +66,8 @@ export default {
|
||||
return this.title || this.$t(pageTitle) || this.routeName
|
||||
},
|
||||
routeName() {
|
||||
return this.$t(this.$route.path.substring(1).replace(new RegExp('/', 'g'), '.') + '.name')
|
||||
const route = this.$route
|
||||
return this.$t(getI18nKey(route.matched[route.matched.length - 1].path))
|
||||
},
|
||||
breadcrumb() {
|
||||
let page = this.page
|
||||
@@ -89,9 +92,8 @@ export default {
|
||||
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'))
|
||||
const path = route.path.length === 0 ? '/home' : route.path
|
||||
breadcrumb.push(this.$t(getI18nKey(path)))
|
||||
})
|
||||
return breadcrumb
|
||||
},
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
@contextmenu="onContextmenu"
|
||||
>
|
||||
<a-tab-pane :key="page.fullPath" v-for="page in pageList">
|
||||
<span slot="tab" :pagekey="page.fullPath">{{pageName(page.path)}}</span>
|
||||
<span slot="tab" :pagekey="page.fullPath">{{pageName(page)}}</span>
|
||||
</a-tab-pane>
|
||||
</a-tabs>
|
||||
<div class="tabs-view-content" :style="`margin-top: ${multiPage ? -24 : 0}px`">
|
||||
@@ -31,6 +31,7 @@ import AdminLayout from '@/layouts/AdminLayout'
|
||||
import Contextmenu from '@/components/menu/Contextmenu'
|
||||
import PageToggleTransition from '@/components/transition/PageToggleTransition'
|
||||
import {mapState, mapMutations} from 'vuex'
|
||||
import {getI18nKey} from '@/utils/routerUtil'
|
||||
|
||||
export default {
|
||||
name: 'TabsView',
|
||||
@@ -176,8 +177,8 @@ export default {
|
||||
this.setDustbins(this.dustbins.filter(item => item !== componentName))
|
||||
}
|
||||
},
|
||||
pageName(path) {
|
||||
return this.$t(path.substring(1).replace(new RegExp('/', 'g'), '.') + '.name')
|
||||
pageName(page) {
|
||||
return this.$t(getI18nKey(page.matched[page.matched.length - 1].path))
|
||||
},
|
||||
...mapMutations('setting', ['setDustbins', 'correctPageMinHeight'])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user