智慧水务管理系统 - 精河县供水工程综合管理平台

123456789101112131415161718192021222324252627282930313233343536
  1. Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
  2. require("../../_virtual/_rolldown/runtime.js");
  3. const require_types = require("../../utils/types.js");
  4. let vue = require("vue");
  5. let _vue_shared = require("@vue/shared");
  6. //#region ../../packages/hooks/use-throttle-render/index.ts
  7. const useThrottleRender = (loading, throttle = 0) => {
  8. if (throttle === 0) return loading;
  9. const throttled = (0, vue.ref)((0, _vue_shared.isObject)(throttle) && Boolean(throttle.initVal));
  10. let timeoutHandle = null;
  11. const dispatchThrottling = (timer) => {
  12. if (require_types.isUndefined(timer)) {
  13. throttled.value = loading.value;
  14. return;
  15. }
  16. if (timeoutHandle) clearTimeout(timeoutHandle);
  17. timeoutHandle = setTimeout(() => {
  18. throttled.value = loading.value;
  19. }, timer);
  20. };
  21. const dispatcher = (type) => {
  22. if (type === "leading") if (require_types.isNumber(throttle)) dispatchThrottling(throttle);
  23. else dispatchThrottling(throttle.leading);
  24. else if ((0, _vue_shared.isObject)(throttle)) dispatchThrottling(throttle.trailing);
  25. else throttled.value = false;
  26. };
  27. (0, vue.onMounted)(() => dispatcher("leading"));
  28. (0, vue.watch)(() => loading.value, (val) => {
  29. dispatcher(val ? "leading" : "trailing");
  30. });
  31. return throttled;
  32. };
  33. //#endregion
  34. exports.useThrottleRender = useThrottleRender;
  35. //# sourceMappingURL=index.js.map