重定向解注

This commit is contained in:
guoyue 2022-10-08 14:20:51 +08:00
parent 667d53484e
commit 7b4b410538
1 changed files with 20 additions and 20 deletions

View File

@ -82,9 +82,9 @@ instance.interceptors.request.use(
if (debounce.some((item) => config.url.includes(item))) {
//
}
// if (!config.headers.REQUESTURI) {
// config.headers.REQUESTURI = window.location.href
// }
if (!config.headers.REQUESTURI) {
config.headers.REQUESTURI = window.location.href
}
return config
},
@ -108,19 +108,19 @@ instance.interceptors.response.use(
message
} = response.data
// if (response.headers.token) {
// setAccessToken(response.headers.token)
// }
// if (response.headers.redirect) {
// const _old_href = window.location.href.split('#')[0];
// const _new_href = response.headers.redirect.split('#')[0];
// window.location.replace(response.headers.redirect)
// // url
// if (_old_href === _new_href) {
// location.reload()
// }
// return response
// }
if (response.headers.token) {
setAccessToken(response.headers.token)
}
if (response.headers.redirect) {
const _old_href = window.location.href.split('#')[0];
const _new_href = response.headers.redirect.split('#')[0];
window.location.replace(response.headers.redirect)
// url
if (_old_href === _new_href) {
location.reload()
}
return response
}
if (response.headers.redirect === '/#/login') {
var keys = document.cookie.match(/[^ =;]+(?=\=)/g)
if (keys) {
@ -179,10 +179,10 @@ instance.interceptors.response.use(
if (response.headers.token) {
setAccessToken(response.headers.token)
}
// if (response.headers.redirect) {
// window.location.replace(response.headers.redirect)
// return Promise.resolve()
// }
if (response.headers.redirect) {
window.location.replace(response.headers.redirect)
return Promise.resolve()
}
const {
status,
data