import { Loading } from 'element-ui'

let loadingInstance = null

export function showLoading () {
  return (loadingInstance = Loading.service({
    lock: true,
    background: 'rgba(0, 0, 0, .8)'
  }))
}

export function closeLoading (loading) {
  if (loading) {
    loading.close()
  } else if (loadingInstance) {
    loadingInstance.close()
    loadingInstance = null
  }
}
