#
zhou zhou
1 天以前 979bc5d5616d8f43681251a93a546008c83a4683
rsf-design/src/utils/ui/loading.js
@@ -13,18 +13,26 @@
  customClass: 'art-loading-fix'
}
let loadingInstance = null
let loadingTimer = null
const DEFAULT_LOADING_DELAY = 180
const loadingService = {
  /**
   * 显示 loading
   * @returns 关闭 loading 的函数
   */
  showLoading() {
    if (!loadingInstance) {
      const config = {
        ...DEFAULT_LOADING_CONFIG,
        background: getLoadingBackground()
      }
      loadingInstance = ElLoading.service(config)
    if (!loadingInstance && !loadingTimer) {
      loadingTimer = setTimeout(() => {
        loadingTimer = null
        if (loadingInstance) {
          return
        }
        const config = {
          ...DEFAULT_LOADING_CONFIG,
          background: getLoadingBackground()
        }
        loadingInstance = ElLoading.service(config)
      }, DEFAULT_LOADING_DELAY)
    }
    return () => this.hideLoading()
  },
@@ -32,6 +40,10 @@
   * 隐藏 loading
   */
  hideLoading() {
    if (loadingTimer) {
      clearTimeout(loadingTimer)
      loadingTimer = null
    }
    if (loadingInstance) {
      loadingInstance.close()
      loadingInstance = null