-
Notifications
You must be signed in to change notification settings - Fork 225
/
Copy pathmain.js
52 lines (43 loc) · 1.15 KB
/
main.js
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
import Vue from 'vue'
import VueI18n from 'vue-i18n'
import App from './App'
import router from './router'
import DemoBox from './components/demobox'
import IconList from './components/iconlist'
import VueClipboard from './directives/clipboard'
import AtUI from 'at-ui-lib'
import zhLocale from 'at-ui-locale-zh'
import enLocale from 'at-ui-locale-en'
import 'at-ui-style'
Vue.use(VueI18n)
Vue.use(AtUI)
Vue.use(VueClipboard)
Vue.component('demo-box', DemoBox)
Vue.component('icon-list', IconList)
const matchArr = window.location.href.match(/#\/(zh|en)/)
const urlLang = matchArr && matchArr[1]
let navigatorLang = window.navigator.language.slice(0, 2)
if (['en', 'zh'].indexOf(navigatorLang) <= -1) {
navigatorLang = ''
}
const userLang = urlLang || window.localStorage.getItem('at-ui-language') || navigatorLang || 'zh'
const i18n = new VueI18n({
locale: userLang,
fallbackLocale: 'en',
messages: {
'en': {
...enLocale
},
'zh': {
...zhLocale
}
}
})
AtUI.i18n((key, value) => i18n.t(key, value))
Vue.config.debug = process.env.NODE_ENV !== 'production'
new Vue({ // eslint-disable-line
el: '#app',
router,
i18n,
...App
})