Commit d5a54bbc by 姜雷

请求中添加notLoading参数在不需要显示loading状态时设为true

parent 104ea2f5
......@@ -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 (
......
......@@ -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) {
fetchCount++;
state.loading = true;
[FETCH_START](state, notLoading) {
if (!notLoading) {
fetchCount++;
state.loading = true;
}
},
[FETCH_DONE](state) {
fetchCount--;
[FETCH_DONE](state, notLoading) {
if (!notLoading) {
fetchCount--;
}
if (fetchCount === 0) {
state.loading = false;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment