vap1 0.2.3 → 0.2.5

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.
Files changed (272) hide show
  1. package/components/Box/Box.js +75 -42
  2. package/components/Box/SelectBar.js +51 -24
  3. package/components/Box/_register.d.ts +4 -0
  4. package/components/Box/_register.js +10 -8
  5. package/components/Box/index.js +1 -1
  6. package/components/Lists/SList.js +76 -48
  7. package/components/SearchBar/ActionButtons.js +75 -42
  8. package/components/SearchBar/ByField.js +80 -52
  9. package/components/SearchBar/ByKeyword.js +44 -17
  10. package/components/SearchBar/SearchField.js +8 -8
  11. package/components/SearchBar/SearchTags.js +4 -4
  12. package/components/SearchBar/_register.js +9 -8
  13. package/components/SearchBar/index.js +22 -11
  14. package/components/Tables/ApiTable.d.ts +1 -1
  15. package/components/Tables/ApiTable.js +19 -8
  16. package/components/Tables/ApiTableModal.d.ts +1 -1
  17. package/components/Tables/ApiTableModal.js +40 -13
  18. package/components/Tables/Components/ActionBar.js +53 -26
  19. package/components/Tables/Components/Actions.js +40 -29
  20. package/components/Tables/Components/Summary.js +2 -2
  21. package/components/Tables/Components/index.js +3 -3
  22. package/components/Tables/STable.js +21 -10
  23. package/components/Tables/TopTable.d.ts +3 -2
  24. package/components/Tables/TopTable.js +64 -37
  25. package/components/Tables/TopTableModal.js +21 -10
  26. package/components/Tables/Util.d.ts +2 -2
  27. package/components/Tables/Util.js +11 -9
  28. package/components/Tables/VTable.d.ts +2 -2
  29. package/components/Tables/VTable.js +137 -65
  30. package/components/Tables/index.d.ts +7 -2
  31. package/components/Tables/index.js +5 -5
  32. package/components/TreeSelect/BaseTreeSelect.js +81 -45
  33. package/components/TreeSelect/DTreeSelect.js +191 -66
  34. package/components/TreeSelect/FTreeSelect.js +67 -20
  35. package/components/TreeSelect/STreeSelect.js +22 -11
  36. package/components/Trees/ActionTree.js +562 -431
  37. package/components/Trees/BaseTree.js +85 -38
  38. package/components/Trees/COTree/COButton.js +48 -21
  39. package/components/Trees/COTree/COSelect.js +31 -20
  40. package/components/Trees/COTree/COTree.js +223 -107
  41. package/components/Trees/COTree/COTreeUtil.js +160 -115
  42. package/components/Trees/DTree.js +139 -68
  43. package/components/Trees/FTree.js +76 -29
  44. package/components/Trees/STree.js +59 -23
  45. package/components/UForm/FormWrapper.js +70 -53
  46. package/components/UForm/UDescriptions.js +38 -38
  47. package/components/UForm/UForm.js +240 -135
  48. package/components/UForm/UFormModal.js +99 -44
  49. package/components/UForm/UInfo.js +33 -22
  50. package/components/UForm/UInfoModal.js +31 -20
  51. package/components/UForm/UModal.js +40 -13
  52. package/components/UForm/_FormUtils.js +29 -18
  53. package/components/UForm/_input.js +75 -39
  54. package/components/UForm/_register.js +11 -9
  55. package/components/UForm/index.d.ts +5 -0
  56. package/components/Upload/UploadFile.js +38 -11
  57. package/components/Upload/UploadImage.js +50 -23
  58. package/components/Upload/UploadModal.js +149 -84
  59. package/components/Upload/useUpload.js +35 -19
  60. package/components/_RegisterUtil.js +20 -8
  61. package/components/_adapt/Alert.js +20 -9
  62. package/components/_adapt/Breadcrumb.js +18 -7
  63. package/components/_adapt/Button.js +24 -13
  64. package/components/_adapt/Col.js +34 -23
  65. package/components/_adapt/Collapse.js +21 -10
  66. package/components/_adapt/ColorPicker.js +55 -28
  67. package/components/_adapt/ConfigProvider.js +14 -3
  68. package/components/_adapt/Drawer.js +18 -7
  69. package/components/_adapt/Dropdown.js +23 -12
  70. package/components/_adapt/FloatButton.js +21 -10
  71. package/components/_adapt/Icon.js +18 -7
  72. package/components/_adapt/Input.js +17 -6
  73. package/components/_adapt/InputNumber.js +16 -5
  74. package/components/_adapt/Layout.js +84 -28
  75. package/components/_adapt/Menu.js +28 -17
  76. package/components/_adapt/Modal.js +72 -25
  77. package/components/_adapt/Pagination.js +14 -3
  78. package/components/_adapt/Popconfirm.js +17 -6
  79. package/components/_adapt/Popover.js +17 -6
  80. package/components/_adapt/Progress.js +42 -11
  81. package/components/_adapt/Radio.js +21 -10
  82. package/components/_adapt/Row.js +18 -7
  83. package/components/_adapt/Select.js +54 -43
  84. package/components/_adapt/Slider.js +1 -1
  85. package/components/_adapt/Space.js +2 -2
  86. package/components/_adapt/Table.js +16 -5
  87. package/components/_adapt/Tabs.js +17 -6
  88. package/components/_adapt/Tag.js +19 -8
  89. package/components/_adapt/Tooltip.js +15 -4
  90. package/components/_adapt/TreeSelect.js +18 -7
  91. package/components/_adapt/notification.js +1 -1
  92. package/components/_adapt/todo/Image.js +2 -2
  93. package/components/_adapt/todo/NotEffectOnV15.js +1 -1
  94. package/components/_adapt/todo/Segmented.js +2 -2
  95. package/components/_adapt/utils.js +28 -8
  96. package/components/_common/AutoComplete.js +101 -34
  97. package/components/_common/CountUp.js +30 -14
  98. package/components/_common/DateRange.js +36 -20
  99. package/components/_common/HighLight.js +22 -6
  100. package/components/_common/I18N.js +27 -2
  101. package/components/_common/Loading.js +25 -9
  102. package/components/_common/MonthRange.js +26 -26
  103. package/components/_common/PromiseLabel.js +68 -15
  104. package/components/_common/Role.js +2 -2
  105. package/components/_common/Upagination.js +45 -34
  106. package/components/_setup/Const.js +2 -2
  107. package/components/_setup/I18N/enUS.js +2 -2
  108. package/components/_setup/I18N/zhCN.js +3 -3
  109. package/components/_setup/I18N/zhHK.js +2 -2
  110. package/components/_setup/ICON/IconTypes.js +2 -2
  111. package/components/_setup/SearchField/SearchFieldAdvance.js +22 -11
  112. package/components/_setup/SearchField/SearchFieldDate.js +114 -77
  113. package/components/_setup/SearchField/SearchFieldInput.js +21 -10
  114. package/components/_setup/SearchField/SearchFieldSelect.js +55 -44
  115. package/components/_setup/SearchField/SearchFieldTree.js +63 -52
  116. package/components/_setup/SelectBar/SelectList.js +21 -10
  117. package/components/_setup/SelectBar/SelectTree.js +17 -6
  118. package/components/_setup/UForm/UFormAdvanceInput.js +105 -78
  119. package/components/_setup/UForm/UFormCOTree.js +21 -10
  120. package/components/_setup/UForm/UFormCrontab.js +51 -35
  121. package/components/_setup/UForm/UFormDate.js +158 -122
  122. package/components/_setup/UForm/UFormInput.js +110 -73
  123. package/components/_setup/UForm/UFormJSON.js +95 -57
  124. package/components/_setup/UForm/UFormJSONTable.js +79 -41
  125. package/components/_setup/UForm/UFormOrg.js +112 -48
  126. package/components/_setup/UForm/UFormRole.js +31 -20
  127. package/components/_setup/UForm/UFormSelect.js +106 -79
  128. package/components/_setup/UForm/UFormTree.js +52 -41
  129. package/components/_setup/UForm/UFormUpload.js +62 -34
  130. package/components/_setup/UForm/_utils.js +9 -9
  131. package/deps/JsonView.js +18 -7
  132. package/deps/SpringBoot.js +1 -1
  133. package/deps/SpringCloud.js +4 -4
  134. package/deps/_editor/advance/_Image.js +33 -20
  135. package/deps/_editor/base/Element.js +28 -17
  136. package/deps/_editor/base/Leaf.js +18 -7
  137. package/deps/_editor/base/Support.js +4 -4
  138. package/deps/_editor/i18n.js +1 -1
  139. package/deps/_editor/tools/Button.js +31 -19
  140. package/deps/_editor/tools/ToolBar.js +3 -3
  141. package/deps/_editor/tools/_BlockButton.js +49 -27
  142. package/deps/_editor/tools/_InsertButton.js +32 -28
  143. package/deps/_editor/tools/_MarkButton.js +15 -14
  144. package/deps/_editor/tools/_TxtButton.js +90 -58
  145. package/deps/api-audit.js +1 -1
  146. package/deps/echarts.js +58 -17
  147. package/deps/editor.js +52 -26
  148. package/deps/registerEditor.js +18 -7
  149. package/hooks/_list.js +1 -1
  150. package/hooks/useAjax.js +43 -19
  151. package/hooks/useAjaxAction.js +57 -20
  152. package/hooks/useAjaxQuery.js +121 -51
  153. package/hooks/useApi.js +35 -8
  154. package/hooks/useApiBase.js +291 -184
  155. package/hooks/useApiGlobal.js +40 -13
  156. package/hooks/useApp.js +4 -4
  157. package/hooks/useArray.js +114 -52
  158. package/hooks/useDefault.js +19 -3
  159. package/hooks/useDoLoad.js +25 -9
  160. package/hooks/useEffectFunction.js +4 -3
  161. package/hooks/useEffectOnce.js +5 -5
  162. package/hooks/useError.js +21 -5
  163. package/hooks/useFirstMountState.js +3 -3
  164. package/hooks/useGenkey.js +7 -7
  165. package/hooks/useGetSet.js +9 -9
  166. package/hooks/useGlobal.js +58 -29
  167. package/hooks/useHover.js +25 -9
  168. package/hooks/useMemoPromise.js +62 -22
  169. package/hooks/useModals.js +71 -36
  170. package/hooks/useMountedState.js +6 -6
  171. package/hooks/useOpenState.js +26 -10
  172. package/hooks/usePromise.js +15 -13
  173. package/hooks/useQueue.js +35 -8
  174. package/hooks/useSetState.js +25 -8
  175. package/hooks/useStateList.js +30 -18
  176. package/hooks/useSyncExternalStore.js +31 -15
  177. package/hooks/useToggle.js +6 -3
  178. package/hooks/useUnmountPromise.js +11 -11
  179. package/hooks/useUpdate.js +20 -4
  180. package/hooks/useUpdateEffect.js +5 -5
  181. package/login/Base65.js +15 -14
  182. package/login/Password.js +91 -38
  183. package/login/SM4.js +50 -49
  184. package/login/cems/index.js +2 -2
  185. package/login/jit/index.js +16 -71
  186. package/login/jit/pnxclient.js +6 -4
  187. package/login/vap/index.js +1 -1
  188. package/login/xrtx/index.js +2 -2
  189. package/package.json +1 -1
  190. package/screen/Comment.js +16 -5
  191. package/screen/Page.js +14 -14
  192. package/screen/render.js +2 -2
  193. package/uform/FormEditor.js +44 -27
  194. package/uform/FormViewer.js +30 -19
  195. package/uform/hooks/useEditor.js +83 -47
  196. package/uform/hooks/useForm.js +2 -2
  197. package/uform/index.js +10 -10
  198. package/uform/inputs/_advance.js +12 -12
  199. package/uform/inputs/_date.js +63 -52
  200. package/uform/inputs/_input.js +49 -38
  201. package/uform/inputs/_select.js +53 -42
  202. package/uform/inputs/_specific.js +33 -22
  203. package/uform/inputs/index.js +5 -5
  204. package/uform/inputs/register.d.ts +8 -0
  205. package/uform/inputs/register.js +14 -14
  206. package/uform/panel/Editor/GroupEditor.js +31 -31
  207. package/uform/panel/Editor/ListEditor.js +22 -22
  208. package/uform/panel/Editor/_FieldItems.js +16 -16
  209. package/uform/panel/Editor/_GroupCollapse.js +9 -9
  210. package/uform/panel/Editor/_GroupDefault.js +9 -9
  211. package/uform/panel/Editor/_GroupStep.js +18 -18
  212. package/uform/panel/Editor/_GroupTab.js +16 -16
  213. package/uform/panel/Editor/index.js +17 -17
  214. package/uform/panel/Items/index.js +22 -11
  215. package/uform/panel/Propreties/CanvasProperties.js +14 -14
  216. package/uform/panel/Propreties/Component/FieldPlugin.js +5 -5
  217. package/uform/panel/Propreties/Component/LinkAsyncFunction.js +22 -47
  218. package/uform/panel/Propreties/Component/LinkSyncFunction.js +20 -43
  219. package/uform/panel/Propreties/Component/Links.js +40 -29
  220. package/uform/panel/Propreties/Component/OptionTable.js +97 -52
  221. package/uform/panel/Propreties/Component/RegexpModal.js +11 -11
  222. package/uform/panel/Propreties/Component/Validate.js +35 -24
  223. package/uform/panel/Propreties/Component/ValidateAsyncFunction.js +13 -24
  224. package/uform/panel/Propreties/Component/ValidateSyncFunction.js +15 -38
  225. package/uform/panel/Propreties/FieldOptions.js +78 -44
  226. package/uform/panel/Propreties/FieldProperties.js +47 -20
  227. package/uform/panel/Propreties/GroupProperties.js +9 -9
  228. package/uform/panel/Propreties/_ItemAdvance.js +37 -26
  229. package/uform/panel/Propreties/_ItemBase.js +72 -21
  230. package/uform/panel/Propreties/_ItemLink.js +20 -9
  231. package/uform/panel/Propreties/_ItemValidate.js +33 -22
  232. package/uform/plugins/index.js +7 -7
  233. package/uform/schema.d.ts +6 -1
  234. package/uform/utils/Convert.js +137 -94
  235. package/uform/utils/SchemaConvert.js +43 -68
  236. package/uform/utils/arr.js +106 -75
  237. package/utils/Ajax.d.ts +1 -11
  238. package/utils/Ajax.js +154 -68
  239. package/utils/ArrayUtil.js +14 -12
  240. package/utils/CacheUtil.js +19 -13
  241. package/utils/Const.js +13 -13
  242. package/utils/CustomApp.js +15 -10
  243. package/utils/EventUtil.js +78 -14
  244. package/utils/Format.js +59 -38
  245. package/utils/Global.js +8 -8
  246. package/utils/Logger.js +56 -11
  247. package/utils/PageUtil.d.ts +12 -6
  248. package/utils/PageUtil.js +105 -35
  249. package/utils/Renders/ApiGetRender.js +187 -100
  250. package/utils/Renders/ApiPostRender.js +123 -69
  251. package/utils/Renders/DateRender.js +9 -9
  252. package/utils/Renders/DictRender.js +82 -55
  253. package/utils/Renders/FileRender.js +34 -12
  254. package/utils/Renders/ListRender.js +21 -21
  255. package/utils/Renders/NumberRender.js +14 -13
  256. package/utils/Renders/StatusRender.js +20 -20
  257. package/utils/Renders/StringRender.js +17 -17
  258. package/utils/Renders/_define.d.ts +2 -2
  259. package/utils/Renders/_define.js +7 -7
  260. package/utils/StringUtil.js +98 -67
  261. package/utils/TreeUtil.js +71 -20
  262. package/utils/VAP.js +14 -14
  263. package/utils/XHR.js +27 -11
  264. package/utils/_AjaxUtil.d.ts +10 -0
  265. package/utils/_AjaxUtil.js +35 -12
  266. package/utils/_Support.d.ts +2 -2
  267. package/utils/_Support.js +26 -26
  268. package/utils/i18n.js +78 -44
  269. package/utils/index.d.ts +9 -1
  270. package/utils/index.js +34 -5
  271. package/utils/screenful.js +84 -31
  272. package/widget/index.js +4 -4
package/hooks/useAjax.js CHANGED
@@ -1,43 +1,67 @@
1
1
  "use strict";
2
+ var __read = (this && this.__read) || function (o, n) {
3
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
4
+ if (!m) return o;
5
+ var i = m.call(o), r, ar = [], e;
6
+ try {
7
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
8
+ }
9
+ catch (error) { e = { error: error }; }
10
+ finally {
11
+ try {
12
+ if (r && !r.done && (m = i["return"])) m.call(i);
13
+ }
14
+ finally { if (e) throw e.error; }
15
+ }
16
+ return ar;
17
+ };
2
18
  Object.defineProperty(exports, "__esModule", { value: true });
3
19
  exports.useDelete = exports.usePatch = exports.usePost = exports.useGet = exports.useFetch = exports.usePromise = void 0;
4
- const Ajax_1 = require("../utils/Ajax");
5
- const react_1 = require("react");
6
- const usePromise = (...promises) => {
7
- const [loading, setLoading] = (0, react_1.useState)(true);
8
- Promise.all(promises).then(response => {
20
+ var Ajax_1 = require("../utils/Ajax");
21
+ var react_1 = require("react");
22
+ var usePromise = function () {
23
+ var promises = [];
24
+ for (var _i = 0; _i < arguments.length; _i++) {
25
+ promises[_i] = arguments[_i];
26
+ }
27
+ var _a = __read((0, react_1.useState)(true), 2), loading = _a[0], setLoading = _a[1];
28
+ Promise.all(promises).then(function (response) {
9
29
  });
10
30
  };
11
31
  exports.usePromise = usePromise;
12
- const useFetch = (...promises) => {
13
- const [loading, setLoading] = (0, react_1.useState)(true);
14
- Promise.all(promises).then(response => {
32
+ var useFetch = function () {
33
+ var promises = [];
34
+ for (var _i = 0; _i < arguments.length; _i++) {
35
+ promises[_i] = arguments[_i];
36
+ }
37
+ var _a = __read((0, react_1.useState)(true), 2), loading = _a[0], setLoading = _a[1];
38
+ Promise.all(promises).then(function (response) {
15
39
  });
16
40
  };
17
41
  exports.useFetch = useFetch;
18
- const useGet = (url, options) => {
19
- const [loading, setLoading] = (0, react_1.useState)(true);
20
- const [result, setResult] = (0, react_1.useState)(null);
21
- const reflush = () => {
22
- (0, Ajax_1.GET)(url).then(response => {
42
+ var useGet = function (url, options) {
43
+ var _a = __read((0, react_1.useState)(true), 2), loading = _a[0], setLoading = _a[1];
44
+ var _b = __read((0, react_1.useState)(null), 2), result = _b[0], setResult = _b[1];
45
+ var reflush = function () {
46
+ (0, Ajax_1.GET)(url).then(function (response) {
23
47
  setResult(response);
24
48
  setLoading(false);
25
- }).catch(err => {
49
+ }).catch(function (err) {
26
50
  });
27
51
  };
28
52
  // reflush();
29
53
  return {
30
- loading,
31
- result,
54
+ loading: loading,
55
+ result: result,
32
56
  };
33
57
  };
34
58
  exports.useGet = useGet;
35
- const usePost = (url, param, options) => {
59
+ var usePost = function (url, param, options) {
36
60
  };
37
61
  exports.usePost = usePost;
38
- const usePatch = (url, param, options) => {
62
+ var usePatch = function (url, param, options) {
39
63
  };
40
64
  exports.usePatch = usePatch;
41
- const useDelete = (url, param, options) => {
65
+ var useDelete = function (url, param, options) {
42
66
  };
43
67
  exports.useDelete = useDelete;
@@ -8,35 +8,72 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
11
38
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
39
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
40
  };
14
41
  Object.defineProperty(exports, "__esModule", { value: true });
15
42
  exports.useAjaxAction = void 0;
16
- const antd_1 = require("antd");
17
- const lodash_1 = __importDefault(require("lodash"));
43
+ var antd_1 = require("antd");
44
+ var lodash_1 = __importDefault(require("lodash"));
18
45
  /**
19
46
  * 封装一个Ajax接口调用操作
20
47
  */
21
- const useAjaxAction = (options) => {
22
- const config = lodash_1.default.isFunction(options) ? { fn: options } : options;
23
- const fetch = (data) => __awaiter(void 0, void 0, void 0, function* () {
24
- try {
25
- const param = lodash_1.default.merge(config.defaultParam, data);
26
- const resp = yield config.fn(param);
27
- if (lodash_1.default.has(resp, 'code') && resp.code != '0') {
28
- antd_1.message.error(resp.message);
29
- // setLoading(false);
30
- return;
48
+ var useAjaxAction = function (options) {
49
+ var config = lodash_1.default.isFunction(options) ? { fn: options } : options;
50
+ var fetch = function (data) { return __awaiter(void 0, void 0, void 0, function () {
51
+ var param, resp, err_1;
52
+ return __generator(this, function (_a) {
53
+ switch (_a.label) {
54
+ case 0:
55
+ _a.trys.push([0, 2, , 3]);
56
+ param = lodash_1.default.merge(config.defaultParam, data);
57
+ return [4 /*yield*/, config.fn(param)];
58
+ case 1:
59
+ resp = _a.sent();
60
+ if (lodash_1.default.has(resp, 'code') && resp.code != '0') {
61
+ antd_1.message.error(resp.message);
62
+ // setLoading(false);
63
+ return [2 /*return*/];
64
+ }
65
+ if (config.hander) {
66
+ config.hander(resp, param);
67
+ }
68
+ return [3 /*break*/, 3];
69
+ case 2:
70
+ err_1 = _a.sent();
71
+ console.error(err_1);
72
+ return [3 /*break*/, 3];
73
+ case 3: return [2 /*return*/];
31
74
  }
32
- if (config.hander) {
33
- config.hander(resp, param);
34
- }
35
- }
36
- catch (err) {
37
- console.error(err);
38
- }
39
- });
75
+ });
76
+ }); };
40
77
  return fetch;
41
78
  };
42
79
  exports.useAjaxAction = useAjaxAction;
@@ -8,69 +8,139 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ var __read = (this && this.__read) || function (o, n) {
39
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
40
+ if (!m) return o;
41
+ var i = m.call(o), r, ar = [], e;
42
+ try {
43
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
44
+ }
45
+ catch (error) { e = { error: error }; }
46
+ finally {
47
+ try {
48
+ if (r && !r.done && (m = i["return"])) m.call(i);
49
+ }
50
+ finally { if (e) throw e.error; }
51
+ }
52
+ return ar;
53
+ };
54
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
55
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
56
+ if (ar || !(i in from)) {
57
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
58
+ ar[i] = from[i];
59
+ }
60
+ }
61
+ return to.concat(ar || Array.prototype.slice.call(from));
62
+ };
11
63
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
64
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
65
  };
14
66
  Object.defineProperty(exports, "__esModule", { value: true });
15
67
  exports.useAjaxQuery = void 0;
16
- const react_1 = require("react");
17
- const lodash_1 = __importDefault(require("lodash"));
18
- const antd_1 = require("antd");
19
- const useFirstMountState_1 = require("./useFirstMountState");
68
+ var react_1 = require("react");
69
+ var lodash_1 = __importDefault(require("lodash"));
70
+ var antd_1 = require("antd");
71
+ var useFirstMountState_1 = require("./useFirstMountState");
20
72
  /**
21
73
  * 封装一个Ajax接口查询操作
22
74
  * 通过用于 Ajax 操作,实际上可以用于任何 Promise 方法
23
75
  */
24
- const useAjaxQuery = (options) => {
25
- const config = lodash_1.default.isFunction(options) ? { fn: options } : options;
26
- const [[data, param], setData] = (0, react_1.useState)([config.defaultValue, lodash_1.default.isArray(config.autoLoad) ? config.autoLoad : []]);
27
- const [loading, setLoading] = (0, react_1.useState)(config.autoLoad != undefined ? true : false);
28
- const isFirstMount = (0, useFirstMountState_1.useFirstMountState)();
29
- const _fetch = (...args) => __awaiter(void 0, void 0, void 0, function* () {
30
- // let param = args.length > 0 ? args[0] : (config.defaultParam || null);
31
- // args.length
32
- try {
33
- setLoading(true);
34
- const resp = yield config.fn(...args);
35
- if (lodash_1.default.has(resp, 'code') && resp.code != '0' && resp.message) {
36
- antd_1.message.error(resp.message);
37
- setData([config.defaultValue, args]);
38
- setLoading(false);
39
- return;
40
- }
41
- if (config.valueHander) {
42
- if (lodash_1.default.isString(config.valueHander)) {
43
- setData([lodash_1.default.get(resp, config.valueHander), args]);
44
- }
45
- else {
46
- setData([config.valueHander(resp, ...args), args]);
47
- }
48
- }
49
- else {
50
- if (lodash_1.default.has(resp, 'data')) {
51
- setData([resp.data, args]);
52
- }
53
- else if (lodash_1.default.has(resp, 'list')) {
54
- setData([resp.list, args]);
55
- }
56
- else {
57
- setData([resp, args]);
58
- }
59
- }
60
- setLoading(false);
61
- }
62
- catch (err) {
63
- console.error(err);
64
- setData([config.defaultValue, args]);
65
- setLoading(false);
76
+ var useAjaxQuery = function (options) {
77
+ var config = lodash_1.default.isFunction(options) ? { fn: options } : options;
78
+ var _a = __read((0, react_1.useState)([config.defaultValue, lodash_1.default.isArray(config.autoLoad) ? config.autoLoad : []]), 2), _b = __read(_a[0], 2), data = _b[0], param = _b[1], setData = _a[1];
79
+ var _c = __read((0, react_1.useState)(config.autoLoad != undefined ? true : false), 2), loading = _c[0], setLoading = _c[1];
80
+ var isFirstMount = (0, useFirstMountState_1.useFirstMountState)();
81
+ var _fetch = function () {
82
+ var args = [];
83
+ for (var _i = 0; _i < arguments.length; _i++) {
84
+ args[_i] = arguments[_i];
66
85
  }
67
- });
86
+ return __awaiter(void 0, void 0, void 0, function () {
87
+ var resp, err_1;
88
+ return __generator(this, function (_a) {
89
+ switch (_a.label) {
90
+ case 0:
91
+ _a.trys.push([0, 2, , 3]);
92
+ setLoading(true);
93
+ return [4 /*yield*/, config.fn.apply(config, __spreadArray([], __read(args), false))];
94
+ case 1:
95
+ resp = _a.sent();
96
+ if (lodash_1.default.has(resp, 'code') && resp.code != '0' && resp.message) {
97
+ antd_1.message.error(resp.message);
98
+ setData([config.defaultValue, args]);
99
+ setLoading(false);
100
+ return [2 /*return*/];
101
+ }
102
+ if (config.valueHander) {
103
+ if (lodash_1.default.isString(config.valueHander)) {
104
+ setData([lodash_1.default.get(resp, config.valueHander), args]);
105
+ }
106
+ else {
107
+ setData([config.valueHander.apply(config, __spreadArray([resp], __read(args), false)), args]);
108
+ }
109
+ }
110
+ else {
111
+ if (lodash_1.default.has(resp, 'data')) {
112
+ setData([resp.data, args]);
113
+ }
114
+ else if (lodash_1.default.has(resp, 'list')) {
115
+ setData([resp.list, args]);
116
+ }
117
+ else {
118
+ setData([resp, args]);
119
+ }
120
+ }
121
+ setLoading(false);
122
+ return [3 /*break*/, 3];
123
+ case 2:
124
+ err_1 = _a.sent();
125
+ console.error(err_1);
126
+ setData([config.defaultValue, args]);
127
+ setLoading(false);
128
+ return [3 /*break*/, 3];
129
+ case 3: return [2 /*return*/];
130
+ }
131
+ });
132
+ });
133
+ };
68
134
  if (isFirstMount && config.autoLoad) {
69
- const params = lodash_1.default.isArray(config.autoLoad) ? config.autoLoad : [];
70
- _fetch(...params);
135
+ var params = lodash_1.default.isArray(config.autoLoad) ? config.autoLoad : [];
136
+ _fetch.apply(void 0, __spreadArray([], __read(params), false));
71
137
  }
72
- const query = (...args) => {
73
- _fetch(...args);
138
+ var query = function () {
139
+ var args = [];
140
+ for (var _i = 0; _i < arguments.length; _i++) {
141
+ args[_i] = arguments[_i];
142
+ }
143
+ _fetch.apply(void 0, __spreadArray([], __read(args), false));
74
144
  };
75
145
  return [loading, data, query, param];
76
146
  };
package/hooks/useApi.js CHANGED
@@ -1,24 +1,51 @@
1
1
  "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __read = (this && this.__read) || function (o, n) {
14
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
15
+ if (!m) return o;
16
+ var i = m.call(o), r, ar = [], e;
17
+ try {
18
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
19
+ }
20
+ catch (error) { e = { error: error }; }
21
+ finally {
22
+ try {
23
+ if (r && !r.done && (m = i["return"])) m.call(i);
24
+ }
25
+ finally { if (e) throw e.error; }
26
+ }
27
+ return ar;
28
+ };
2
29
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
30
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
31
  };
5
32
  Object.defineProperty(exports, "__esModule", { value: true });
6
33
  exports.useApi = void 0;
7
- const lodash_1 = __importDefault(require("lodash"));
34
+ var lodash_1 = __importDefault(require("lodash"));
8
35
  ;
9
- const useSetState_1 = require("./useSetState");
10
- const _list_1 = require("./_list");
11
- const useApiBase_1 = require("./useApiBase");
12
- const useApi = (options) => {
13
- const config = lodash_1.default.isString(options) ? { api: options } : options;
14
- const BASE = Object.assign(Object.assign({}, _list_1.DEFAULT_STATE), { effect: null });
36
+ var useSetState_1 = require("./useSetState");
37
+ var _list_1 = require("./_list");
38
+ var useApiBase_1 = require("./useApiBase");
39
+ var useApi = function (options) {
40
+ var config = lodash_1.default.isString(options) ? { api: options } : options;
41
+ var BASE = __assign(__assign({}, _list_1.DEFAULT_STATE), { effect: null });
15
42
  BASE.rowKey = config.rowKey || 'id';
16
43
  ;
17
44
  if (config.list)
18
45
  BASE.list = config.list;
19
46
  if (config.pageSize)
20
47
  BASE.pageSize = config.pageSize;
21
- const [state, doLoad] = (0, useSetState_1.useSetState)(BASE);
48
+ var _a = __read((0, useSetState_1.useSetState)(BASE), 2), state = _a[0], doLoad = _a[1];
22
49
  return (0, useApiBase_1.useApiBase)(config, state, doLoad);
23
50
  };
24
51
  exports.useApi = useApi;