chore: optimize the i18n code of router; 🌟
This commit is contained in:
@@ -50,8 +50,7 @@ export default {
|
||||
},
|
||||
provide() {
|
||||
return{
|
||||
layoutMinHeight: minHeight,
|
||||
menuI18n: require('@/router/i18n').default
|
||||
layoutMinHeight: minHeight
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div class="page-layout">
|
||||
<page-header :i18n="routesI18n" :breadcrumb="breadcrumb" :title="pageTitle" :logo="logo" :avatar="avatar">
|
||||
<page-header :breadcrumb="breadcrumb" :title="pageTitle" :logo="logo" :avatar="avatar">
|
||||
<slot name="action" slot="action"></slot>
|
||||
<slot slot="content" name="headerContent"></slot>
|
||||
<div slot="content" v-if="!this.$slots.headerContent && desc">
|
||||
@@ -37,14 +37,10 @@ export default {
|
||||
}
|
||||
},
|
||||
created() {
|
||||
let i18n = this.routesI18n
|
||||
Object.keys(i18n).forEach(key => {
|
||||
this.$i18n.mergeLocaleMessage(key, i18n[key])
|
||||
})
|
||||
this.page = this.$route.meta.page
|
||||
},
|
||||
computed: {
|
||||
...mapState('setting', ['layout', 'routesI18n']),
|
||||
...mapState('setting', ['layout']),
|
||||
pageTitle() {
|
||||
let pageTitle = this.page && this.page.title
|
||||
return this.title || this.$t(pageTitle) || this.routeName
|
||||
|
||||
@@ -26,7 +26,7 @@ export default {
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapState('setting', ['isMobile', 'multiPage', 'animate', 'routesI18n', 'dustbins']),
|
||||
...mapState('setting', ['isMobile', 'multiPage', 'animate', 'dustbins']),
|
||||
desc() {
|
||||
return this.page.desc
|
||||
},
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<a-divider v-if="isMobile" type="vertical" />
|
||||
<a-icon v-if="layout === 'side'" class="trigger" :type="collapsed ? 'menu-unfold' : 'menu-fold'" @click="toggleCollapse"/>
|
||||
<div v-if="layout == 'head' && !isMobile" class="admin-header-menu">
|
||||
<i-menu class="head-menu" style="height: 64px; line-height: 64px;box-shadow: none" @i18nComplete="setRoutesI18n" :i18n="menuI18n" :theme="headerTheme" mode="horizontal" :options="menuData" @select="onSelect"/>
|
||||
<i-menu class="head-menu" style="height: 64px; line-height: 64px;box-shadow: none" :theme="headerTheme" mode="horizontal" :options="menuData" @select="onSelect"/>
|
||||
</div>
|
||||
<div :class="['admin-header-right', headerTheme]">
|
||||
<header-search class="header-item" />
|
||||
@@ -43,7 +43,6 @@ export default {
|
||||
name: 'AdminHeader',
|
||||
components: {IMenu, HeaderAvatar, HeaderNotice, HeaderSearch},
|
||||
props: ['collapsed', 'menuData'],
|
||||
inject: ['menuI18n'],
|
||||
data() {
|
||||
return {
|
||||
langList: [
|
||||
@@ -73,7 +72,7 @@ export default {
|
||||
onSelect (obj) {
|
||||
this.$emit('menuSelect', obj)
|
||||
},
|
||||
...mapMutations('setting', ['setLang', 'setRoutesI18n'])
|
||||
...mapMutations('setting', ['setLang'])
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -44,7 +44,7 @@ export default {
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapState('setting', ['multiPage', 'animate', 'layout', 'dustbins', 'routesI18n']),
|
||||
...mapState('setting', ['multiPage', 'animate', 'layout', 'dustbins']),
|
||||
menuItemList() {
|
||||
return [
|
||||
{ key: '1', icon: 'vertical-right', text: this.$t('closeLeft') },
|
||||
@@ -57,10 +57,6 @@ export default {
|
||||
const route = this.$route
|
||||
this.pageList.push(route)
|
||||
this.activePage = route.fullPath
|
||||
let i18n = this.routesI18n
|
||||
Object.keys(i18n).forEach(key => {
|
||||
this.$i18n.mergeLocaleMessage(key, i18n[key])
|
||||
})
|
||||
},
|
||||
watch: {
|
||||
'$route': function (newRoute) {
|
||||
|
||||
Reference in New Issue
Block a user