header.js
1.51 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import {
mapState
} from 'vuex'
import {
getObjByListKeyValue
} from '@utils/utils.js'
import VDropdown from '@components/home/dropdown/dropdown.vue'
export default {
name: 'VHeader',
components: {
VDropdown
},
computed: {
i18n() {
return this.$i18n.messages && this.$i18n.locale ? this.$i18n.messages[this.$i18n.locale] : {};
}
},
data() {
return {
maxClientWidth: 950,
navList: [],
loginData: {},
langData: {
name: "繁",
path: "",
list: [{
name: "繁",
path: "",
value: "tc"
},
{
name: "简",
path: "",
value: "zh"
},
{
name: "EN",
path: "",
value: "en"
},
]
}
}
},
computed: {
...mapState({
isSmallScreen: state => state.isSmallScreen
})
},
methods: {
toIndex() {
this.$router.push({
path: "/"
})
},
checkIsSmallScreen() {
const self = this;
if (document.body.clientWidth > self.maxClientWidth) {
self.$store.commit('IS_SMALL_SCREEN', false)
} else {
self.$store.commit('IS_SMALL_SCREEN', true)
}
},
initData() {
let i18n = this.$i18n.messages[this.$i18n.locale] || {};
this.loginData = i18n.nav.loginData;
this.navList = i18n.nav.navList;
let curLang = getObjByListKeyValue(this.$i18n.locale, "value", this.langData.list)
this.langData.name = curLang.name;
}
},
mounted() {
const self = this;
self.checkIsSmallScreen();
document.body.onresize = () => {
self.checkIsSmallScreen();
}
},
created() {
this.initData();
},
}