File tree Expand file tree Collapse file tree 2 files changed +25
-21
lines changed
Expand file tree Collapse file tree 2 files changed +25
-21
lines changed Original file line number Diff line number Diff line change 88
99<script >
1010import zhCN from ' ant-design-vue/lib/locale-provider/zh_CN'
11- import { deviceEnquire , DEVICE_TYPE } from ' @/utils/device '
11+ import { AppDeviceEnquire } from ' @/utils/mixin '
1212
1313export default {
14+ mixins: [AppDeviceEnquire],
1415 data () {
1516 return {
1617 locale: zhCN
1718 }
1819 },
1920 mounted () {
20- const { $store } = this
21- deviceEnquire (deviceType => {
22- switch (deviceType) {
23- case DEVICE_TYPE .DESKTOP :
24- $store .commit (' TOGGLE_DEVICE' , ' desktop' )
25- $store .dispatch (' setSidebar' , true )
26- break
27- case DEVICE_TYPE .TABLET :
28- $store .commit (' TOGGLE_DEVICE' , ' tablet' )
29- $store .dispatch (' setSidebar' , false )
30- break
31- case DEVICE_TYPE .MOBILE :
32- default :
33- $store .commit (' TOGGLE_DEVICE' , ' mobile' )
34- $store .dispatch (' setSidebar' , true )
35- break
36- }
37- })
21+
3822 }
3923}
4024 </script >
Original file line number Diff line number Diff line change 11// import Vue from 'vue'
2- import { DEVICE_TYPE } from '@/utils/device'
2+ import { deviceEnquire , DEVICE_TYPE } from '@/utils/device'
33import { mapState } from 'vuex'
44
55// const mixinsComputed = Vue.config.optionMergeStrategies.computed
@@ -50,4 +50,24 @@ const mixinDevice = {
5050 }
5151}
5252
53- export { mixin , mixinDevice }
53+ const AppDeviceEnquire = {
54+ mounted ( ) {
55+ const { $store } = this
56+ deviceEnquire ( deviceType => {
57+ switch ( deviceType ) {
58+ case DEVICE_TYPE . DESKTOP :
59+ $store . commit ( 'TOGGLE_DEVICE' , 'desktop' )
60+ break
61+ case DEVICE_TYPE . TABLET :
62+ $store . commit ( 'TOGGLE_DEVICE' , 'tablet' )
63+ break
64+ case DEVICE_TYPE . MOBILE :
65+ default :
66+ $store . commit ( 'TOGGLE_DEVICE' , 'mobile' )
67+ break
68+ }
69+ } )
70+ }
71+ }
72+
73+ export { mixin , AppDeviceEnquire , mixinDevice }
You can’t perform that action at this time.
0 commit comments