diff --git a/src/MobileApp.vue b/src/MobileApp.vue
new file mode 100644
index 0000000..3455e04
--- /dev/null
+++ b/src/MobileApp.vue
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
diff --git a/src/assets/image/notMobile.png b/src/assets/image/notMobile.png
new file mode 100644
index 0000000..f32f119
Binary files /dev/null and b/src/assets/image/notMobile.png differ
diff --git a/src/main.js b/src/main.js
index b987338..5ee5a6b 100644
--- a/src/main.js
+++ b/src/main.js
@@ -3,6 +3,7 @@
import Vue from 'vue'
import App from './App.vue'
+import MobileApp from './MobileApp'
import Storage from 'vue-ls'
import router from './router'
import store from './store/'
@@ -49,6 +50,7 @@ import JDictComponenets from '@comp/dict/index.js'
import JTable from '@comp/jero/JTable.vue'
import i18n from '@/common/lang'
+import { isMobile } from '@/utils/util'
// Vue.prototype.rules = rules
Vue.config.productionTip = false
@@ -101,7 +103,7 @@ function main () {
store.commit('SET_TOKEN', Vue.ls.get(ACCESS_TOKEN))
store.commit('SET_MULTI_PAGE', Vue.ls.get(DEFAULT_MULTI_PAGE, config.multipage))
},
- render: h => h(App),
+ render: h => h(isMobile() ? MobileApp : App),
data: {
Bus: new Vue()
}
diff --git a/src/permission.js b/src/permission.js
index 8d90252..d551183 100644
--- a/src/permission.js
+++ b/src/permission.js
@@ -4,7 +4,7 @@ import store from './store'
import NProgress from 'nprogress' // progress bar
import 'nprogress/nprogress.css' // progress bar style
import { ACCESS_TOKEN, OAUTH2_LOGIN_PAGE_PATH, UI_CACHE_DB_DICT_DATA, USER_INFO, USER_NAME } from '@/store/mutation-types'
-import { generateIndexRouter, isOAuth2AppEnv, findFirstRoute, welcome } from '@/utils/util'
+import { generateIndexRouter, isOAuth2AppEnv, findFirstRoute, welcome, isMobile } from '@/utils/util'
import { getSSOUserInfo, getTodoSSOUserInfo } from './api/api'
import { updatePageHeight } from './components/tools/setting'
@@ -14,6 +14,14 @@ const whiteList = ['/user/login', '/user/register', '/user/register-result', '/u
whiteList.push(OAUTH2_LOGIN_PAGE_PATH)
router.beforeEach(async (to, from, next) => {
+ if (isMobile()) {
+ if (to.path !== '/') {
+ next({ path: '/' })
+ } else {
+ next()
+ }
+ return
+ }
// 单点登录-OA单点登录
if (to.query.ticket) {
const { result, success, message } = await getTodoSSOUserInfo({ ticket: to.query.ticket })
diff --git a/src/utils/util.js b/src/utils/util.js
index 2f813bd..b522f9c 100644
--- a/src/utils/util.js
+++ b/src/utils/util.js
@@ -761,3 +761,28 @@ export function findNodeByField (tree, findVal, valueField = 'id', childrenField
}
return null
}
+
+// 判断当前是否移动端
+export function isMobile () {
+ const userAgentInfo = navigator.userAgent
+
+ const mobileAgents = ['Android', 'iPhone', 'SymbianOS', 'Windows Phone', 'iPad', 'iPod']
+
+ let mobileFlag = false
+
+ // 根据userAgent判断是否是手机
+ for (let v = 0; v < mobileAgents.length; v++) {
+ if (userAgentInfo.indexOf(mobileAgents[v]) > 0) {
+ mobileFlag = true
+ break
+ }
+ }
+ const screenWidth = window.screen.width
+ const screenHeight = window.screen.height
+
+ // 根据屏幕分辨率判断是否是手机
+ if (screenWidth < 500 && screenHeight < 800) {
+ mobileFlag = true
+ }
+ return mobileFlag
+}