vue2-client 1.8.5 → 1.8.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/App.vue +89 -3
package/package.json
CHANGED
package/src/App.vue
CHANGED
|
@@ -1,12 +1,98 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
2
|
+
<a-config-provider :locale="locale" :get-popup-container="popContainer">
|
|
3
3
|
<router-view/>
|
|
4
|
-
</
|
|
4
|
+
</a-config-provider>
|
|
5
5
|
</template>
|
|
6
6
|
|
|
7
7
|
<script>
|
|
8
|
+
import { enquireScreen } from '@vue2-client/utils/util'
|
|
9
|
+
import { mapState, mapMutations } from 'vuex'
|
|
10
|
+
import themeUtil from '@vue2-client/utils/themeUtil'
|
|
11
|
+
import { getI18nKey } from '@vue2-client/utils/routerUtil'
|
|
12
|
+
import { setSystemVersion } from '@vue2-client/utils/request'
|
|
13
|
+
|
|
8
14
|
export default {
|
|
9
|
-
name: 'App'
|
|
15
|
+
name: 'App',
|
|
16
|
+
data () {
|
|
17
|
+
return {
|
|
18
|
+
locale: {}
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
created () {
|
|
22
|
+
this.setHtmlTitle()
|
|
23
|
+
this.setLanguage(this.lang)
|
|
24
|
+
enquireScreen(isMobile => this.setDevice(isMobile))
|
|
25
|
+
},
|
|
26
|
+
mounted () {
|
|
27
|
+
this.setWeekModeTheme(this.weekMode)
|
|
28
|
+
// 设置系统版本
|
|
29
|
+
setSystemVersion(this.compatible)
|
|
30
|
+
},
|
|
31
|
+
watch: {
|
|
32
|
+
weekMode (val) {
|
|
33
|
+
this.setWeekModeTheme(val)
|
|
34
|
+
},
|
|
35
|
+
lang (val) {
|
|
36
|
+
this.setLanguage(val)
|
|
37
|
+
this.setHtmlTitle()
|
|
38
|
+
},
|
|
39
|
+
$route () {
|
|
40
|
+
this.setHtmlTitle()
|
|
41
|
+
},
|
|
42
|
+
'theme.mode': {
|
|
43
|
+
immediate: true,
|
|
44
|
+
handler: function (val) {
|
|
45
|
+
const closeMessage = this.$message.loading(`您选择了主题模式 ${val}, 正在切换...`)
|
|
46
|
+
themeUtil.changeThemeColor(this.theme.color, val).then(closeMessage)
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
'theme.color': {
|
|
50
|
+
immediate: true,
|
|
51
|
+
handler: function (val) {
|
|
52
|
+
const closeMessage = this.$message.loading(`您选择了主题色 ${val}, 正在切换...`)
|
|
53
|
+
themeUtil.changeThemeColor(val, this.theme.mode).then(closeMessage)
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
layout: function () {
|
|
57
|
+
window.dispatchEvent(new Event('resize'))
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
computed: {
|
|
61
|
+
...mapState('setting', ['layout', 'theme', 'weekMode', 'lang', 'compatible'])
|
|
62
|
+
},
|
|
63
|
+
methods: {
|
|
64
|
+
...mapMutations('setting', ['setDevice']),
|
|
65
|
+
setWeekModeTheme (weekMode) {
|
|
66
|
+
if (weekMode) {
|
|
67
|
+
document.body.classList.add('week-mode')
|
|
68
|
+
} else {
|
|
69
|
+
document.body.classList.remove('week-mode')
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
setLanguage (lang) {
|
|
73
|
+
this.$i18n.locale = lang
|
|
74
|
+
switch (lang) {
|
|
75
|
+
case 'CN':
|
|
76
|
+
this.locale = require('ant-design-vue/es/locale-provider/zh_CN').default
|
|
77
|
+
break
|
|
78
|
+
case 'HK':
|
|
79
|
+
this.locale = require('ant-design-vue/es/locale-provider/zh_TW').default
|
|
80
|
+
break
|
|
81
|
+
case 'US':
|
|
82
|
+
default:
|
|
83
|
+
this.locale = require('ant-design-vue/es/locale-provider/en_US').default
|
|
84
|
+
break
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
setHtmlTitle () {
|
|
88
|
+
const route = this.$route
|
|
89
|
+
const key = route.path === '/' ? 'home.name' : getI18nKey(route.matched[route.matched.length - 1].path)
|
|
90
|
+
document.title = process.env.VUE_APP_NAME + ' | ' + this.$t(key)
|
|
91
|
+
},
|
|
92
|
+
popContainer () {
|
|
93
|
+
return document.getElementById('popContainer')
|
|
94
|
+
}
|
|
95
|
+
}
|
|
10
96
|
}
|
|
11
97
|
</script>
|
|
12
98
|
|