feat: add base path to resources (#17655)

Co-authored-by: fhliu4 <fhliu4@iflytek.com>
This commit is contained in:
diuwu
2025-04-15 17:05:50 +08:00
committed by GitHub
parent 12de1d175c
commit 7161d7ad96
30 changed files with 146 additions and 38 deletions

View File

@@ -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)
}