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 @@ -
- - -
+ + + +
-
- 合众未来 - HEZHONGWEILAI -
+ + + +
@@ -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 @@ - + 自动登录 - + sso登录 @@ -194,8 +194,8 @@ import Vue from 'vue' import { putAction, postAction, getAction } from '@/api/manage' import { getRSAPublicKey } from '@/api/login.js' - import { login, logout, phoneLogin, thirdLogin } from "@/api/login" - import { ACCESS_TOKEN, USER_NAME,USER_INFO,UI_CACHE_DB_DICT_DATA } from "@/store/mutation-types" + import { login, logout, phoneLogin, thirdLogin } from '@/api/login' + import { ACCESS_TOKEN, USER_NAME, USER_INFO, UI_CACHE_DB_DICT_DATA } from '@/store/mutation-types' const Base64 = require('js-base64').Base64 import { JSEncrypt } from 'jsencrypt' @@ -229,7 +229,7 @@ randCodeImage: '', requestCodeSuccess: false, rsaPublicKey: '', - code:'' + code: '' } }, created() { @@ -237,12 +237,12 @@ Vue.ls.remove(ACCESS_TOKEN) this.handleChangeCheckCode() - let query =[] - if(this.$route.query.redirect){ - query=this.$route.query.redirect.includes('code=')?this.$route.query.redirect.split('code='):[] - this.code=query[1] + let query = [] + if (this.$route.query.redirect) { + query = this.$route.query.redirect.includes('code=') ? this.$route.query.redirect.split('code=') : [] + this.code = query[1] } - if(this.code){ + if (this.code) { this.ssoLoginSuccess() } this.getRouterData() @@ -358,7 +358,13 @@ if (!langCn) { localStorage.setItem('language', 'zh-cn') } - this.$router.push({ path: '/dashboard/analysis' }).catch((res) => { + let fullPath = '' + if (this.mobile) { + fullPath = '/phoneSearch' + } else { + fullPath = '/dashboard/analysis' + } + this.$router.push({ path: fullPath }).catch((res) => { }) this.$notification.success({ message: '欢迎', @@ -413,11 +419,11 @@ }) }, //sso登录跳转 - ssoLogin(){ + ssoLogin() { window.open('https://signin-test.nio.com/oauth2/authorize?client_id=100679&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fdashboard%2Fanalysis&response_type=code', '_blank') }, //sso登录 - ssoLoginSuccess(){ + ssoLoginSuccess() { let that = this let loginParams = {} loginParams.checkKey = that.currdatetime @@ -425,24 +431,28 @@ // 新建JSEncrypt对象 let encrypt = new JSEncrypt() encrypt.setPublicKey(loginParams.rsaPublicKey) - getAction(`opensso/callback`,{code:this.code}).then(res=>{ - if(res.success){ + getAction(`opensso/callback`, { code: this.code }).then(res => { + if (res.success) { Vue.ls.set(ACCESS_TOKEN, res.result.token, 7 * 24 * 60 * 60 * 1000) Vue.ls.set(USER_NAME, res.result.userInfo.username, 7 * 24 * 60 * 60 * 1000) Vue.ls.set(USER_INFO, res.result.userInfo, 7 * 24 * 60 * 60 * 1000) Vue.ls.set(UI_CACHE_DB_DICT_DATA, res.result.sysAllDictItems, 7 * 24 * 60 * 60 * 1000) this.$store.commit('SET_TOKEN', res.result.token) this.$store.commit('SET_INFO', res.result.userInfo) - this.$store.commit('SET_NAME', { username: res.result.userInfo.username,realname: res.result.userInfo.realname, welcome: welcome() }) + this.$store.commit('SET_NAME', { + username: res.result.userInfo.username, + realname: res.result.userInfo.realname, + welcome: welcome() + }) this.$store.commit('SET_AVATAR', res.result.userInfo.avatar) this.loginSuccess() - }else if(res.message=='【单点登录】获取access_token失败'){ + } else if (res.message == '【单点登录】获取access_token失败') { this.ssoLogin() - }else{ + } else { this.$message.error(res.message) } }) - }, + } } } @@ -529,9 +539,9 @@ height: 46% !important; background: transparent; min-height: 0; - padding: 0 2rem 0 2rem; + padding: 0 0.4rem 0 0.4rem; position: absolute; - top: 50%; + top: 3.6rem; margin-top: 6rem; transform: translateY(-50%);