|
@@ -6,7 +6,7 @@ import qs from 'querystring'
|
|
|
import { getToken } from '@/utils/auth'
|
|
|
import cleanDeep from 'clean-deep'
|
|
|
// import { Loading } from 'element-ui'
|
|
|
-import load from '@/utils/loading'
|
|
|
+import { showFullScreenLoading, tryHideFullScreenLoading } from './request-loading'
|
|
|
import router from '@/router/index'
|
|
|
import Vue from 'vue'
|
|
|
const showMessage = Symbol('showMessage')
|
|
@@ -58,24 +58,7 @@ let vue = new Vue()
|
|
|
//那么 showFullScreenLoading() tryHideFullScreenLoading() 要干的事儿就是将同一时刻的请求合并。
|
|
|
//声明一个变量 needLoadingRequestCount,每次调用showFullScreenLoading方法 needLoadingRequestCount + 1。
|
|
|
//调用tryHideFullScreenLoading()方法,needLoadingRequestCount - 1。needLoadingRequestCount为 0 时,结束 loading。
|
|
|
-let needLoadingRequestCount = 0
|
|
|
-function showFullScreenLoading () {
|
|
|
- if (needLoadingRequestCount === 0) {
|
|
|
- load.startLoading()
|
|
|
- }
|
|
|
- needLoadingRequestCount++
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-function tryHideFullScreenLoading () {
|
|
|
- if (needLoadingRequestCount <= 0) return
|
|
|
- needLoadingRequestCount--
|
|
|
- if (needLoadingRequestCount === 0) {
|
|
|
- load.endLoading();
|
|
|
|
|
|
- }
|
|
|
-
|
|
|
-}
|
|
|
|
|
|
// axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
|
|
|
|