mirror of
https://github.com/veops/cmdb.git
synced 2025-08-09 10:16:12 +08:00
Modify code organization
This commit is contained in:
33
cmdb-ui/src/utils/device.js
Normal file
33
cmdb-ui/src/utils/device.js
Normal file
@@ -0,0 +1,33 @@
|
||||
import enquireJs from 'enquire.js'
|
||||
|
||||
export const DEVICE_TYPE = {
|
||||
DESKTOP: 'desktop',
|
||||
TABLET: 'tablet',
|
||||
MOBILE: 'mobile'
|
||||
}
|
||||
|
||||
export const deviceEnquire = function (callback) {
|
||||
const matchDesktop = {
|
||||
match: () => {
|
||||
callback && callback(DEVICE_TYPE.DESKTOP)
|
||||
}
|
||||
}
|
||||
|
||||
const matchLablet = {
|
||||
match: () => {
|
||||
callback && callback(DEVICE_TYPE.TABLET)
|
||||
}
|
||||
}
|
||||
|
||||
const matchMobile = {
|
||||
match: () => {
|
||||
callback && callback(DEVICE_TYPE.MOBILE)
|
||||
}
|
||||
}
|
||||
|
||||
// screen and (max-width: 1087.99px)
|
||||
enquireJs
|
||||
.register('screen and (max-width: 576px)', matchMobile)
|
||||
.register('screen and (min-width: 576px) and (max-width: 1199px)', matchLablet)
|
||||
.register('screen and (min-width: 1200px)', matchDesktop)
|
||||
}
|
Reference in New Issue
Block a user