Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yd-csf-h5
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
jianan
yd-csf-h5
Commits
76a92bf5
Commit
76a92bf5
authored
Oct 29, 2026
by
Sweet Zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
解决问题
parent
4a4af674
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
15 deletions
+7
-15
src/api/http.ts
+7
-15
No files found.
src/api/http.ts
View file @
76a92bf5
...
@@ -11,7 +11,6 @@ interface ApiResult<T> {
...
@@ -11,7 +11,6 @@ interface ApiResult<T> {
data
:
T
data
:
T
}
}
<<<<<<<
HEAD
/** 错误分类:界面据此决定文案与是否可重试(认证类跳登录,其余可重试)。 */
/** 错误分类:界面据此决定文案与是否可重试(认证类跳登录,其余可重试)。 */
export
type
ApiErrorKind
=
'auth'
|
'timeout'
|
'network'
|
'server'
|
'business'
export
type
ApiErrorKind
=
'auth'
|
'timeout'
|
'network'
|
'server'
|
'business'
...
@@ -37,19 +36,16 @@ export class ApiError extends Error {
...
@@ -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'
const
HEADER_MOCK_BROKER
=
'X-Mock-Broker-Biz-Id'
// mock-only:本地生产核对环境(.env.development.local),整条 OIDC 链路停用
// mock-only:本地生产核对环境(.env.development.local),整条 OIDC 链路停用
const
mockOnly
=
isMockOnly
const
mockOnly
=
isMockOnly
const
instance
=
axios
.
create
({
baseURL
:
'/csf/api'
})
const
instance
=
axios
.
create
({
>>>>>>>
0
cac32e9c611857dfc32d14724490175aac1f693
baseURL
:
'/csf/api'
,
// 不加超时:后端 hang 住时页面 loading 会永久转圈
timeout
:
15000
})
instance
.
interceptors
.
request
.
use
(
async
(
config
)
=>
{
instance
.
interceptors
.
request
.
use
(
async
(
config
)
=>
{
// DEV 模拟身份优先于 OIDC(仅在 dev 构建中可能有值)
// DEV 模拟身份优先于 OIDC(仅在 dev 构建中可能有值)
...
@@ -73,17 +69,12 @@ let redirecting = false
...
@@ -73,17 +69,12 @@ let redirecting = false
instance
.
interceptors
.
response
.
use
(
instance
.
interceptors
.
response
.
use
(
(
response
)
=>
response
,
(
response
)
=>
response
,
(
error
)
=>
{
(
error
)
=>
{
<<<<<<<
HEAD
const
status
:
number
|
undefined
=
error
.
response
?.
status
const
status
:
number
|
undefined
=
error
.
response
?.
status
if
(
status
===
401
)
{
if
(
status
===
401
)
{
if
(
!
redirecting
&&
window
.
location
.
pathname
!==
'/auth/callback'
)
{
=======
if
(
error
.
response
?.
status
===
401
)
{
// mock-only / 已选模拟身份时 401 交给页面处理,不跳 OIDC
// mock-only / 已选模拟身份时 401 交给页面处理,不跳 OIDC
const
mockActive
=
mockOnly
||
(
import
.
meta
.
env
.
DEV
&&
!!
getMockBrokerBizId
())
const
mockActive
=
mockOnly
||
(
import
.
meta
.
env
.
DEV
&&
!!
getMockBrokerBizId
())
if
(
!
mockActive
&&
!
redirecting
&&
window
.
location
.
pathname
!==
'/auth/callback'
)
{
if
(
!
mockActive
&&
!
redirecting
&&
window
.
location
.
pathname
!==
'/auth/callback'
)
{
>>>>>>>
0
cac32e9c611857dfc32d14724490175aac1f693
redirecting
=
true
redirecting
=
true
// 跳转失败(IdP 不可达)时必须复位,否则此后再也不重定向,页面卡死在错误态
// 跳转失败(IdP 不可达)时必须复位,否则此后再也不重定向,页面卡死在错误态
signinRedirect
(
window
.
location
.
pathname
+
window
.
location
.
search
).
catch
(()
=>
{
signinRedirect
(
window
.
location
.
pathname
+
window
.
location
.
search
).
catch
(()
=>
{
...
@@ -124,4 +115,4 @@ export async function get<T>(path: string): Promise<T> {
...
@@ -124,4 +115,4 @@ export async function get<T>(path: string): Promise<T> {
export
async
function
post
<
T
>
(
path
:
string
,
body
?:
unknown
):
Promise
<
T
>
{
export
async
function
post
<
T
>
(
path
:
string
,
body
?:
unknown
):
Promise
<
T
>
{
const
res
=
await
instance
.
post
<
ApiResult
<
T
>>
(
path
,
body
)
const
res
=
await
instance
.
post
<
ApiResult
<
T
>>
(
path
,
body
)
return
unwrap
(
res
.
data
)
return
unwrap
(
res
.
data
)
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment