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
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
8 deletions
+14
-8
baseFetch.js
src/api/baseFetch.js
+4
-2
index.js
src/store/modules/app/index.js
+10
-6
No files found.
src/api/baseFetch.js
View file @
d5a54bbc
...
...
@@ -12,7 +12,8 @@ const createBaseFetch = config => {
// request拦截器
service
.
interceptors
.
request
.
use
(
conf
=>
{
store
.
dispatch
(
'fetchStart'
);
const
{
notLoading
}
=
conf
;
store
.
dispatch
(
'fetchStart'
,
notLoading
);
conf
.
headers
=
{
...
conf
.
headers
,
reqSource
:
'pc'
,
...
...
@@ -34,7 +35,8 @@ const createBaseFetch = config => {
* code为非 1000 是抛错
*/
setTimeout
(()
=>
{
store
.
dispatch
(
'fetchDone'
);
const
{
notLoading
}
=
response
.
config
;
store
.
dispatch
(
'fetchDone'
,
notLoading
);
},
500
);
if
(
res
.
code
!==
1000
)
{
if
(
...
...
src/store/modules/app/index.js
View file @
d5a54bbc
...
...
@@ -12,20 +12,24 @@ const getters = {
};
const
actions
=
{
fetchStart
({
commit
})
{
commit
(
FETCH_START
);
fetchStart
({
commit
}
,
notLoading
)
{
commit
(
FETCH_START
,
notLoading
);
},
fetchDone
({
commit
})
{
commit
(
FETCH_DONE
);
fetchDone
({
commit
}
,
notLoading
)
{
commit
(
FETCH_DONE
,
notLoading
);
},
};
const
mutations
=
{
[
FETCH_START
](
state
)
{
[
FETCH_START
](
state
,
notLoading
)
{
if
(
!
notLoading
)
{
fetchCount
++
;
state
.
loading
=
true
;
}
},
[
FETCH_DONE
](
state
)
{
[
FETCH_DONE
](
state
,
notLoading
)
{
if
(
!
notLoading
)
{
fetchCount
--
;
}
if
(
fetchCount
===
0
)
{
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