From 6f399ed94e88e22f00642597c80bab8b2441315b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8C=83=E5=BC=BA=E5=BC=BA?= <787203167> Date: Mon, 12 Jun 2023 09:58:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=89=8B=E6=9C=BA=E7=AB=AF?= =?UTF-8?q?=E7=9A=84=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/layouts/UserLayout.vue | 18 +++---- jero-web/src/permission.js | 52 +++++++++++++++++-- jero-web/src/views/user/Login.vue | 52 +++++++++++-------- 3 files changed, 88 insertions(+), 34 deletions(-) diff --git a/jero-web/src/components/layouts/UserLayout.vue b/jero-web/src/components/layouts/UserLayout.vue index ebb4b15bd..607454014 100644 --- a/jero-web/src/components/layouts/UserLayout.vue +++ b/jero-web/src/components/layouts/UserLayout.vue @@ -10,18 +10,18 @@ -
-
-
@@ -174,7 +174,7 @@
height: 100%;
.mobile{
position: absolute;
- top: 6rem;
+ top: 3rem;
width: 100%;
display: flex;
flex-direction: column;
diff --git a/jero-web/src/permission.js b/jero-web/src/permission.js
index e040aff0b..ab77712ff 100644
--- a/jero-web/src/permission.js
+++ b/jero-web/src/permission.js
@@ -10,6 +10,32 @@ import { JSEncrypt } from 'jsencrypt'
import { getAction } from '@/api/manage'
import { welcome } from '@/utils/util'
+// 判断当前设备
+function isMobile() {
+ var userAgentInfo = navigator.userAgent
+
+ var mobileAgents = ['Android', 'iPhone', 'SymbianOS', 'Windows Phone', 'iPad', 'iPod']
+
+ var mobile_flag = false
+
+ //根据userAgent判断是否是手机
+ for (var v = 0; v < mobileAgents.length; v++) {
+ if (userAgentInfo.indexOf(mobileAgents[v]) > 0) {
+ mobile_flag = true
+ break
+ }
+ }
+ var screen_width = window.screen.width
+ var screen_height = window.screen.height
+
+ //根据屏幕分辨率判断是否是手机
+ if (screen_width < 500 && screen_height < 800) {
+ mobile_flag = true
+ }
+ return mobile_flag
+}
+
+let mobile = isMobile()
NProgress.configure({ showSpinner: false }) // NProgress Configuration
// TODO 线上部署在conmponetns/tools/UserMenu.vue的退出登录时需解开代码以及注释代码
@@ -46,7 +72,11 @@ router.beforeEach((to, from, next) => {
store.commit('SET_AVATAR', res.result.userInfo.avatar)
let fullPath = ''
if (to.fullPath == '/') {
- fullPath = INDEX_MAIN_PAGE_PATH
+ if (mobile) {
+ fullPath = '/phoneSearch'
+ } else {
+ fullPath = INDEX_MAIN_PAGE_PATH
+ }
} else {
fullPath = to.path
}
@@ -64,7 +94,13 @@ router.beforeEach((to, from, next) => {
if (Vue.ls.get(ACCESS_TOKEN)) {
/* has token */
if (to.path === '/user/login') {
- next({ path: INDEX_MAIN_PAGE_PATH })
+ let fullPath = ''
+ if (mobile) {
+ fullPath = '/phoneSearch'
+ } else {
+ fullPath = INDEX_MAIN_PAGE_PATH
+ }
+ next({ path: fullPath })
NProgress.done()
} else {
if (store.getters.permissionList.length === 0) {
@@ -81,7 +117,11 @@ router.beforeEach((to, from, next) => {
// 根据roles权限生成可访问的路由表
// 动态添加可访问路由表
router.addRoutes(store.getters.addRouters)
- const redirect = decodeURIComponent(from.query.redirect || to.path)
+ let redirect = decodeURIComponent(from.query.redirect || to.path)
+ if (mobile) {
+ redirect = '/phoneSearch'
+ }
+ console.log(redirect)
if (to.path === redirect) {
// hack方法 确保addRoutes已完成 ,set the replace: true so the navigation will not leave a history record
next({ ...to, replace: true })
@@ -103,7 +143,11 @@ router.beforeEach((to, from, next) => {
let fullPath = ''
if (to.fullPath == '/') {
- fullPath = INDEX_MAIN_PAGE_PATH
+ if (mobile) {
+ fullPath = '/phoneSearch'
+ } else {
+ fullPath = INDEX_MAIN_PAGE_PATH
+ }
} else {
fullPath = to.path
}
diff --git a/jero-web/src/views/user/Login.vue b/jero-web/src/views/user/Login.vue
index 868eb8246..35a450bb2 100644
--- a/jero-web/src/views/user/Login.vue
+++ b/jero-web/src/views/user/Login.vue
@@ -148,12 +148,12 @@