update 单点登录

This commit is contained in:
赵霄
2023-10-31 16:27:50 +08:00
parent e2d09defdb
commit cafeac6eba
+5 -4
View File
@@ -14,9 +14,8 @@ const whiteList = ['/user/login', '/user/register', '/user/register-result', '/u
whiteList.push(OAUTH2_LOGIN_PAGE_PATH)
router.beforeEach(async (to, from, next) => {
console.log(to.query)
// 单点登录
if (to.query.code && !Vue.ls.get(ACCESS_TOKEN)) {
if (to.query.code) {
const { result } = await getSSOUserInfo({ code: to.query.code })
const userInfo = result.userInfo
Vue.ls.set(ACCESS_TOKEN, result.token, 7 * 24 * 60 * 60 * 1000)
@@ -71,8 +70,10 @@ router.beforeEach(async (to, from, next) => {
// 根据roles权限生成可访问的路由表
// 动态添加可访问路由表
router.addRoutes(store.getters.addRouters)
const redirect = decodeURIComponent(from.query.redirect || to.path)
console.log(redirect)
let redirect = decodeURIComponent(from.query.redirect || to.fullPath)
if (redirect.indexOf('code') !== -1) {
redirect = redirect.substring(0, redirect.indexOf('code'))
}
if (to.path === redirect) {
if (to.path === '/enterpriseStandardLibrary/enterpriseStandardDetail') {
// 跳企标详情,需要判断是否能看详情