Commit 76a92bf5 by Sweet Zhang

解决问题

parent 4a4af674
......@@ -11,7 +11,6 @@ interface ApiResult<T> {
data: T
}
<<<<<<< HEAD
/** 错误分类:界面据此决定文案与是否可重试(认证类跳登录,其余可重试)。 */
export type ApiErrorKind = 'auth' | 'timeout' | 'network' | 'server' | 'business'
......@@ -37,19 +36,16 @@ export class ApiError extends Error {
}
}
const instance = axios.create({
baseURL: '/csf/api',
// 不加超时:后端 hang 住时页面 loading 会永久转圈
timeout: 15000
})
=======
const HEADER_MOCK_BROKER = 'X-Mock-Broker-Biz-Id'
// mock-only:本地生产核对环境(.env.development.local),整条 OIDC 链路停用
const mockOnly = isMockOnly
const instance = axios.create({ baseURL: '/csf/api' })
>>>>>>> 0cac32e9c611857dfc32d14724490175aac1f693
const instance = axios.create({
baseURL: '/csf/api',
// 不加超时:后端 hang 住时页面 loading 会永久转圈
timeout: 15000
})
instance.interceptors.request.use(async (config) => {
// DEV 模拟身份优先于 OIDC(仅在 dev 构建中可能有值)
......@@ -73,17 +69,12 @@ let redirecting = false
instance.interceptors.response.use(
(response) => response,
(error) => {
<<<<<<< HEAD
const status: number | undefined = error.response?.status
if (status === 401) {
if (!redirecting && window.location.pathname !== '/auth/callback') {
=======
if (error.response?.status === 401) {
// mock-only / 已选模拟身份时 401 交给页面处理,不跳 OIDC
const mockActive = mockOnly || (import.meta.env.DEV && !!getMockBrokerBizId())
if (!mockActive && !redirecting && window.location.pathname !== '/auth/callback') {
>>>>>>> 0cac32e9c611857dfc32d14724490175aac1f693
redirecting = true
// 跳转失败(IdP 不可达)时必须复位,否则此后再也不重定向,页面卡死在错误态
signinRedirect(window.location.pathname + window.location.search).catch(() => {
......@@ -124,4 +115,4 @@ export async function get<T>(path: string): Promise<T> {
export async function post<T>(path: string, body?: unknown): Promise<T> {
const res = await instance.post<ApiResult<T>>(path, body)
return unwrap(res.data)
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment