移动设备判断
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:
@@ -149,6 +149,8 @@
|
||||
s.parentNode.insertBefore(hm, s);
|
||||
})();
|
||||
</script>
|
||||
<script src="./script/ua-parser.min.js"></script>
|
||||
<script src="./script/ua.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<noscript>
|
||||
|
||||
@@ -1,29 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||
<link rel="icon" href="<%= BASE_URL %>icon.ico">
|
||||
<title><%= VUE_APP_TITLE %></title>
|
||||
<script>
|
||||
// 感谢您使用 D2Admin
|
||||
// D2Admin 完全开源免费,并且长期更新维护
|
||||
// 下面的百度统计代码不会拖慢您的应用速度也不会占用多少网络带宽,我们只是想统计一下我们的用户量
|
||||
// 所以希望您不要删除我们的统计代码,让我们知道有更多人的在使用,给我们继续开发的动力
|
||||
var _hmt = _hmt || [];
|
||||
(function() {
|
||||
var hm = document.createElement("script");
|
||||
hm.src = "https://hm.baidu.com/hm.js?20b202d9b1189c9352fc3e8c92c215fc";
|
||||
var s = document.getElementsByTagName("script")[0];
|
||||
s.parentNode.insertBefore(hm, s);
|
||||
})();
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<noscript>
|
||||
<strong>We're sorry but d2-admin-start-kit-cli3 doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
|
||||
</noscript>
|
||||
is-mobile
|
||||
</body>
|
||||
</html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>提示信息</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>请不要使用手机浏览</h1>
|
||||
<!-- 请自行完善此页面 -->
|
||||
</body>
|
||||
</html>
|
||||
1
public/script/ua-parser.min.js.REMOVED.git-id
Normal file
1
public/script/ua-parser.min.js.REMOVED.git-id
Normal file
@@ -0,0 +1 @@
|
||||
ad74810e21f5d982ae8d549334e05bd57d7378a6
|
||||
9
public/script/ua.js
Normal file
9
public/script/ua.js
Normal file
@@ -0,0 +1,9 @@
|
||||
/* eslint-disable */
|
||||
|
||||
var parser = new UAParser()
|
||||
|
||||
var uaResult = parser.getResult()
|
||||
|
||||
if (uaResult.device.type === 'mobile') {
|
||||
window.location.href = './is-mobile.html'
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -53,8 +53,8 @@ new Vue({
|
||||
mounted () {
|
||||
// D2Admin 开发环境检查更新
|
||||
util.checkUpdate(this)
|
||||
// 获取并记录用户 UA 同时对危险环境做出判断
|
||||
util.uaGet(this)
|
||||
// 获取并记录用户 UA
|
||||
this.$store.commit('d2adminUaGet')
|
||||
// 展示系统信息
|
||||
util.showInfo()
|
||||
// 用户登陆后从数据库加载一系列的设置
|
||||
|
||||
@@ -16,17 +16,6 @@ let router = new VueRouter({ routes })
|
||||
* 权限验证
|
||||
*/
|
||||
router.beforeEach((to, from, next) => {
|
||||
const isMobile = util.isMobile()
|
||||
// 禁止手机访问
|
||||
if (to.name !== 'is-mobile' && isMobile) {
|
||||
next({ name: 'is-mobile' })
|
||||
return
|
||||
}
|
||||
// 如果是电脑访问手机提示页面的话 -> 跳转到首页
|
||||
if (to.name === 'is-mobile' && !isMobile) {
|
||||
next({ name: 'index' })
|
||||
return
|
||||
}
|
||||
// 验证当前路由所有的匹配中是否需要有登陆验证的
|
||||
if (to.matched.some(r => r.meta.requiresAuth)) {
|
||||
// 这里暂时将cookie里是否存有token作为验证是否登陆的条件
|
||||
|
||||
@@ -1 +1 @@
|
||||
488c440e7112793c7321bc1ef62f74fe0bba9138
|
||||
e771f2f57cedfc8d2e3e0a07a9b4f1f0ada4f152
|
||||
Reference in New Issue
Block a user