forked from fdzcxy212206413/gsl_grs
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 line
1.6 KiB
1 line
1.6 KiB
2 months ago
|
{"version":3,"file":"index.mjs","sources":["../../../../../packages/hooks/use-throttle-render/index.ts"],"sourcesContent":["import { onMounted, ref, watch } from 'vue'\n\nimport type { Ref } from 'vue'\n\nexport const useThrottleRender = (loading: Ref<boolean>, throttle = 0) => {\n if (throttle === 0) return loading\n const throttled = ref(false)\n let timeoutHandle: ReturnType<typeof setTimeout> | null = null\n\n const dispatchThrottling = () => {\n if (timeoutHandle) {\n clearTimeout(timeoutHandle)\n }\n timeoutHandle = setTimeout(() => {\n throttled.value = loading.value\n }, throttle)\n }\n onMounted(dispatchThrottling)\n\n watch(\n () => loading.value,\n (val) => {\n if (val) {\n dispatchThrottling()\n } else {\n throttled.value = val\n }\n }\n )\n return throttled\n}\n"],"names":[],"mappings":";;AACY,MAAC,iBAAiB,GAAG,CAAC,OAAO,EAAE,QAAQ,GAAG,CAAC,KAAK;AAC5D,EAAE,IAAI,QAAQ,KAAK,CAAC;AACpB,IAAI,OAAO,OAAO,CAAC;AACnB,EAAE,MAAM,SAAS,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC;AAC/B,EAAE,IAAI,aAAa,GAAG,IAAI,CAAC;AAC3B,EAAE,MAAM,kBAAkB,GAAG,MAAM;AACnC,IAAI,IAAI,aAAa,EAAE;AACvB,MAAM,YAAY,CAAC,aAAa,CAAC,CAAC;AAClC,KAAK;AACL,IAAI,aAAa,GAAG,UAAU,CAAC,MAAM;AACrC,MAAM,SAAS,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;AACtC,KAAK,EAAE,QAAQ,CAAC,CAAC;AACjB,GAAG,CAAC;AACJ,EAAE,SAAS,CAAC,kBAAkB,CAAC,CAAC;AAChC,EAAE,KAAK,CAAC,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC,GAAG,KAAK;AACtC,IAAI,IAAI,GAAG,EAAE;AACb,MAAM,kBAAkB,EAAE,CAAC;AAC3B,KAAK,MAAM;AACX,MAAM,SAAS,CAAC,KAAK,GAAG,GAAG,CAAC;AAC5B,KAAK;AACL,GAAG,CAAC,CAAC;AACL,EAAE,OAAO,SAAS,CAAC;AACnB;;;;"}
|