Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
tswj
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
hookehuyr
2022-06-30 01:30:58 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
613027642622fd8c1a710a7ed2abc0177f85f68c
61302764
1 parent
d9032dd5
代码优化
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
8 deletions
src/utils/axios.js
src/utils/axios.js
View file @
6130276
...
...
@@ -2,7 +2,7 @@
* @Author: hookehuyr hookehuyr@gmail.com
* @Date: 2022-05-28 10:17:40
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2022-06-30 01:
16:40
* @LastEditTime: 2022-06-30 01:
30:26
* @FilePath: /tswj/src/utils/axios.js
* @Description:
*/
...
...
@@ -24,13 +24,11 @@ axios.interceptors.request.use(
// const url_params = parseQueryString(location.href);
// GET请求默认打上时间戳,避免从缓存中拿数据。
const
timestamp
=
config
.
method
===
'get'
?
(
new
Date
()).
valueOf
()
:
''
;
if
(
config
.
method
===
'post'
)
{
// 上传相关接口需要屏蔽掉封装, 不能序列化,数据会报错。
if
(
!
strExist
([
'a=upload'
,
'upload.qiniup.com'
],
config
.
url
))
{
// POST PHP需要修改数据格式
config
.
data
=
qs
.
stringify
(
config
.
data
)
}
}
/**
* POST PHP需要修改数据格式
* 序列化POST请求时需要屏蔽上传相关接口,上传相关接口序列化后报错
*/
config
.
data
=
config
.
method
===
'post'
&&
!
strExist
([
'a=upload'
,
'upload.qiniup.com'
],
config
.
url
)
?
qs
.
stringify
(
config
.
data
)
:
config
.
data
;
// 绑定默认请求头
config
.
params
=
{
...
config
.
params
,
timestamp
}
return
config
;
...
...
Please
register
or
login
to post a comment