公共服务平台跳转问题
This commit is contained in:
parent
de851f4147
commit
f254838154
|
|
@ -108,7 +108,7 @@ export default {
|
||||||
type: 'warning'
|
type: 'warning'
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
this.$store.dispatch('LogOut').then(() => {
|
this.$store.dispatch('LogOut').then(() => {
|
||||||
location.href = '/glweb/';
|
location.href = '/glweb/#/login';
|
||||||
})
|
})
|
||||||
}).catch(() => {});
|
}).catch(() => {});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -162,7 +162,7 @@ export default {
|
||||||
},
|
},
|
||||||
close() {
|
close() {
|
||||||
this.$store.dispatch('LogOut').then(() => {
|
this.$store.dispatch('LogOut').then(() => {
|
||||||
location.href = '/glweb/';
|
location.href = '/glweb/#/login';
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,9 @@ import NProgress from 'nprogress'
|
||||||
import 'nprogress/nprogress.css'
|
import 'nprogress/nprogress.css'
|
||||||
import { getToken } from '@/utils/auth'
|
import { getToken } from '@/utils/auth'
|
||||||
import { isRelogin } from '@/utils/request'
|
import { isRelogin } from '@/utils/request'
|
||||||
|
import {bnsCloudDecrypt} from "@/utils/aes_new";
|
||||||
|
import Cookies from "js-cookie";
|
||||||
|
import { encrypt, decrypt } from '@/utils/jsencrypt'
|
||||||
NProgress.configure({ showSpinner: false })
|
NProgress.configure({ showSpinner: false })
|
||||||
|
|
||||||
const whiteList = ['/login', '/register']
|
const whiteList = ['/login', '/register']
|
||||||
|
|
@ -16,7 +18,7 @@ router.beforeEach((to, from, next) => {
|
||||||
to.meta.title && store.dispatch('settings/setTitle', to.meta.title)
|
to.meta.title && store.dispatch('settings/setTitle', to.meta.title)
|
||||||
/* has token*/
|
/* has token*/
|
||||||
if (to.path === '/login') {
|
if (to.path === '/login') {
|
||||||
next({ path: '/' })
|
next({ path: '/login' })
|
||||||
NProgress.done()
|
NProgress.done()
|
||||||
} else if (whiteList.indexOf(to.path) !== -1) {
|
} else if (whiteList.indexOf(to.path) !== -1) {
|
||||||
next()
|
next()
|
||||||
|
|
@ -34,7 +36,7 @@ router.beforeEach((to, from, next) => {
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
store.dispatch('LogOut').then(() => {
|
store.dispatch('LogOut').then(() => {
|
||||||
Message.error(err)
|
Message.error(err)
|
||||||
next({ path: '/' })
|
next({ path: '/login' })
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -47,12 +49,32 @@ router.beforeEach((to, from, next) => {
|
||||||
// 在免登录白名单,直接进入
|
// 在免登录白名单,直接进入
|
||||||
next()
|
next()
|
||||||
} else {
|
} else {
|
||||||
next(`/login?redirect=${encodeURIComponent(to.fullPath)}`) // 否则全部重定向到登录页
|
// console.log(to)
|
||||||
|
if(to.redirectedFrom=='/'){
|
||||||
|
next(`/login`)
|
||||||
|
}else{
|
||||||
|
if(!to.query.params){
|
||||||
|
next(`/login`)
|
||||||
|
}else{
|
||||||
|
let str = bnsCloudDecrypt(to.query.params)
|
||||||
|
let username = str.split("&")[0].split("=")[1]
|
||||||
|
let password = str.split("&")[1].split("=")[1]
|
||||||
|
Cookies.set("username", username, { expires: 30 });
|
||||||
|
Cookies.set("password", encrypt(password), { expires: 30 });
|
||||||
|
Cookies.set('rememberMe', true, { expires: 30 });
|
||||||
|
store.dispatch("Login", {'username':username,'password':password,'loginType':"USERNAME_PASSWORD"}).then(() => {
|
||||||
|
console.log(3)
|
||||||
|
next({ ...to, replace: true })
|
||||||
|
}).catch(() => {});
|
||||||
|
}
|
||||||
|
}
|
||||||
NProgress.done()
|
NProgress.done()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
router.afterEach(() => {
|
router.afterEach(() => {
|
||||||
NProgress.done()
|
NProgress.done()
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
// src/utils/aesUtil.js
|
||||||
|
import CryptoJS from 'crypto-js'
|
||||||
|
//公告服务平台加密参数跳转到本系统后参数解密
|
||||||
|
/**
|
||||||
|
* AES解密函数
|
||||||
|
* @param {string} word - 需要解密的字符串
|
||||||
|
* @returns {string} 解密后的明文
|
||||||
|
*/
|
||||||
|
export function bnsCloudDecrypt(word) {
|
||||||
|
const key = CryptoJS.enc.Utf8.parse("bonus@cloud@2025")
|
||||||
|
const decrypt = CryptoJS.AES.decrypt(word, key, {
|
||||||
|
mode: CryptoJS.mode.ECB,
|
||||||
|
padding: CryptoJS.pad.Pkcs7
|
||||||
|
})
|
||||||
|
return CryptoJS.enc.Utf8.stringify(decrypt).toString()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AES加密函数
|
||||||
|
* @param {string} word - 需要加密的明文
|
||||||
|
* @returns {string} 加密后的字符串
|
||||||
|
*/
|
||||||
|
export function bnsCloudEncrypt(word) {
|
||||||
|
const key = CryptoJS.enc.Utf8.parse("bonus@cloud@2025")
|
||||||
|
const srcs = CryptoJS.enc.Utf8.parse(word)
|
||||||
|
const encrypted = CryptoJS.AES.encrypt(srcs, key, {
|
||||||
|
mode: CryptoJS.mode.ECB,
|
||||||
|
padding: CryptoJS.pad.Pkcs7
|
||||||
|
})
|
||||||
|
return encrypted.toString()
|
||||||
|
}
|
||||||
|
|
||||||
|
export default {
|
||||||
|
bnsCloudDecrypt,
|
||||||
|
bnsCloudEncrypt
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import Cookies from 'js-cookie'
|
import Cookies from 'js-cookie'
|
||||||
|
|
||||||
const TokenKey = 'Admin-Token'
|
const TokenKey = 'Glweb-Token'
|
||||||
|
|
||||||
const ExpiresInKey = 'Admin-Expires-In'
|
const ExpiresInKey = 'Admin-Expires-In'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -120,7 +120,7 @@ service.interceptors.response.use(res => {
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
isRelogin.show = false
|
isRelogin.show = false
|
||||||
store.dispatch('LogOut').then(() => {
|
store.dispatch('LogOut').then(() => {
|
||||||
location.href = '/glweb/'
|
location.href = '/glweb/#/canteen/index'
|
||||||
})
|
})
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
isRelogin.show = false
|
isRelogin.show = false
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ module.exports = {
|
||||||
// detail: https://cli.vuejs.org/config/#devserver-proxy
|
// detail: https://cli.vuejs.org/config/#devserver-proxy
|
||||||
[process.env.VUE_APP_BASE_API]: {
|
[process.env.VUE_APP_BASE_API]: {
|
||||||
// target: `http://192.168.2.75:48380`,//旭
|
// target: `http://192.168.2.75:48380`,//旭
|
||||||
target: `http://192.168.20.234:48390`,//测试
|
target: `http://192.168.0.244:48380`,//测试
|
||||||
// target: `http://192.168.20.242:48380`,//测试
|
// target: `http://192.168.20.242:48380`,//测试
|
||||||
// target: `http://192.168.2.108:48380`,//测试
|
// target: `http://192.168.2.108:48380`,//测试
|
||||||
// target: `http://192.168.0.34:48380`,//测试
|
// target: `http://192.168.0.34:48380`,//测试
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue