request-loading.js 860 B

1234567891011121314151617181920212223242526272829303132333435
  1. import load from '@/utils/loading'
  2. // isLoading
  3. // let times = store.getters.loadCount;
  4. let timer = null
  5. export async function showFullScreenLoading(store) {
  6. if (store.getters.loadCount === 0 && !store.getters.isLoading) {
  7. await store.dispatch('app/setLoadCount', 1)
  8. await store.dispatch('app/setLoadStatus', true)
  9. load.startLoading()
  10. } else {
  11. await store.dispatch('app/setLoadCount', 1)
  12. clearTimeout(timer)
  13. timer = null
  14. }
  15. }
  16. export async function tryHideFullScreenLoading(store) {
  17. await store.dispatch('app/setLoadCount', -1)
  18. if (store.getters.loadCount <= 0 && store.getters.isLoading) {
  19. timer = setTimeout(async () => {
  20. await store.dispatch('app/resetLoadCount')
  21. await store.dispatch('app/setLoadStatus', false)
  22. load.endLoading();
  23. clearTimeout(timer)
  24. timer = null
  25. }, 100)
  26. }
  27. }