mirror of
https://github.com/iczer/vue-antd-admin
synced 2025-04-06 04:00:06 +08:00
refactor: remove enquireScreen function from device.js to util.js; 🌟
重构:把 enquireScreen 功能从 device.js 迁移至 util.js;
This commit is contained in:
parent
d4261bc401
commit
365dde7e66
@ -5,8 +5,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import enquireScreen from './utils/device'
|
import {enquireScreen} from './utils/util'
|
||||||
import {mapState} from 'vuex'
|
import {mapState, mapMutations} from 'vuex'
|
||||||
import themeUtil from '@/utils/themeUtil';
|
import themeUtil from '@/utils/themeUtil';
|
||||||
import {getI18nKey} from '@/utils/routerUtil'
|
import {getI18nKey} from '@/utils/routerUtil'
|
||||||
|
|
||||||
@ -20,9 +20,7 @@ export default {
|
|||||||
created () {
|
created () {
|
||||||
this.setHtmlTitle()
|
this.setHtmlTitle()
|
||||||
this.setLanguage(this.lang)
|
this.setLanguage(this.lang)
|
||||||
enquireScreen(isMobile => {
|
enquireScreen(isMobile => this.setDevice(isMobile))
|
||||||
this.$store.commit('setting/setDevice', isMobile)
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.setWeekModeTheme(this.weekMode)
|
this.setWeekModeTheme(this.weekMode)
|
||||||
@ -54,6 +52,7 @@ export default {
|
|||||||
...mapState('setting', ['theme', 'weekMode', 'lang'])
|
...mapState('setting', ['theme', 'weekMode', 'lang'])
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
...mapMutations('setting', ['setDevice']),
|
||||||
setWeekModeTheme(weekMode) {
|
setWeekModeTheme(weekMode) {
|
||||||
if (weekMode) {
|
if (weekMode) {
|
||||||
document.body.classList.add('week-mode')
|
document.body.classList.add('week-mode')
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
import enquireJs from 'enquire.js'
|
|
||||||
|
|
||||||
const enquireScreen = function (call) {
|
|
||||||
const hanlder = {
|
|
||||||
match: function () {
|
|
||||||
call && call(true)
|
|
||||||
},
|
|
||||||
unmatch: function () {
|
|
||||||
call && call(false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
enquireJs.register('only screen and (max-width: 767.99px)', hanlder)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default enquireScreen
|
|
@ -1,3 +1,5 @@
|
|||||||
|
import enquireJs from 'enquire.js'
|
||||||
|
|
||||||
export function isDef (v){
|
export function isDef (v){
|
||||||
return v !== undefined && v !== null
|
return v !== undefined && v !== null
|
||||||
}
|
}
|
||||||
@ -18,4 +20,16 @@ export function isRegExp (v) {
|
|||||||
return _toString.call(v) === '[object RegExp]'
|
return _toString.call(v) === '[object RegExp]'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function enquireScreen(call) {
|
||||||
|
const handler = {
|
||||||
|
match: function () {
|
||||||
|
call && call(true)
|
||||||
|
},
|
||||||
|
unmatch: function () {
|
||||||
|
call && call(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
enquireJs.register('only screen and (max-width: 767.99px)', handler)
|
||||||
|
}
|
||||||
|
|
||||||
const _toString = Object.prototype.toString
|
const _toString = Object.prototype.toString
|
||||||
|
Loading…
x
Reference in New Issue
Block a user