@lemon-fe/kits 0.0.23 → 0.0.24
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.
- package/es/index.d.ts +0 -1
- package/es/index.js +0 -1
- package/package.json +5 -5
- package/es/usePreload/index.d.ts +0 -9
- package/es/usePreload/index.js +0 -83
package/es/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export * from '@lemon-fe/components';
|
|
2
2
|
export * from '@lemon-fe/hooks';
|
|
3
3
|
export * from '@lemon-fe/layouts';
|
|
4
|
-
export { default as usePreload } from './usePreload';
|
|
5
4
|
export { default as useBatchOperator } from './useBatchOperator';
|
|
6
5
|
export { default as Subject } from './subject';
|
package/es/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export * from '@lemon-fe/components';
|
|
2
2
|
export * from '@lemon-fe/hooks';
|
|
3
3
|
export * from '@lemon-fe/layouts';
|
|
4
|
-
export { default as usePreload } from './usePreload';
|
|
5
4
|
export { default as useBatchOperator } from './useBatchOperator';
|
|
6
5
|
export { default as Subject } from './subject';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lemon-fe/kits",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.24",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"author": "鲁盛杰 <lusj@cnlemon.net>",
|
|
6
6
|
"homepage": "",
|
|
@@ -20,12 +20,12 @@
|
|
|
20
20
|
"url": "git@gitlab.nhsoft.cn:lemon-fe/kits-next.git"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@lemon-fe/components": "^0.0.
|
|
24
|
-
"@lemon-fe/hooks": "^0.0.
|
|
25
|
-
"@lemon-fe/layouts": "^0.0.
|
|
23
|
+
"@lemon-fe/components": "^0.0.24",
|
|
24
|
+
"@lemon-fe/hooks": "^0.0.24",
|
|
25
|
+
"@lemon-fe/layouts": "^0.0.24"
|
|
26
26
|
},
|
|
27
27
|
"scripts": {
|
|
28
28
|
"test": "echo \"Error: run tests from root\" && exit 1"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "85f8df424cf24a01973162690b65a2747ee67af5"
|
|
31
31
|
}
|
package/es/usePreload/index.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
export default function usePreload<TargetProps>(opts: {
|
|
3
|
-
request: () => Promise<TargetProps>;
|
|
4
|
-
onSuccess?: (data: TargetProps) => void;
|
|
5
|
-
} | (() => Promise<TargetProps>), deps?: ReadonlyArray<any>): {
|
|
6
|
-
refresh: () => void;
|
|
7
|
-
data: TargetProps | null;
|
|
8
|
-
mask: React.ReactElement<any, string | React.JSXElementConstructor<any>> | null;
|
|
9
|
-
};
|
package/es/usePreload/index.js
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
-
|
|
3
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
-
|
|
5
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
6
|
-
|
|
7
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
8
|
-
|
|
9
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
10
|
-
|
|
11
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
|
-
|
|
13
|
-
import React, { useEffect, useState } from 'react';
|
|
14
|
-
import { Result, Button } from 'antd';
|
|
15
|
-
import { useRequest } from '@lemon-fe/hooks';
|
|
16
|
-
import { PageLoading } from '@lemon-fe/components';
|
|
17
|
-
export default function usePreload(opts, deps) {
|
|
18
|
-
var _useState = useState(null),
|
|
19
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
20
|
-
data = _useState2[0],
|
|
21
|
-
setData = _useState2[1];
|
|
22
|
-
|
|
23
|
-
var _useState3 = useState(null),
|
|
24
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
25
|
-
error = _useState4[0],
|
|
26
|
-
setError = _useState4[1];
|
|
27
|
-
|
|
28
|
-
var request;
|
|
29
|
-
|
|
30
|
-
var _onSuccess;
|
|
31
|
-
|
|
32
|
-
if (typeof opts === 'function') {
|
|
33
|
-
request = opts;
|
|
34
|
-
} else {
|
|
35
|
-
request = opts.request;
|
|
36
|
-
_onSuccess = opts.onSuccess;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
var _useRequest = useRequest(request, {
|
|
40
|
-
onSuccess: function onSuccess(res) {
|
|
41
|
-
if (_onSuccess) {
|
|
42
|
-
_onSuccess(res);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
setData(res);
|
|
46
|
-
},
|
|
47
|
-
onError: function onError(err) {
|
|
48
|
-
setError(err);
|
|
49
|
-
}
|
|
50
|
-
}),
|
|
51
|
-
run = _useRequest.run;
|
|
52
|
-
|
|
53
|
-
useEffect(function () {
|
|
54
|
-
run();
|
|
55
|
-
}, deps ? deps : []);
|
|
56
|
-
|
|
57
|
-
var handleRefresh = function handleRefresh() {
|
|
58
|
-
setError(null);
|
|
59
|
-
run();
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
var mask = null;
|
|
63
|
-
|
|
64
|
-
if (error) {
|
|
65
|
-
mask = /*#__PURE__*/React.createElement(Result, {
|
|
66
|
-
status: "500",
|
|
67
|
-
title: "500",
|
|
68
|
-
subTitle: error.message,
|
|
69
|
-
extra: /*#__PURE__*/React.createElement(Button, {
|
|
70
|
-
type: "primary",
|
|
71
|
-
onClick: handleRefresh
|
|
72
|
-
}, "\u91CD\u65B0\u52A0\u8F7D")
|
|
73
|
-
});
|
|
74
|
-
} else if (data === null) {
|
|
75
|
-
mask = /*#__PURE__*/React.createElement(PageLoading, null);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return {
|
|
79
|
-
refresh: handleRefresh,
|
|
80
|
-
data: data,
|
|
81
|
-
mask: mask
|
|
82
|
-
};
|
|
83
|
-
}
|