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:
liyang
2018-07-17 23:59:20 +08:00
parent 6f2ccca853
commit 1c46f5e5d7
11 changed files with 77 additions and 8 deletions

View File

@@ -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

View File

@@ -51,6 +51,11 @@ new Vue({
this.$store.commit('d2adminMenusHeaderSet', menusHeader)
},
mounted () {
// D2Admin 开发环境检查更新
util.checkUpdate(this)
// 获取并记录用户 UA 同时对危险环境做出判断
util.uaGet(this)
// 展示系统信息
util.showInfo()
// DB -> store 加载用户名
this.$store.commit('d2adminUsernameLoad')
@@ -58,8 +63,6 @@ new Vue({
this.$store.commit('d2adminThemeLoad')
// DB -> store 数据库加载上次退出时的多页列表
this.$store.commit('d2adminPageOpenedListLoad')
// D2Admin 开发环境检查更新
util.checkUpdate(this)
// 初始化全屏监听
this.fullscreenListenerInit()
},

View File

@@ -1,3 +1,3 @@
import page from './dashboard'
import page from './page'
export default page

View File

@@ -1,3 +1,3 @@
import page from './error-page-404'
import page from './page'
export default page

View File

@@ -0,0 +1,3 @@
import page from './page'
export default page

View File

@@ -0,0 +1,28 @@
<template>
<div class="page">
<img src="./image/icon@2x.png" class="icon">
<p class="title">系统暂未对移动设备提供支持</p>
<p class="sub-title">请使用PC访问</p>
</div>
</template>
<style lang="scss" scoped>
@import '~@/assets/style/public.scss';
.page {
@extend %full;
@extend %flex-center-col;
background-color: #EDF4FA;
.icon {
width: 42px;
}
.title {
font-size: 14px;
color: #35495E;
}
.sub-title {
font-size: 12px;
color: #35495E;
margin: 0px;
}
}
</style>

View File

@@ -16,6 +16,11 @@ let router = new VueRouter({ routes })
* 权限验证
*/
router.beforeEach((to, from, next) => {
// 禁止手机访问
if (to.name !== 'is-mobile' && util.isMobile()) {
next({ name: 'is-mobile' })
return
}
// 验证当前路由所有的匹配中是否需要有登陆验证的
if (to.matched.some(r => r.meta.requiresAuth)) {
// 这里暂时将cookie里是否存有token作为验证是否登陆的条件

View File

@@ -1 +1 @@
b48413cb8c217f7ecaf10be1313caa442cffe91b
51bf6b20922ac42bc614d4dafc3928f2f9017796

View File

@@ -1 +1 @@
303f0d76d55f00375ac5d17efcd00212c3bc2619
2831ac4870bc4916671225959f7721a1eeb52ebd