Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
traceSourceMb
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
yanyanhong
traceSourceMb
Commits
54767591
Commit
54767591
authored
May 29, 2020
by
yyh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
loading
parent
eeefc23f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
1 deletion
+12
-1
http.ts
src/utils/http.ts
+12
-1
No files found.
src/utils/http.ts
View file @
54767591
...
...
@@ -75,6 +75,7 @@ const errorHandle = (status: number, other: any) => {
const
instance
=
axios
.
create
({
timeout
:
1000
*
12
});
// 设置post请求头
instance
.
defaults
.
headers
.
post
[
'Content-Type'
]
=
'application/json'
;
/**
* 请求拦截器
* 每次请求前,如果存在token则在请求头中携带token
...
...
@@ -86,7 +87,14 @@ instance.interceptors.request.use(
// 后台根据携带的token判断用户的登录情况,并返回给我们对应的状态码
// 而后我们可以在响应拦截器中,根据状态码进行一些统一的操作。
// token && (config.headers.Authorization = token);
const
url
=
config
.
url
as
string
;
if
(
url
.
indexOf
(
'list'
)
<
0
)
{
const
toast
=
Toast
({
type
:
'loading'
,
duration
:
0
,
forbidClick
:
true
,
});
}
config
.
cancelToken
=
new
CancelToken
((
c
)
=>
{
removePendingAjax
(
config
,
c
);
});
...
...
@@ -102,6 +110,9 @@ instance.interceptors.response.use(
// 请求成功
(
res
:
any
)
=>
{
removePendingAjax
(
res
.
config
);
setTimeout
(()
=>
{
Toast
.
clear
();
},
200
);
if
(
res
.
status
===
200
)
{
if
(
res
.
data
.
code
===
200
)
{
return
Promise
.
resolve
(
res
.
data
.
data
);
...
...
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