Compare commits

..

2 Commits

Author SHA1 Message Date
yuhan_jiang c156b52d84 Merge branch 'hi-ucs-dev' of http://15.2.21.221:3000/wuhongjian/hi-ucs into hi-ucs-dev
* 'hi-ucs-dev' of http://15.2.21.221:3000/wuhongjian/hi-ucs:
  端口修改
  BUG修改  应用资源新增 能力集市图标  和详情页切换
  bug修改
  bug修复
  BUG修改
  BUG修改

# Conflicts:
#	front/src/utils/request.js
#	front/src/vab/plugins/permissions.js
2022-07-16 16:22:28 +08:00
yuhan_jiang 15eb5dbd13 【单点登录】修复云图需要点击两次才能单点成功问题 2022-07-16 16:16:38 +08:00
4 changed files with 70 additions and 86 deletions

View File

@ -23,11 +23,15 @@ export async function socialLogin(data) {
})
}
export function getUserInfo() {
export function getUserInfo(redict) {
//mock.js使dataaccessToken使mockheaders
// debugger
return request({
url: '/sys/user/info',
method: 'get',
headers: {
REQUESTURI:redict
}
})
}
export function getDeptAll() {

View File

@ -23,24 +23,10 @@ let loadingInstance
* @param {*} msg
*/
const handleCode = (code, msg, res) => {
debugger
// debugger
switch (code) {
case 401:
// message.error(msg || '')
store.dispatch('user/resetAll').catch(() => {})
debugger
// if (res.token) {
// console.log('token', res.token)
// setAccessToken(res.token)
// const token = getAccessToken()
// console.log('token', token)
// }
// // location.reload()
// if (redirect) {
// window.location.href = res.redirect
// }
break
case 403:
router.push({ path: '/401' }).catch(() => {})
@ -72,7 +58,7 @@ const instance = axios.create({
*/
instance.interceptors.request.use(
(config) => {
debugger
// debugger
const token = getAccessToken()
if (token) config.headers[tokenName] = token
if (
@ -84,7 +70,10 @@ instance.interceptors.request.use(
if (debounce.some((item) => config.url.includes(item))) {
//
}
if (!config.headers.REQUESTURI){
config.headers.REQUESTURI = window.location.href
}
return config
},
(error) => {
@ -103,17 +92,13 @@ instance.interceptors.response.use(
console.log('接口返回REDIRECT', response.headers.redirect)
response['Access-Control-Expose-Headers'] = 'redirect'
const { code, message } = response.data
debugger
if (code == '0' && response.headers.token) {
if (response.headers.token) {
setAccessToken(response.headers.token)
} else {
const token = getAccessToken()
if (response.headers.redirect && !token) {
// window.location.href = response.headers.redirect
}
if (response.headers.redirect) {
window.location.replace(response.headers.redirect)
return
// location.reload()
}
}
if (response.headers.redirect === '/#/login') {
var keys = document.cookie.match(/[^ =;]+(?=\=)/g)
@ -158,7 +143,7 @@ instance.interceptors.response.use(
// }
},
(error) => {
debugger
// debugger
console.log('接口error', error)
if (loadingInstance) loadingInstance.close()
@ -167,12 +152,12 @@ instance.interceptors.response.use(
console.log('接口返回', response)
console.log('接口返回headers', response.headers)
console.log('接口返回REDIRECT', response.headers.redirect)
// if (response.headers.token) {
// setAccessToken(response.headers.token)
// }
if (response.headers.token) {
setAccessToken(response.headers.token)
}
if (response.headers.redirect) {
window.location.replace(response.headers.redirect)
// return Promise.resolve()
return Promise.resolve()
}
const { status, data } = response

View File

@ -9,33 +9,34 @@
* @author chuzhixin 1204505056@qq.com
* @description 路由守卫目前两种模式all模式与intelligence模式
*/
import router from '@/router'
import store from '@/store'
import getPageTitle from '@/utils/pageTitle'
import { getUserInfo } from '@/api/user'
import {
import router from '@/router'
import store from '@/store'
import getPageTitle from '@/utils/pageTitle'
import { getUserInfo } from '@/api/user'
import {
// authentication,
loginInterception,
// recordRoute,
routesWhiteList,
} from '@/config'
import { setAccessToken, getAccessToken } from '@/utils/accessToken'
router.beforeEach(async (to, from, next) => {
} from '@/config'
import { setAccessToken, getAccessToken } from '@/utils/accessToken'
router.beforeEach(async (to, from, next) => {
// debugger
// const SSOTOKEN = to.query.SSOToken
// if (SSOTOKEN) {
// setAccessToken(SSOTOKEN)
// }
const token = getAccessToken()
console.log('token', token)
let hasToken = token || store.getters['user/accessToken']
let hasToken = token
// debugger
if (!loginInterception) hasToken = true
console.log('hasToken存在巨大问题', hasToken)
if (hasToken) {
// setAccessToken(hasToken)
await store.dispatch('user/getUserInfo')
debugger
// debugger
next()
} else {
let accessRoutes = []
@ -47,20 +48,14 @@ router.beforeEach(async (to, from, next) => {
next()
} else {
//
getUserInfo().then((res) => {
console.log(res)
router.replace('/home')
if (to.query.redict)
getUserInfo(to.query.redict)
else {
getUserInfo()
}
}
}
})
// await store.dispatch('user/getUserInfo')
// next()
// if (recordRoute)
// next({ path: '/login', query: { redirect: to.path }, replace: true })
// else next({ path: '/login', replace: true })
// next()
// window.open('http://www.baidu.com', '_self')
}
}
})
router.afterEach((to) => {
router.afterEach((to) => {
document.title = getPageTitle(to.meta.title)
})
})

View File

@ -32,7 +32,7 @@
import { useRouter } from 'vue-router'
const router = useRouter()
const goHome = () => {
router.push('/home')
router.push({path: '/home', query:{redict: window.location.origin + '/#/home'}})
}
</script>
<style lang="less">