import { ref } from 'vue'
const useReadLoading = function () {
  const isLoading = ref<boolean>(false)
  const loadingTimer = ref<any>()
  const OSS_URL = import.meta.env.VITE_OSS_URL

  // 获取加载动效
  function getLoading() {
    return `${OSS_URL}/xuexiaole_clinet/normalMode/read_loading.gif`
  }
  // 加载定时器
  function overLoading() {
    loadingTimer.value = setTimeout(() => {
      isLoading.value = false
    }, 1200)
  }
  // 清除定时器
  function clearLoadingTimer() {
    clearTimeout(loadingTimer.value)
  }
  return {
    isLoading,
    getLoading,
    overLoading,
    clearLoadingTimer,
  }
}
export default useReadLoading
