-
Notifications
You must be signed in to change notification settings - Fork 145
/
Copy pathApp.vue
57 lines (51 loc) · 1.04 KB
/
App.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<template>
<div id="app" :class="{ 'is-component': isComponent }">
<main-header v-if="lang !== 'play'"></main-header>
<div class="main-cnt">
<keep-alive>
<router-view ></router-view>
</keep-alive>
</div>
</div>
</template>
<script>
import mainHeader from './components/header'
import { use } from 'element-ui/lib/locale'
import zhLocale from 'element-ui/lib/locale/lang/zh-CN'
import enLocale from 'element-ui/lib/locale/lang/en'
const lang = location.hash.replace('#', '').split('/')[1] || 'zh-CN'
const localize = lang => {
switch (lang) {
case 'zh-CN':
use(zhLocale)
break
default:
use(enLocale)
}
}
localize(lang)
export default {
name: 'app',
components: {
mainHeader
},
computed: {
lang () {
return this.$route.path.split('/')[1] || 'zh-CN'
},
isComponent () {
return /^component-/.test(this.$route.name || '')
}
},
watch: {
lang (val) {
localize(val)
}
},
methods: {
},
mounted () {
localize(this.lang)
}
}
</script>