移动设备判断

Former-commit-id: b0fcd554d934259ea58187452785c3a9a56c64a4 [formerly b0fcd554d934259ea58187452785c3a9a56c64a4 [formerly b0fcd554d934259ea58187452785c3a9a56c64a4 [formerly b0fcd554d934259ea58187452785c3a9a56c64a4 [formerly 34226601ec79c52767f74109b1813a396d2dc605 [formerly dbb1af9b0c7b60efa8f8b9f9bee8da61b3197ac3]]]]]
Former-commit-id: 4a0fac504665277509d1f4a65fa63eddf170bfc1
Former-commit-id: 3666dfaef0e6eb43a62959a00832a67540a9e0df
Former-commit-id: 14836b621d0f8d0b3d0982eec086fa6334afd80d [formerly 5b1ed7a7065b47fd37de6ed71db4c6b709ded728]
Former-commit-id: ac7827d7b5674c7bb57764686c10f1721d4ceca7
Former-commit-id: 4bb10eb0e6081ef9556380c92a992b810936477f
Former-commit-id: 12fa567115e57ce5da084eaa1cbd5e0d842f470d
Former-commit-id: a927e3bc505c09154e1054d0aee79d42711570aa
Former-commit-id: 8907e13de1ebe0478bc1d7776553f156e361ec37
This commit is contained in:
liyang
2018-07-21 08:47:51 +08:00
parent 87b8f26a85
commit 07dc8bf834
8 changed files with 29 additions and 66 deletions

View File

@@ -26,34 +26,12 @@ util.title = function (titleText) {
}
/**
* @description [ 私有 ] 获取所有的 UA 信息
* @description 获取所有的 UA 信息
*/
function getUa () {
util.ua = function () {
return new UaParser().getResult()
}
/**
* @description 返回当前设备是否是手机
*/
util.isMobile = function (ua) {
return (ua || getUa()).device.type === 'mobile'
}
/**
* @description 获取并存储用户 UA 同时对危险环境做检查
* @param {object} vm vue
*/
util.uaGet = function (vm) {
// 获取 UA
const ua = getUa()
// 存储
vm.$store.commit('d2adminUaSet', ua)
// 判断
if (util.isMobile(ua)) {
vm.$router.replace({ name: 'is-mobile' })
}
}
/**
* @description 判断是否在其内
* @param {*} ele element