Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
founder_vue
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
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
常超
founder_vue
Commits
0163b473
Commit
0163b473
authored
Jan 07, 2022
by
li_hongchao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
http.js 优化
parent
88f72f55
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
3 deletions
+7
-3
src/request/http.js
+7
-3
No files found.
src/request/http.js
View file @
0163b473
...
...
@@ -41,6 +41,8 @@ var down = axios.create({ // 文件下载
},
})
var
_IS_SHOW_TIP
=
true
// 初始化参数
let
initConfig
=
(
config
)
=>
{
if
(
config
.
url
.
indexOf
(
'/login/myLoginForm'
)
<=
0
)
{
...
...
@@ -60,12 +62,14 @@ let initConfig = (config) => {
if
(
config
[
_HTTP_TYPE
.
LOADING
]
!==
false
)
{
showLoading
(
config
[
_HTTP_TYPE
.
LOADING_TARGET
])
// 如果设置了targer,使用设置的target,比如el-table
}
_IS_SHOW_TIP
=
config
[
_HTTP_TYPE
.
TIP
]
// console.log('initConfig', config)
return
config
}
let
onError
=
(
error
)
=>
{
logger
.
info
(
'error-config'
,
error
.
config
)
//
logger.info('error-config', error.config)
if
(
error
)
{
hideLoading
()
}
...
...
@@ -74,7 +78,7 @@ let onError = (error) => {
let
result
=
{
code
:
999
,
message
:
''
,
[
_HTTP_TYPE
.
TIP
]:
error
.
config
[
_HTTP_TYPE
.
TIP
]
[
_HTTP_TYPE
.
TIP
]:
_IS_SHOW_TIP
}
if
(
error
.
toString
().
indexOf
(
'400'
)
>=
0
)
{
result
.
code
=
400
...
...
@@ -111,7 +115,7 @@ let onResponse = (response) => {
if
(
response
.
headers
&&
response
.
headers
.
token
)
localStorage
.
setItem
(
ACCESS_TOKEN
,
response
.
headers
.
token
)
if
(
response
.
config
&&
response
.
config
.
loading
!==
false
)
hideLoading
(
response
.
config
.
loadingTarget
)
logger
.
info
(
'response-config'
,
response
.
config
)
//
logger.info('response-config', response.config)
if
(
response
.
data
&&
response
.
data
.
code
>=
0
)
{
let
status
=
response
.
data
.
code
...
...
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