This commit is contained in:
parent
00a87948c2
commit
7d7f652e93
@ -46,13 +46,19 @@ function attachApiErrorDetails(error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function isSetupRequest(config) {
|
function isSetupRequest(config) {
|
||||||
const url = String(config?.url || '').split('?')[0]
|
const rawUrl = String(config?.url || '').split('?')[0]
|
||||||
return url === '/api/setup' || url === '/api/v1/setup'
|
let path = rawUrl
|
||||||
|
try {
|
||||||
|
path = new URL(rawUrl, config?.baseURL || window.location.origin).pathname
|
||||||
|
} catch (error) {
|
||||||
|
path = rawUrl
|
||||||
|
}
|
||||||
|
return path === '/api/setup' || path === '/api/v1/setup'
|
||||||
}
|
}
|
||||||
|
|
||||||
http.interceptors.response.use(async (response) => {
|
http.interceptors.response.use(async (response) => {
|
||||||
//响应成功
|
//响应成功
|
||||||
if (response.data.errorNo === 403 && !isSetupRequest(response.config)) {
|
if (response.data?.errorNo === 403 && !isSetupRequest(response.config)) {
|
||||||
|
|
||||||
await router.replace({
|
await router.replace({
|
||||||
path: '/login',
|
path: '/login',
|
||||||
@ -62,7 +68,7 @@ http.interceptors.response.use(async (response) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
//响应成功
|
//响应成功
|
||||||
if (response.data.errorNo === 402) {
|
if (response.data?.errorNo === 402 && !isSetupRequest(response.config)) {
|
||||||
await router.replace({
|
await router.replace({
|
||||||
path: '/setup',
|
path: '/setup',
|
||||||
query: {
|
query: {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user