Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dcxy-system
Project
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
姜雷
dcxy-system
Commits
d5a54bbc
Commit
d5a54bbc
authored
Apr 03, 2019
by
姜雷
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
请求中添加notLoading参数在不需要显示loading状态时设为true
parent
104ea2f5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
11 deletions
+17
-11
baseFetch.js
src/api/baseFetch.js
+4
-2
index.js
src/store/modules/app/index.js
+13
-9
No files found.
src/api/baseFetch.js
View file @
d5a54bbc
...
@@ -12,7 +12,8 @@ const createBaseFetch = config => {
...
@@ -12,7 +12,8 @@ const createBaseFetch = config => {
// request拦截器
// request拦截器
service
.
interceptors
.
request
.
use
(
service
.
interceptors
.
request
.
use
(
conf
=>
{
conf
=>
{
store
.
dispatch
(
'fetchStart'
);
const
{
notLoading
}
=
conf
;
store
.
dispatch
(
'fetchStart'
,
notLoading
);
conf
.
headers
=
{
conf
.
headers
=
{
...
conf
.
headers
,
...
conf
.
headers
,
reqSource
:
'pc'
,
reqSource
:
'pc'
,
...
@@ -34,7 +35,8 @@ const createBaseFetch = config => {
...
@@ -34,7 +35,8 @@ const createBaseFetch = config => {
* code为非 1000 是抛错
* code为非 1000 是抛错
*/
*/
setTimeout
(()
=>
{
setTimeout
(()
=>
{
store
.
dispatch
(
'fetchDone'
);
const
{
notLoading
}
=
response
.
config
;
store
.
dispatch
(
'fetchDone'
,
notLoading
);
},
500
);
},
500
);
if
(
res
.
code
!==
1000
)
{
if
(
res
.
code
!==
1000
)
{
if
(
if
(
...
...
src/store/modules/app/index.js
View file @
d5a54bbc
...
@@ -12,20 +12,24 @@ const getters = {
...
@@ -12,20 +12,24 @@ const getters = {
};
};
const
actions
=
{
const
actions
=
{
fetchStart
({
commit
})
{
fetchStart
({
commit
}
,
notLoading
)
{
commit
(
FETCH_START
);
commit
(
FETCH_START
,
notLoading
);
},
},
fetchDone
({
commit
})
{
fetchDone
({
commit
}
,
notLoading
)
{
commit
(
FETCH_DONE
);
commit
(
FETCH_DONE
,
notLoading
);
},
},
};
};
const
mutations
=
{
const
mutations
=
{
[
FETCH_START
](
state
)
{
[
FETCH_START
](
state
,
notLoading
)
{
fetchCount
++
;
if
(
!
notLoading
)
{
state
.
loading
=
true
;
fetchCount
++
;
state
.
loading
=
true
;
}
},
},
[
FETCH_DONE
](
state
)
{
[
FETCH_DONE
](
state
,
notLoading
)
{
fetchCount
--
;
if
(
!
notLoading
)
{
fetchCount
--
;
}
if
(
fetchCount
===
0
)
{
if
(
fetchCount
===
0
)
{
state
.
loading
=
false
;
state
.
loading
=
false
;
}
}
...
...
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