ebaoferc 0.0.3-beta.6 → 0.1.0
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.
|
@@ -7,13 +7,13 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
7
7
|
import { usePagination } from 'ahooks';
|
|
8
8
|
import { isNullOrUndefined } from "../../utils";
|
|
9
9
|
import { useMemo } from 'react';
|
|
10
|
+
var deepSearchProp = function deepSearchProp(current, path) {
|
|
11
|
+
if ((path === null || path === void 0 ? void 0 : path.length) === 1) return current === null || current === void 0 ? void 0 : current[path === null || path === void 0 ? void 0 : path[0]];
|
|
12
|
+
return deepSearchProp(current === null || current === void 0 ? void 0 : current[path === null || path === void 0 ? void 0 : path[0]], path.slice(1));
|
|
13
|
+
};
|
|
10
14
|
var getPropByPath = function getPropByPath(target, path) {
|
|
11
15
|
var pathArr = path.split('.');
|
|
12
|
-
|
|
13
|
-
if ((path === null || path === void 0 ? void 0 : path.length) === 1) return current === null || current === void 0 ? void 0 : current[path === null || path === void 0 ? void 0 : path[0]];
|
|
14
|
-
return deep(current === null || current === void 0 ? void 0 : current[path === null || path === void 0 ? void 0 : path[0]], path.slice(1));
|
|
15
|
-
};
|
|
16
|
-
return deep(target, pathArr);
|
|
16
|
+
return deepSearchProp(target, pathArr);
|
|
17
17
|
};
|
|
18
18
|
export function useEnhancePagination(service, options) {
|
|
19
19
|
var _ref = options !== null && options !== void 0 ? options : {},
|
|
@@ -25,13 +25,12 @@ export function useEnhancePagination(service, options) {
|
|
|
25
25
|
if (!isNullOrUndefined(options === null || options === void 0 ? void 0 : options.onSuccess)) options === null || options === void 0 || (_options$onSuccess = options.onSuccess) === null || _options$onSuccess === void 0 || _options$onSuccess.call(options, result, args);
|
|
26
26
|
var data = getPropByPath(result, dataPropPath);
|
|
27
27
|
var params = args === null || args === void 0 ? void 0 : args[0];
|
|
28
|
-
if (!(data !== null && data !== void 0 && data.length) && (params === null || params === void 0 ? void 0 : params.current) > 1) paginationHookRes.pagination.changeCurrent(
|
|
28
|
+
if (Array.isArray(data) && !(data !== null && data !== void 0 && data.length) && (params === null || params === void 0 ? void 0 : params.current) > 1) paginationHookRes.pagination.changeCurrent(1);
|
|
29
29
|
}
|
|
30
30
|
}));
|
|
31
31
|
var listData = useMemo(function () {
|
|
32
|
-
var _getPropByPath, _paginationHookRes$da
|
|
33
|
-
|
|
34
|
-
return (_getPropByPath2 = getPropByPath((_paginationHookRes$da2 = paginationHookRes.data) !== null && _paginationHookRes$da2 !== void 0 ? _paginationHookRes$da2 : {}, dataPropPath)) !== null && _getPropByPath2 !== void 0 ? _getPropByPath2 : [];
|
|
32
|
+
var _getPropByPath, _paginationHookRes$da;
|
|
33
|
+
return (_getPropByPath = getPropByPath((_paginationHookRes$da = paginationHookRes.data) !== null && _paginationHookRes$da !== void 0 ? _paginationHookRes$da : {}, dataPropPath)) !== null && _getPropByPath !== void 0 ? _getPropByPath : [];
|
|
35
34
|
}, [paginationHookRes.data, dataPropPath]);
|
|
36
35
|
return _objectSpread({
|
|
37
36
|
listData: listData
|