feat: add base path to resources (#17655)
Co-authored-by: fhliu4 <fhliu4@iflytek.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { API_PREFIX, IS_CE_EDITION, PUBLIC_API_PREFIX } from '@/config'
|
||||
import { refreshAccessTokenOrRelogin } from './refresh-token'
|
||||
import Toast from '@/app/components/base/toast'
|
||||
import { basePath } from '@/utils/var'
|
||||
import type { AnnotationReply, MessageEnd, MessageReplace, ThoughtItem } from '@/app/components/base/chat/chat/type'
|
||||
import type { VisionFile } from '@/types/app'
|
||||
import type {
|
||||
@@ -466,7 +467,7 @@ export const request = async<T>(url: string, options = {}, otherOptions?: IOther
|
||||
const errResp: Response = err as any
|
||||
if (errResp.status === 401) {
|
||||
const [parseErr, errRespData] = await asyncRunSafe<ResponseError>(errResp.json())
|
||||
const loginUrl = `${globalThis.location.origin}/signin`
|
||||
const loginUrl = `${globalThis.location.origin}${basePath}/signin`
|
||||
if (parseErr) {
|
||||
globalThis.location.href = loginUrl
|
||||
return Promise.reject(err)
|
||||
@@ -498,11 +499,11 @@ export const request = async<T>(url: string, options = {}, otherOptions?: IOther
|
||||
return Promise.reject(err)
|
||||
}
|
||||
if (code === 'not_init_validated' && IS_CE_EDITION) {
|
||||
globalThis.location.href = `${globalThis.location.origin}/init`
|
||||
globalThis.location.href = `${globalThis.location.origin}${basePath}/init`
|
||||
return Promise.reject(err)
|
||||
}
|
||||
if (code === 'not_setup' && IS_CE_EDITION) {
|
||||
globalThis.location.href = `${globalThis.location.origin}/install`
|
||||
globalThis.location.href = `${globalThis.location.origin}${basePath}/install`
|
||||
return Promise.reject(err)
|
||||
}
|
||||
|
||||
@@ -510,7 +511,7 @@ export const request = async<T>(url: string, options = {}, otherOptions?: IOther
|
||||
const [refreshErr] = await asyncRunSafe(refreshAccessTokenOrRelogin(TIME_OUT))
|
||||
if (refreshErr === null)
|
||||
return baseFetch<T>(url, options, otherOptionsForBaseFetch)
|
||||
if (location.pathname !== '/signin' || !IS_CE_EDITION) {
|
||||
if (location.pathname !== `${basePath}/signin` || !IS_CE_EDITION) {
|
||||
globalThis.location.href = loginUrl
|
||||
return Promise.reject(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user