Skip to content

Commit 4269ffd

Browse files
committed
fix: locale
1 parent e4e8837 commit 4269ffd

File tree

11 files changed

+67
-194
lines changed

11 files changed

+67
-194
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"postinstall": "opencollective-postinstall"
1313
},
1414
"dependencies": {
15-
"@ant-design-vue/pro-layout": "^0.2.3",
15+
"@ant-design-vue/pro-layout": "^0.2.5",
1616
"@antv/data-set": "^0.10.2",
1717
"ant-design-vue": "1.5.3",
1818
"axios": "^0.19.0",

src/App.vue

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,23 @@
77
</template>
88

99
<script>
10-
import zhCN from 'ant-design-vue/lib/locale-provider/zh_CN'
11-
1210
export default {
1311
data () {
1412
return {
15-
locale: zhCN
13+
}
14+
},
15+
computed: {
16+
locale () {
17+
return this.$i18n.getLocaleMessage(this.$store.getters.lang).antLocale
1618
}
1719
},
1820
mounted () {
19-
21+
this.test()
22+
},
23+
methods: {
24+
test () {
25+
console.log('this', this)
26+
}
2027
}
2128
}
2229
</script>

src/config/router.config.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export const asyncRouterMap = [
1313
path: '/',
1414
name: 'index',
1515
component: BasicLayout,
16-
meta: { title: '首页' },
16+
meta: { title: 'menu.home' },
1717
redirect: '/dashboard/workplace',
1818
children: [
1919
// dashboard
@@ -22,25 +22,25 @@ export const asyncRouterMap = [
2222
name: 'dashboard',
2323
redirect: '/dashboard/workplace',
2424
component: RouteView,
25-
meta: { title: '仪表盘', keepAlive: true, icon: bxAnaalyse, permission: [ 'dashboard' ] },
25+
meta: { title: 'menu.dashboard', keepAlive: true, icon: bxAnaalyse, permission: [ 'dashboard' ] },
2626
children: [
2727
{
2828
path: '/dashboard/analysis/:pageNo([1-9]\\d*)?',
2929
name: 'Analysis',
3030
component: () => import('@/views/dashboard/Analysis'),
31-
meta: { title: '分析页', keepAlive: false, permission: [ 'dashboard' ] }
31+
meta: { title: 'menu.dashboard.analysis', keepAlive: false, permission: [ 'dashboard' ] }
3232
},
3333
// 外部链接
3434
{
3535
path: 'https://www.baidu.com/',
3636
name: 'Monitor',
37-
meta: { title: '监控页(外部)', target: '_blank' }
37+
meta: { title: 'menu.dashboard.monitor', target: '_blank' }
3838
},
3939
{
4040
path: '/dashboard/workplace',
4141
name: 'Workplace',
4242
component: () => import('@/views/dashboard/Workplace'),
43-
meta: { title: '工作台', keepAlive: true, permission: [ 'dashboard' ] }
43+
meta: { title: 'menu.dashboard.workplace', keepAlive: true, permission: [ 'dashboard' ] }
4444
}
4545
]
4646
},

src/layouts/BasicLayout.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
<script>
2828
import { i18nRender } from '@/locales'
2929
import { mapState } from 'vuex'
30-
import ProLayout from '@ant-design-vue/pro-layout'
3130
import RightContent from '@/components/GlobalHeader/RightContent'
3231
import GlobalFooter from '@/components/GlobalFooter'
3332
@@ -37,7 +36,6 @@ import { SIDEBAR_TYPE, TOGGLE_MOBILE_TYPE } from '@/store/mutation-types'
3736
export default {
3837
name: 'BasicLayout',
3938
components: {
40-
ProLayout,
4139
RightContent,
4240
GlobalFooter,
4341
LogoSvg

src/locales/lang/en-US.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@ const components = {
88
}
99

1010
const locale = {
11-
'message': '-'
11+
'message': '-',
12+
'menu.home': 'Home',
13+
'menu.dashboard': 'Dashboard',
14+
'menu.dashboard.analysis': 'Analysis',
15+
'menu.dashboard.monitor': 'Monitor',
16+
'menu.dashboard.workplace': 'Workplace'
1217
}
1318

1419
export default {

src/locales/lang/zh-CN.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import antd from 'ant-design-vue/es/locale-provider/zh_CN'
2+
import momentCN from 'moment/locale/zh-cn'
3+
4+
const components = {
5+
antLocale: antd,
6+
momentName: 'zh-cn',
7+
momentLocale: momentCN
8+
}
9+
10+
const locale = {
11+
'message': '-',
12+
'menu.home': '主页',
13+
'menu.dashboard': '仪表盘',
14+
'menu.dashboard.analysis': '分析页',
15+
'menu.dashboard.monitor': '监控页',
16+
'menu.dashboard.workplace': '工作台'
17+
}
18+
19+
export default {
20+
...components,
21+
...locale
22+
}

src/main.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ import Vue from 'vue'
66
import App from './App.vue'
77
import router from './router'
88
import store from './store/'
9+
import i18n from './locales'
910
import { VueAxios } from './utils/request'
10-
import { PageHeaderWrapper } from '@ant-design-vue/pro-layout'
11+
import ProLayout, { PageHeaderWrapper } from '@ant-design-vue/pro-layout'
1112

1213
// mock
1314
// WARNING: `mockjs` NOT SUPPORT `IE` PLEASE DO NOT USE IN `production` ENV.
@@ -23,11 +24,13 @@ Vue.config.productionTip = false
2324

2425
// mount axios to `Vue.$http` and `this.$http`
2526
Vue.use(VueAxios)
27+
Vue.component('pro-layout', ProLayout)
2628
Vue.component('page-header-wrapper', PageHeaderWrapper)
2729

2830
new Vue({
2931
router,
3032
store,
33+
i18n,
3134
created: bootstrap,
3235
render: h => h(App)
3336
}).$mount('#app')

src/store/getters.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const getters = {
22
isMobile: state => state.app.isMobile,
3-
lang: state => state.i18n.lang,
3+
lang: state => state.app.lang,
44
theme: state => state.app.theme,
55
color: state => state.app.color,
66
token: state => state.user.token,

src/views/result/Error.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<a-card :bordered="false" style="margin: -24px -24px 0px;">
2+
<a-card :bordered="false">
33
<a-result status="error" :title="title" :sub-title="description">
44
<template #extra>
55
<a-button type="primary" >返回修改</a-button>

src/views/result/Success.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<a-card :bordered="false" style="margin: -24px -24px 0px;">
2+
<a-card :bordered="false">
33
<a-result status="success" :sub-title="description" :title="title">
44
<template #extra>
55
<a-button type="primary">返回列表</a-button>

0 commit comments

Comments
 (0)