@mi-avalon/libs 0.0.8 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,7 +9,6 @@ var React = require('react');
9
9
  var React__default = _interopDefault(React);
10
10
  var ReactDOMClient = require('react-dom/client');
11
11
  var icons = require('@ant-design/icons');
12
- var lodash = require('lodash');
13
12
 
14
13
  var CMX = function CMX() {
15
14
  /**
@@ -506,6 +505,42 @@ var removeNull = function removeNull(obj) {
506
505
  }
507
506
  return obj;
508
507
  };
508
+ // 防抖函数
509
+ var debounce = function debounce(func, wait) {
510
+ var timeout = null;
511
+ return function () {
512
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
513
+ args[_key] = arguments[_key];
514
+ }
515
+ if (timeout) {
516
+ clearTimeout(timeout);
517
+ }
518
+ timeout = setTimeout(function () {
519
+ func.apply(void 0, args);
520
+ }, wait);
521
+ };
522
+ };
523
+ // 节流函数
524
+ var throttle = function throttle(func, wait) {
525
+ var timeout = null;
526
+ var lastTime = 0;
527
+ return function () {
528
+ var nowTime = Date.now();
529
+ if (!timeout) {
530
+ func.apply(void 0, arguments);
531
+ lastTime = nowTime;
532
+ timeout = setTimeout(function () {
533
+ timeout = null;
534
+ }, wait);
535
+ } else {
536
+ var diffTime = nowTime - lastTime;
537
+ if (diffTime >= wait) {
538
+ func.apply(void 0, arguments);
539
+ lastTime = nowTime;
540
+ }
541
+ }
542
+ };
543
+ };
509
544
 
510
545
  /**
511
546
  * 版本号工具类
@@ -1712,7 +1747,7 @@ option) {
1712
1747
  return _ref3.apply(this, arguments);
1713
1748
  };
1714
1749
  }();
1715
- var debounceRefresh = React.useCallback(lodash.debounce(refresh, 500), [refresh]);
1750
+ var debounceRefresh = React.useCallback(debounce(refresh, 500), [refresh]);
1716
1751
  /* 重置逻辑 */
1717
1752
  var _deps = [].concat(deps || [], [isReady]);
1718
1753
  React.useEffect(function () {
@@ -2023,7 +2058,7 @@ option) {
2023
2058
  };
2024
2059
  }();
2025
2060
  // 防抖 加载下一页数据
2026
- var debounceRefresh = React.useCallback(lodash.debounce(_refresh, 500), [_refresh]);
2061
+ var debounceRefresh = React.useCallback(debounce(_refresh, 500), [_refresh]);
2027
2062
  /* 重置逻辑 */
2028
2063
  var _deps = [].concat(deps || [], [isReady]);
2029
2064
  React.useEffect(function () {
@@ -2077,12 +2112,14 @@ exports.PAGE_SIZE = PAGE_SIZE;
2077
2112
  exports.PatternType = PatternType;
2078
2113
  exports.VersionUtil = VersionUtil;
2079
2114
  exports.cmx = cmx;
2115
+ exports.debounce = debounce;
2080
2116
  exports.getClassName = getClassName;
2081
2117
  exports.getFieldsByPath = getFieldsByPath;
2082
2118
  exports.nextTick = nextTick;
2083
2119
  exports.noop = noop;
2084
2120
  exports.openModal = openModal;
2085
2121
  exports.removeNull = removeNull;
2122
+ exports.throttle = throttle;
2086
2123
  exports.useFuncRequest = useFuncRequest;
2087
2124
  exports.useInterval = useInterval;
2088
2125
  exports.useMiThemeConfig = useMiThemeConfig;