is-mobile页面
Former-commit-id: c859c0a360ad0d23b45c479e4d9e39edbca03cf8 [formerly c859c0a360ad0d23b45c479e4d9e39edbca03cf8 [formerly c859c0a360ad0d23b45c479e4d9e39edbca03cf8 [formerly c859c0a360ad0d23b45c479e4d9e39edbca03cf8 [formerly e67ff51ddc4498da1d45a5ed1b29a006e284ca9e [formerly 0847d1f0e60a9992c4e4457d35eff0d981c0e79e]]]]] Former-commit-id: 4bbc804527be8d0b049558d616926d107964d630 Former-commit-id: 0aa8a6c02f2474fe40761b65e958b6a862a809b0 Former-commit-id: b4aa260b2fc851f1411723a10980ec8eeb8812a1 [formerly ea0cd16fec9ecf1f5d8ae5fef8371f858a53f4a2] Former-commit-id: 14f651f5bdeeeee713f9fabfd1cd94836c7ff1b1 Former-commit-id: 4ad96fab15f02793f4727c5f047679cf90d5c7f4 Former-commit-id: 2958b0c9a6e039c6aeb9888a250428559e91171c Former-commit-id: 1ae356951e27fc2a841da0028f5fe08f89d2eb58 Former-commit-id: a25fa4db9e8516374c6379e67a331e0903985d8e
This commit is contained in:
@@ -3,6 +3,7 @@ import Cookies from 'js-cookie'
|
||||
import axios from 'axios'
|
||||
import semver from 'semver'
|
||||
import dayjs from 'dayjs'
|
||||
import UaParser from 'ua-parser-js'
|
||||
|
||||
// 获取项目信息
|
||||
import packJson from '../../package.json'
|
||||
@@ -10,7 +11,7 @@ import packJson from '../../package.json'
|
||||
let util = {}
|
||||
|
||||
/**
|
||||
* @description 得到现在的用户
|
||||
* @description 得到现在的用户 uuid
|
||||
*/
|
||||
util.uuid = function () {
|
||||
return Cookies.get('uuid')
|
||||
@@ -20,10 +21,39 @@ util.uuid = function () {
|
||||
* @description 更新标题
|
||||
* @param {string} title 标题
|
||||
*/
|
||||
util.title = function title (titleText) {
|
||||
util.title = function (titleText) {
|
||||
window.document.title = `${process.env.VUE_APP_TITLE}${titleText ? ` | ${titleText}` : ''}`
|
||||
}
|
||||
|
||||
/**
|
||||
* @description [ 私有 ] 获取所有的 UA 信息
|
||||
*/
|
||||
function getUa () {
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user