@zat-design/sisyphus-react 4.5.9 → 4.5.10-beta.2
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/dist/index.esm.css +1 -1
- package/dist/less.esm.css +1 -1
- package/es/FormsProvider/index.js +14 -21
- package/es/ProAction/components/CheckModalContent/index.js +12 -26
- package/es/ProAction/index.js +79 -83
- package/es/ProAction/propsType.js +0 -1
- package/es/ProConfigProvider/index.js +63 -110
- package/es/ProConfigProvider/propsType.js +0 -1
- package/es/ProDownload/index.d.ts +2 -1
- package/es/ProDownload/index.js +74 -69
- package/es/ProDownload/propsType.js +0 -1
- package/es/ProDownload/utils.d.ts +10 -5
- package/es/ProDownload/utils.js +63 -95
- package/es/ProDrawerForm/components/ProDrawer/index.js +83 -113
- package/es/ProDrawerForm/components/ProModal/index.js +77 -108
- package/es/ProDrawerForm/components/index.js +6 -2
- package/es/ProDrawerForm/hooks/useConfirmClose.js +20 -39
- package/es/ProDrawerForm/index.js +29 -38
- package/es/ProDrawerForm/propsType.js +0 -1
- package/es/ProDrawerForm/utils/index.js +18 -36
- package/es/ProEditLabel/components/RenderProForm.js +45 -49
- package/es/ProEditLabel/index.js +126 -163
- package/es/ProEditLabel/propsType.js +0 -1
- package/es/ProEditLabel/utils/index.js +5 -8
- package/es/ProEditTable/components/ActionButton/index.js +111 -119
- package/es/ProEditTable/components/RcTable/BaseTable.js +38 -51
- package/es/ProEditTable/components/RcTable/DraggableTable.js +97 -129
- package/es/ProEditTable/components/RcTable/index.js +6 -4
- package/es/ProEditTable/components/RenderField/ListChangedWrapper.js +77 -95
- package/es/ProEditTable/components/RenderField/index.js +490 -587
- package/es/ProEditTable/components/RenderField/propsType.js +0 -1
- package/es/ProEditTable/components/RenderField/tools.js +115 -112
- package/es/ProEditTable/components/RenderToolbar/index.js +47 -73
- package/es/ProEditTable/components/Summary/index.js +38 -64
- package/es/ProEditTable/components/Validator/index.js +46 -46
- package/es/ProEditTable/components/index.js +12 -5
- package/es/ProEditTable/index.js +456 -378
- package/es/ProEditTable/propsType.js +0 -1
- package/es/ProEditTable/utils/config.js +60 -122
- package/es/ProEditTable/utils/diffOriginal.js +45 -82
- package/es/ProEditTable/utils/getDefaultProps.js +19 -24
- package/es/ProEditTable/utils/index.js +154 -235
- package/es/ProEditTable/utils/tools.js +149 -286
- package/es/ProEditTable/utils/transform.js +25 -30
- package/es/ProEditTable/utils/useEditTableError.js +30 -43
- package/es/ProEditTable/utils/useShouldUpdateForTable.js +42 -72
- package/es/ProEditTable/utils/validateAll.js +87 -154
- package/es/ProEnum/components/Group.js +38 -30
- package/es/ProEnum/components/Tag.js +22 -26
- package/es/ProEnum/hooks/useEnum.js +48 -116
- package/es/ProEnum/hooks/useEnumRequest.js +182 -212
- package/es/ProEnum/hooks/useFrequentEnumRequest.js +40 -48
- package/es/ProEnum/index.js +162 -172
- package/es/ProEnum/propsType.js +0 -1
- package/es/ProEnum/utils/eventCenter.js +10 -12
- package/es/ProEnum/utils/frequentEnum.js +35 -92
- package/es/ProEnum/utils/getEnum.js +32 -90
- package/es/ProEnum/utils/getEnumLabel.js +44 -49
- package/es/ProEnum/utils/index.js +93 -207
- package/es/ProForm/components/Container.js +13 -28
- package/es/ProForm/components/FormFooter/index.js +36 -44
- package/es/ProForm/components/FormFooter/propsType.js +0 -1
- package/es/ProForm/components/base/Checkbox/index.js +32 -59
- package/es/ProForm/components/base/DatePicker/index.js +49 -71
- package/es/ProForm/components/base/Input/index.js +63 -97
- package/es/ProForm/components/base/Input/propsType.js +0 -1
- package/es/ProForm/components/base/InputNumber/index.js +118 -172
- package/es/ProForm/components/base/Radio/index.js +39 -52
- package/es/ProForm/components/base/RangePicker/index.js +109 -127
- package/es/ProForm/components/base/RangePicker/useDateRange.js +20 -17
- package/es/ProForm/components/base/Select/index.js +63 -89
- package/es/ProForm/components/base/Switch/index.js +27 -35
- package/es/ProForm/components/base/SwitchCheckbox/index.js +36 -54
- package/es/ProForm/components/base/TextArea/index.js +30 -41
- package/es/ProForm/components/base/TimePicker/index.js +27 -37
- package/es/ProForm/components/combination/Container/index.js +37 -47
- package/es/ProForm/components/combination/Container/propsType.js +0 -1
- package/es/ProForm/components/combination/FormList/components/ActionButton.js +165 -237
- package/es/ProForm/components/combination/FormList/components/BlockFields.js +98 -102
- package/es/ProForm/components/combination/FormList/components/Empty.js +28 -55
- package/es/ProForm/components/combination/FormList/components/LineFields.js +57 -54
- package/es/ProForm/components/combination/FormList/components/ToolbarButton.js +61 -109
- package/es/ProForm/components/combination/FormList/index.js +151 -161
- package/es/ProForm/components/combination/FormList/propsType.js +0 -1
- package/es/ProForm/components/combination/FormList/style/index.less +6 -0
- package/es/ProForm/components/combination/FormList/utils.js +22 -38
- package/es/ProForm/components/combination/Group/component/AddonWrapper/index.js +12 -28
- package/es/ProForm/components/combination/Group/component/ComRender.js +50 -111
- package/es/ProForm/components/combination/Group/component/FlexibleGroup.js +106 -213
- package/es/ProForm/components/combination/Group/hooks/index.js +69 -129
- package/es/ProForm/components/combination/Group/index.js +87 -126
- package/es/ProForm/components/combination/Group/propsType.js +0 -1
- package/es/ProForm/components/combination/Group/utils/index.js +124 -239
- package/es/ProForm/components/combination/ProCascader/index.js +156 -199
- package/es/ProForm/components/combination/ProCascader/propsType.js +0 -1
- package/es/ProForm/components/combination/ProCascader/utils/index.js +12 -21
- package/es/ProForm/components/combination/ProModalSelect/hooks/useRequestList.js +72 -70
- package/es/ProForm/components/combination/ProModalSelect/index.js +309 -347
- package/es/ProForm/components/combination/ProModalSelect/propsType.js +0 -1
- package/es/ProForm/components/combination/ProModalSelect/utils/index.js +32 -39
- package/es/ProForm/components/combination/ProNumberRange/index.js +100 -156
- package/es/ProForm/components/combination/ProNumberRange/propsType.js +0 -1
- package/es/ProForm/components/combination/ProRangeLimit/index.js +104 -115
- package/es/ProForm/components/combination/ProRangeLimit/propsType.js +0 -1
- package/es/ProForm/components/combination/ProTimeLimit/hooks/useControlled.js +16 -16
- package/es/ProForm/components/combination/ProTimeLimit/index.js +75 -109
- package/es/ProForm/components/index.js +56 -34
- package/es/ProForm/components/render/ChangedWrapper.js +85 -94
- package/es/ProForm/components/render/ConfirmWrapper.js +27 -39
- package/es/ProForm/components/render/CustomComponentViewWrapper.js +65 -82
- package/es/ProForm/components/render/Render.js +223 -329
- package/es/ProForm/components/render/RenderFields.js +76 -113
- package/es/ProForm/components/render/propsType.js +0 -1
- package/es/ProForm/hooks/useControlled.js +8 -10
- package/es/ProForm/hooks/useDeepCompareMemo.js +11 -11
- package/es/ProForm/hooks/useFieldProps.js +8 -4
- package/es/ProForm/hooks/useForm.js +50 -110
- package/es/ProForm/hooks/useRules.js +17 -33
- package/es/ProForm/hooks/useShouldUpdate.js +77 -152
- package/es/ProForm/hooks/useWatch.js +62 -134
- package/es/ProForm/index.js +157 -194
- package/es/ProForm/propsType.js +15 -7
- package/es/ProForm/utils/buildFormItemProps.js +51 -58
- package/es/ProForm/utils/diffOriginal.js +43 -73
- package/es/ProForm/utils/getDefaultProps.js +18 -24
- package/es/ProForm/utils/index.js +160 -235
- package/es/ProForm/utils/processDependencies.js +21 -60
- package/es/ProForm/utils/reactiveValues.js +20 -34
- package/es/ProForm/utils/rulesCreator.js +42 -40
- package/es/ProForm/utils/transformNames.js +10 -13
- package/es/ProForm/utils/transformValue.js +16 -29
- package/es/ProForm/utils/valueType.js +96 -178
- package/es/ProIcon/config/index.js +340 -274
- package/es/ProIcon/index.js +135 -209
- package/es/ProIcon/propsTypes.js +0 -1
- package/es/ProIcon/utils/index.js +24 -39
- package/es/ProLayout/components/Layout/Header/index.js +108 -141
- package/es/ProLayout/components/Layout/Menu/FoldMenu/index.js +134 -190
- package/es/ProLayout/components/Layout/Menu/OpenMenu/index.js +113 -139
- package/es/ProLayout/components/Layout/Menu/OpenMenu/propsType.js +0 -1
- package/es/ProLayout/components/Layout/Menu/SideMenu/index.js +23 -31
- package/es/ProLayout/components/Layout/Menu/index.js +92 -89
- package/es/ProLayout/components/Layout/Notice/index.js +13 -27
- package/es/ProLayout/components/Layout/index.js +8 -3
- package/es/ProLayout/components/ProCollapse/PropTypes.js +0 -1
- package/es/ProLayout/components/ProCollapse/index.js +89 -111
- package/es/ProLayout/components/ProFooter/PropTypes.js +0 -1
- package/es/ProLayout/components/ProFooter/index.js +27 -24
- package/es/ProLayout/components/ProHeader/PropTypes.js +0 -1
- package/es/ProLayout/components/ProHeader/components/Copy/index.js +23 -21
- package/es/ProLayout/components/ProHeader/components/Describe/index.js +67 -84
- package/es/ProLayout/components/ProHeader/components/ProBackBtn/index.js +18 -21
- package/es/ProLayout/components/ProHeader/components/ProBackBtn/propsType.js +0 -1
- package/es/ProLayout/components/ProHeader/components/index.js +6 -2
- package/es/ProLayout/components/ProHeader/index.js +216 -356
- package/es/ProLayout/components/ProHeader/utils/index.js +19 -26
- package/es/ProLayout/components/TabsManager/components/TabContextMenu.js +92 -85
- package/es/ProLayout/components/TabsManager/components/TabItem.js +53 -63
- package/es/ProLayout/components/TabsManager/components/TabsContext.js +5 -5
- package/es/ProLayout/components/TabsManager/components/TabsHeader.js +42 -52
- package/es/ProLayout/components/TabsManager/hooks/useActiveTab.js +8 -9
- package/es/ProLayout/components/TabsManager/hooks/useIframeRoute.js +19 -32
- package/es/ProLayout/components/TabsManager/hooks/useProLayoutTabs.js +6 -20
- package/es/ProLayout/components/TabsManager/hooks/useTabsCache.js +25 -42
- package/es/ProLayout/components/TabsManager/hooks/useTabsState.js +320 -350
- package/es/ProLayout/components/TabsManager/hooks/useTabsUrlSync.d.ts +19 -0
- package/es/ProLayout/components/TabsManager/hooks/useTabsUrlSync.js +332 -0
- package/es/ProLayout/components/TabsManager/index.js +407 -351
- package/es/ProLayout/components/TabsManager/propTypes.d.ts +4 -0
- package/es/ProLayout/components/TabsManager/propTypes.js +7 -15
- package/es/ProLayout/components/TabsManager/style/index.less +1 -1
- package/es/ProLayout/components/TabsManager/utils/historyObserver.d.ts +7 -0
- package/es/ProLayout/components/TabsManager/utils/historyObserver.js +65 -0
- package/es/ProLayout/components/TabsManager/utils/index.d.ts +15 -2
- package/es/ProLayout/components/TabsManager/utils/index.js +156 -159
- package/es/ProLayout/components/index.js +8 -3
- package/es/ProLayout/index.js +173 -228
- package/es/ProLayout/propTypes.d.ts +28 -1
- package/es/ProLayout/propTypes.js +12 -52
- package/es/ProLayout/utils/index.js +48 -128
- package/es/ProSelect/components/AdaptiveTooltip.js +26 -25
- package/es/ProSelect/index.js +187 -223
- package/es/ProSelect/propsType.js +0 -1
- package/es/ProSelect/style/index.less +13 -0
- package/es/ProSelect/utils/index.js +100 -146
- package/es/ProStep/components/Anchor/index.js +71 -82
- package/es/ProStep/components/Item/index.js +49 -56
- package/es/ProStep/components/LazyLoad/index.js +23 -29
- package/es/ProStep/components/Listener/index.js +20 -33
- package/es/ProStep/components/Step/index.js +31 -38
- package/es/ProStep/constants.js +4 -1
- package/es/ProStep/index.js +166 -153
- package/es/ProStep/propsType.js +0 -1
- package/es/ProStep/style/index.less +1 -1
- package/es/ProStep/utils/index.js +29 -55
- package/es/ProStepTab/index.js +83 -138
- package/es/ProStepTab/propsType.js +0 -1
- package/es/ProTable/components/EditableCell/EditIcon.js +10 -14
- package/es/ProTable/components/EditableCell/index.js +37 -71
- package/es/ProTable/components/EditableCell/propsType.js +0 -1
- package/es/ProTable/components/FormatColumn/index.js +209 -340
- package/es/ProTable/components/FormatColumn/propsType.js +0 -1
- package/es/ProTable/components/RcTable/components/BaseTable/index.js +35 -39
- package/es/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/index.js +80 -107
- package/es/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/utils/index.js +54 -48
- package/es/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/utils/propsType.js +0 -1
- package/es/ProTable/components/RcTable/components/DraggableTable/index.js +47 -54
- package/es/ProTable/components/RcTable/index.js +6 -4
- package/es/ProTable/components/RenderColumn/index.js +158 -186
- package/es/ProTable/components/RenderEmptyText/index.js +12 -21
- package/es/ProTable/components/RenderFooter/index.js +15 -15
- package/es/ProTable/components/RenderSummary/index.js +33 -50
- package/es/ProTable/components/RenderTableHeader/index.js +44 -46
- package/es/ProTable/components/RenderTabs/index.js +47 -51
- package/es/ProTable/components/TableResizable/index.js +56 -72
- package/es/ProTable/components/TooltipTitle/index.js +13 -21
- package/es/ProTable/components/index.js +16 -36
- package/es/ProTable/hooks/useAntdTable.js +191 -224
- package/es/ProTable/index.js +232 -249
- package/es/ProTable/propsType.js +0 -1
- package/es/ProTable/utils/columnStorage.js +63 -88
- package/es/ProTable/utils/index.js +57 -90
- package/es/ProTabs/components/Card/index.js +20 -48
- package/es/ProTabs/components/index.js +4 -1
- package/es/ProTabs/index.js +41 -58
- package/es/ProTabs/propType.js +0 -1
- package/es/ProThemeTools/component/ProTools/index.js +106 -158
- package/es/ProThemeTools/component/index.js +4 -1
- package/es/ProThemeTools/context/ThemeContext.js +67 -146
- package/es/ProThemeTools/index.js +103 -156
- package/es/ProThemeTools/propsType.js +0 -1
- package/es/ProThemeTools/utils/index.js +60 -109
- package/es/ProTooltip/index.js +132 -168
- package/es/ProTooltip/propsType.js +0 -1
- package/es/ProTree/components/AdaptiveTooltip.js +15 -17
- package/es/ProTree/components/CloseIcon.js +18 -26
- package/es/ProTree/components/List.js +28 -47
- package/es/ProTree/components/ProTree.js +152 -211
- package/es/ProTree/components/ProTreeSelect/index.js +255 -459
- package/es/ProTree/components/ProTreeSelect/propsType.js +0 -1
- package/es/ProTree/components/SearchTitle.js +23 -42
- package/es/ProTree/components/Tree.js +147 -195
- package/es/ProTree/components/index.js +10 -5
- package/es/ProTree/index.js +12 -16
- package/es/ProTree/propsType.js +0 -1
- package/es/ProTree/utils.js +46 -118
- package/es/ProTreeModal/components/Cascader.js +56 -64
- package/es/ProTreeModal/components/CloseIcon.js +18 -26
- package/es/ProTreeModal/components/List.js +114 -180
- package/es/ProTreeModal/components/SearchTitle.js +15 -18
- package/es/ProTreeModal/components/SortableItem.js +29 -58
- package/es/ProTreeModal/components/Tree.js +99 -113
- package/es/ProTreeModal/components/Trigger.js +87 -121
- package/es/ProTreeModal/components/index.js +14 -6
- package/es/ProTreeModal/index.js +397 -438
- package/es/ProTreeModal/propsType.js +0 -1
- package/es/ProTreeModal/utils.js +52 -95
- package/es/ProUpload/components/ButtonRender.js +44 -54
- package/es/ProUpload/components/DragRender.js +94 -148
- package/es/ProUpload/components/DraggableUploadListItem.js +12 -25
- package/es/ProUpload/components/Example.js +27 -31
- package/es/ProUpload/components/FileItem.js +69 -163
- package/es/ProUpload/components/ImageRender.js +134 -170
- package/es/ProUpload/index.js +68 -100
- package/es/ProUpload/propsType.js +0 -1
- package/es/ProUpload/uitls.js +8 -4
- package/es/ProUtils/utils/index.js +17 -13
- package/es/ProViewer/index.js +154 -175
- package/es/ProViewer/propsType.js +0 -5
- package/es/ProWaterMark/index.js +9 -16
- package/es/ProWaterMark/propsType.js +0 -1
- package/es/hooks/useDraggableRow.js +25 -53
- package/es/index.js +57 -77
- package/es/locale/en_US.js +153 -142
- package/es/locale/index.js +23 -36
- package/es/locale/zh_CN.js +145 -142
- package/es/tokens.js +84 -83
- package/es/utils/index.js +24 -51
- package/package.json +4 -2
- package/es/ProConfigProvider/demo/locale.js +0 -58
|
@@ -1,17 +1,27 @@
|
|
|
1
|
-
import { useEffect, useMemo, useRef } from
|
|
2
|
-
import { useDeepCompareEffect, useRequest as useRequestFunc } from
|
|
3
|
-
import {
|
|
1
|
+
import { useEffect, useMemo, useRef } from "react";
|
|
2
|
+
import { useDeepCompareEffect, useRequest as useRequestFunc } from "ahooks";
|
|
3
|
+
import {
|
|
4
|
+
diffCode,
|
|
5
|
+
getEnumData,
|
|
6
|
+
setEnumData,
|
|
7
|
+
removeEnumData,
|
|
8
|
+
cacheFieldNames,
|
|
9
|
+
cleanEnumResponse,
|
|
10
|
+
baseCacheKey,
|
|
11
|
+
baseStorage
|
|
12
|
+
} from "../utils";
|
|
4
13
|
import locale from "../../locale";
|
|
5
14
|
import "../utils/eventCenter";
|
|
6
15
|
const useEnumRequest = (props, dispatch) => {
|
|
16
|
+
var _a, _b;
|
|
7
17
|
const {
|
|
8
18
|
main = false,
|
|
9
19
|
share = false,
|
|
10
20
|
clear = true,
|
|
11
21
|
fieldNames = {
|
|
12
|
-
label:
|
|
13
|
-
value:
|
|
14
|
-
children:
|
|
22
|
+
label: "label",
|
|
23
|
+
value: "value",
|
|
24
|
+
children: "children"
|
|
15
25
|
},
|
|
16
26
|
cacheKey = baseCacheKey,
|
|
17
27
|
requestRefresh = false,
|
|
@@ -21,228 +31,196 @@ const useEnumRequest = (props, dispatch) => {
|
|
|
21
31
|
transformResponse,
|
|
22
32
|
dics = {}
|
|
23
33
|
} = props || {};
|
|
24
|
-
if (typeof dataSource ===
|
|
25
|
-
throw new Error(locale
|
|
34
|
+
if (typeof dataSource === "object" && dataSource === null) {
|
|
35
|
+
throw new Error((_b = (_a = locale) == null ? void 0 : _a.ProEnum) == null ? void 0 : _b.errorDataSource);
|
|
26
36
|
}
|
|
27
|
-
const logDebug = msg => {
|
|
37
|
+
const logDebug = (msg) => {
|
|
28
38
|
if (props.debugger) {
|
|
29
|
-
console.warn(
|
|
39
|
+
console.warn("proEnum:", msg);
|
|
30
40
|
}
|
|
31
41
|
};
|
|
32
|
-
|
|
33
|
-
// IndexedDB 缓存策略:包装 service,在 service 层面返回缓存数据,
|
|
34
|
-
// 而非跳过 run()。这样 enumRes.data/loading 正常变更,
|
|
35
|
-
// ProConfigProvider 的 onSuccess 回调能正常触发(修复白屏问题)。
|
|
36
42
|
const fromCacheRef = useRef(null);
|
|
37
|
-
const
|
|
43
|
+
const errorReportedRef = useRef(false);
|
|
44
|
+
const originalService = useRequest == null ? void 0 : useRequest.service;
|
|
38
45
|
const serviceForRequest = useMemo(() => {
|
|
39
|
-
if (!originalService || storage !==
|
|
46
|
+
if (!originalService || storage !== "indexedDB") {
|
|
40
47
|
return originalService;
|
|
41
48
|
}
|
|
42
49
|
return async (...args) => {
|
|
43
50
|
if (!requestRefresh) {
|
|
44
51
|
const cached = await Promise.resolve(getEnumData(storage, cacheKey));
|
|
45
|
-
if (cached
|
|
52
|
+
if ((cached == null ? void 0 : cached.data) && Object.keys(cached.data).length > 0 && (cached == null ? void 0 : cached.time) && Date.now() - cached.time <= 6e4 * 60) {
|
|
46
53
|
fromCacheRef.current = cached.data;
|
|
47
|
-
return {
|
|
48
|
-
status: 200,
|
|
49
|
-
data: cached.data
|
|
50
|
-
};
|
|
54
|
+
return { status: 200, data: cached.data };
|
|
51
55
|
}
|
|
52
56
|
}
|
|
53
57
|
fromCacheRef.current = null;
|
|
54
58
|
return originalService(...args);
|
|
55
59
|
};
|
|
56
60
|
}, [originalService, storage, requestRefresh, cacheKey]);
|
|
61
|
+
const reportBackgroundError = (error, params = []) => {
|
|
62
|
+
var _a2, _b2;
|
|
63
|
+
if (errorReportedRef.current) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
errorReportedRef.current = true;
|
|
67
|
+
const normalizedError = error instanceof Error ? error : new Error(String(error));
|
|
68
|
+
(_b2 = (_a2 = useRequest == null ? void 0 : useRequest.options) == null ? void 0 : _a2.onError) == null ? void 0 : _b2.call(_a2, normalizedError, params);
|
|
69
|
+
};
|
|
57
70
|
const enumRes = useRequestFunc(serviceForRequest, {
|
|
58
71
|
manual: true,
|
|
59
72
|
cacheKey,
|
|
60
73
|
cacheTime: -1,
|
|
61
74
|
staleTime: 6e4 * 60,
|
|
62
|
-
...useRequest
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
75
|
+
...useRequest == null ? void 0 : useRequest.options,
|
|
76
|
+
onBefore: (params) => {
|
|
77
|
+
var _a2, _b2;
|
|
78
|
+
errorReportedRef.current = false;
|
|
79
|
+
(_b2 = (_a2 = useRequest == null ? void 0 : useRequest.options) == null ? void 0 : _a2.onBefore) == null ? void 0 : _b2.call(_a2, params);
|
|
80
|
+
},
|
|
81
|
+
onError: reportBackgroundError,
|
|
82
|
+
setCache: async (res) => {
|
|
83
|
+
var _a2, _b2, _c;
|
|
84
|
+
try {
|
|
85
|
+
if (fromCacheRef.current) {
|
|
86
|
+
const cachedData = fromCacheRef.current;
|
|
87
|
+
const mergedPayload2 = { ...dics, ...cachedData, ...dataSource };
|
|
88
|
+
dispatch({
|
|
89
|
+
type: "setProEnumDic",
|
|
90
|
+
payload: mergedPayload2
|
|
91
|
+
});
|
|
92
|
+
if (main) {
|
|
93
|
+
setTimeout(() => {
|
|
94
|
+
var _a3, _b3, _c2;
|
|
95
|
+
(_a3 = window == null ? void 0 : window.eventCenter) == null ? void 0 : _a3.publish("pro-enum-event", cachedData);
|
|
96
|
+
logDebug((_c2 = (_b3 = locale) == null ? void 0 : _b3.ProEnum) == null ? void 0 : _c2.mainInitByCache);
|
|
97
|
+
}, 1e4);
|
|
98
|
+
}
|
|
99
|
+
fromCacheRef.current = null;
|
|
100
|
+
return res;
|
|
101
|
+
}
|
|
102
|
+
let response = res.data;
|
|
103
|
+
if (transformResponse && typeof transformResponse === "function") {
|
|
104
|
+
response = await transformResponse(res.data);
|
|
105
|
+
if (typeof response !== "object" || response == null) {
|
|
106
|
+
throw new Error((_b2 = (_a2 = locale) == null ? void 0 : _a2.ProEnum) == null ? void 0 : _b2.errorMessage);
|
|
107
|
+
} else {
|
|
108
|
+
res.data = response;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (typeof response !== "object" || response === null) {
|
|
112
|
+
throw Error("response enum data must be object");
|
|
113
|
+
}
|
|
114
|
+
if (Object.keys(response).length === 0) {
|
|
115
|
+
throw Error("Please return valid enumeration data");
|
|
116
|
+
}
|
|
117
|
+
if (clear) {
|
|
118
|
+
const ignoreCodes = ((_c = useRequest == null ? void 0 : useRequest.options) == null ? void 0 : _c.ignoreCodes) || [];
|
|
119
|
+
Object.keys(response).forEach((key) => {
|
|
120
|
+
if (!response[key] || !Array.isArray(response[key])) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
const options = [...response[key]];
|
|
124
|
+
if (ignoreCodes.includes(key)) {
|
|
125
|
+
response[key] = options;
|
|
126
|
+
} else {
|
|
127
|
+
response[key] = options.map((item) => {
|
|
128
|
+
return cacheFieldNames(fieldNames, item);
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
res.data = response;
|
|
133
|
+
}
|
|
134
|
+
const cacheData = await Promise.resolve(getEnumData(storage, cacheKey) || { data: {} });
|
|
135
|
+
res.data = {
|
|
136
|
+
...cacheData == null ? void 0 : cacheData.data,
|
|
137
|
+
...res.data
|
|
71
138
|
};
|
|
139
|
+
await Promise.resolve(setEnumData(storage, cacheKey, res));
|
|
140
|
+
const mergedPayload = { ...dics, ...res.data, ...dataSource };
|
|
72
141
|
dispatch({
|
|
73
|
-
type:
|
|
142
|
+
type: "setProEnumDic",
|
|
74
143
|
payload: mergedPayload
|
|
75
144
|
});
|
|
76
145
|
if (main) {
|
|
77
146
|
setTimeout(() => {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
147
|
+
var _a3, _b3, _c2;
|
|
148
|
+
(_a3 = window == null ? void 0 : window.eventCenter) == null ? void 0 : _a3.publish("pro-enum-event", res.data);
|
|
149
|
+
logDebug((_c2 = (_b3 = locale) == null ? void 0 : _b3.ProEnum) == null ? void 0 : _c2.mainInitByRequest);
|
|
150
|
+
}, 1e4);
|
|
81
151
|
}
|
|
82
|
-
|
|
152
|
+
return res;
|
|
153
|
+
} catch (error) {
|
|
154
|
+
reportBackgroundError(error);
|
|
83
155
|
return res;
|
|
84
156
|
}
|
|
85
|
-
let response = res.data;
|
|
86
|
-
if (transformResponse && typeof transformResponse === 'function') {
|
|
87
|
-
response = await transformResponse(res.data);
|
|
88
|
-
if (typeof response !== 'object' || response == null) {
|
|
89
|
-
throw new Error(locale?.ProEnum?.errorMessage);
|
|
90
|
-
} else {
|
|
91
|
-
res.data = response;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
if (typeof response !== 'object' || response === null) {
|
|
95
|
-
throw Error('response enum data must be object');
|
|
96
|
-
}
|
|
97
|
-
if (Object.keys(response).length === 0) {
|
|
98
|
-
throw Error('Please return valid enumeration data');
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// 只返回fieldNames对象的key
|
|
102
|
-
if (clear) {
|
|
103
|
-
// 忽略清洗的 codes
|
|
104
|
-
const ignoreCodes = useRequest?.options?.ignoreCodes || [];
|
|
105
|
-
Object.keys(response).forEach(key => {
|
|
106
|
-
if (!response[key] || !Array.isArray(response[key])) {
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
const options = [...response[key]];
|
|
110
|
-
if (ignoreCodes.includes(key)) {
|
|
111
|
-
response[key] = options;
|
|
112
|
-
} else {
|
|
113
|
-
response[key] = options.map(item => {
|
|
114
|
-
return cacheFieldNames(fieldNames, item);
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
res.data = response;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
// 获取缓存数据(支持异步)
|
|
122
|
-
const cacheData = await Promise.resolve(getEnumData(storage, cacheKey) || {
|
|
123
|
-
data: {}
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
// 合并缓存数据
|
|
127
|
-
res.data = {
|
|
128
|
-
...cacheData?.data,
|
|
129
|
-
...res.data
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
// 设置缓存数据(支持异步)
|
|
133
|
-
await Promise.resolve(setEnumData(storage, cacheKey, res));
|
|
134
|
-
|
|
135
|
-
// 同步数据到全局
|
|
136
|
-
const mergedPayload = {
|
|
137
|
-
...dics,
|
|
138
|
-
...res.data,
|
|
139
|
-
...dataSource
|
|
140
|
-
};
|
|
141
|
-
dispatch({
|
|
142
|
-
type: 'setProEnumDic',
|
|
143
|
-
payload: mergedPayload
|
|
144
|
-
});
|
|
145
|
-
if (main) {
|
|
146
|
-
setTimeout(() => {
|
|
147
|
-
window?.eventCenter?.publish('pro-enum-event', res.data);
|
|
148
|
-
logDebug(locale?.ProEnum?.mainInitByRequest);
|
|
149
|
-
}, 10000);
|
|
150
|
-
}
|
|
151
|
-
return res;
|
|
152
157
|
},
|
|
153
|
-
getCache: params => {
|
|
154
|
-
if (storage ===
|
|
155
|
-
return
|
|
158
|
+
getCache: (params) => {
|
|
159
|
+
if (storage === "indexedDB") {
|
|
160
|
+
return void 0;
|
|
156
161
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
const res = getEnumData(storage, cacheKey) || {
|
|
160
|
-
data: {}
|
|
161
|
-
};
|
|
162
|
-
const mergedPayload = {
|
|
163
|
-
...dics,
|
|
164
|
-
...res?.data,
|
|
165
|
-
...dataSource
|
|
166
|
-
};
|
|
162
|
+
const res = getEnumData(storage, cacheKey) || { data: {} };
|
|
163
|
+
const mergedPayload = { ...dics, ...res == null ? void 0 : res.data, ...dataSource };
|
|
167
164
|
dispatch({
|
|
168
|
-
type:
|
|
165
|
+
type: "setProEnumDic",
|
|
169
166
|
payload: mergedPayload
|
|
170
167
|
});
|
|
171
168
|
if (main) {
|
|
172
169
|
setTimeout(() => {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
170
|
+
var _a2, _b2, _c;
|
|
171
|
+
(_a2 = window == null ? void 0 : window.eventCenter) == null ? void 0 : _a2.publish("pro-enum-event", res.data);
|
|
172
|
+
logDebug((_c = (_b2 = locale) == null ? void 0 : _b2.ProEnum) == null ? void 0 : _c.mainInitByCache);
|
|
173
|
+
}, 1e4);
|
|
176
174
|
}
|
|
177
175
|
return res;
|
|
178
176
|
},
|
|
179
|
-
onSuccess: res => {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
message: msg
|
|
183
|
-
} = res;
|
|
177
|
+
onSuccess: (res) => {
|
|
178
|
+
var _a2, _b2;
|
|
179
|
+
const { status = 200, message: msg } = res;
|
|
184
180
|
if (status !== 200) {
|
|
185
|
-
throw new Error(locale
|
|
181
|
+
throw new Error((_b2 = (_a2 = locale) == null ? void 0 : _a2.ProEnum) == null ? void 0 : _b2.requestError);
|
|
186
182
|
}
|
|
187
183
|
}
|
|
188
184
|
});
|
|
189
185
|
const mergeData = async () => {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
if (typeof cacheData.data === 'object' && cacheData.data !== null) {
|
|
186
|
+
var _a2, _b2, _c, _d;
|
|
187
|
+
const cacheData = await Promise.resolve(getEnumData(storage, cacheKey) || { data: {} });
|
|
188
|
+
if (typeof cacheData === "object") {
|
|
189
|
+
if (typeof cacheData.data === "object" && cacheData.data !== null) {
|
|
195
190
|
const enumData = cacheData.data;
|
|
196
191
|
const cacheCodes = Object.keys(enumData);
|
|
197
|
-
const codes = useRequest
|
|
198
|
-
const ignoreCodes = useRequest
|
|
199
|
-
|
|
192
|
+
const codes = ((_a2 = useRequest == null ? void 0 : useRequest.options) == null ? void 0 : _a2.codes) || [];
|
|
193
|
+
const ignoreCodes = ((_b2 = useRequest == null ? void 0 : useRequest.options) == null ? void 0 : _b2.ignoreCodes) || [];
|
|
200
194
|
const diff = diffCode(cacheCodes, codes);
|
|
201
195
|
if (diff) {
|
|
202
196
|
let response;
|
|
203
|
-
const res = await useRequest
|
|
204
|
-
if (transformResponse && typeof transformResponse ===
|
|
197
|
+
const res = await (useRequest == null ? void 0 : useRequest.service());
|
|
198
|
+
if (transformResponse && typeof transformResponse === "function") {
|
|
205
199
|
response = await transformResponse(res);
|
|
206
|
-
if (typeof response !==
|
|
207
|
-
throw new Error(locale
|
|
200
|
+
if (typeof response !== "object" || response == null) {
|
|
201
|
+
throw new Error((_d = (_c = locale) == null ? void 0 : _c.ProEnum) == null ? void 0 : _d.errorMessage);
|
|
208
202
|
}
|
|
209
203
|
} else if (res.status === 200) {
|
|
210
204
|
response = res.data;
|
|
211
205
|
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
clear,
|
|
215
|
-
ignoreCodes,
|
|
216
|
-
fieldNames
|
|
217
|
-
});
|
|
218
|
-
cacheData.data = {
|
|
219
|
-
...cacheData.data,
|
|
220
|
-
...response
|
|
221
|
-
};
|
|
206
|
+
response = cleanEnumResponse(response, { clear, ignoreCodes, fieldNames });
|
|
207
|
+
cacheData.data = { ...cacheData.data, ...response };
|
|
222
208
|
await Promise.resolve(setEnumData(storage, cacheKey, cacheData));
|
|
223
|
-
// 同步数据到全局
|
|
224
209
|
dispatch({
|
|
225
|
-
type:
|
|
226
|
-
payload: {
|
|
227
|
-
...dics,
|
|
228
|
-
...cacheData.data,
|
|
229
|
-
...dataSource
|
|
230
|
-
}
|
|
210
|
+
type: "setProEnumDic",
|
|
211
|
+
payload: { ...dics, ...cacheData.data, ...dataSource }
|
|
231
212
|
});
|
|
232
213
|
} else if (dataSource && Object.keys(dataSource).length > 0) {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
data: mergedPayload,
|
|
242
|
-
time: Date.now()
|
|
243
|
-
}));
|
|
214
|
+
const mergedPayload = { ...dics, ...cacheData.data, ...dataSource };
|
|
215
|
+
await Promise.resolve(
|
|
216
|
+
setEnumData(storage, cacheKey, {
|
|
217
|
+
...cacheData,
|
|
218
|
+
data: mergedPayload,
|
|
219
|
+
time: Date.now()
|
|
220
|
+
})
|
|
221
|
+
);
|
|
244
222
|
dispatch({
|
|
245
|
-
type:
|
|
223
|
+
type: "setProEnumDic",
|
|
246
224
|
payload: mergedPayload
|
|
247
225
|
});
|
|
248
226
|
}
|
|
@@ -250,79 +228,71 @@ const useEnumRequest = (props, dispatch) => {
|
|
|
250
228
|
}
|
|
251
229
|
};
|
|
252
230
|
useDeepCompareEffect(() => {
|
|
231
|
+
errorReportedRef.current = false;
|
|
253
232
|
const executeAsync = async () => {
|
|
254
|
-
if (useRequest && useRequest
|
|
255
|
-
const {
|
|
256
|
-
|
|
257
|
-
} = useRequest?.options || {};
|
|
258
|
-
const params = Array.isArray(defaultParams) ? defaultParams?.[0] : defaultParams || {};
|
|
233
|
+
if (useRequest && (useRequest == null ? void 0 : useRequest.service)) {
|
|
234
|
+
const { defaultParams } = (useRequest == null ? void 0 : useRequest.options) || {};
|
|
235
|
+
const params = Array.isArray(defaultParams) ? defaultParams == null ? void 0 : defaultParams[0] : defaultParams || {};
|
|
259
236
|
if (requestRefresh) {
|
|
260
237
|
window.localStorage.removeItem(cacheKey);
|
|
261
238
|
window.sessionStorage.removeItem(cacheKey);
|
|
262
|
-
if (storage ===
|
|
263
|
-
await removeEnumData(
|
|
239
|
+
if (storage === "indexedDB") {
|
|
240
|
+
await removeEnumData("indexedDB", cacheKey);
|
|
264
241
|
}
|
|
265
242
|
}
|
|
266
243
|
enumRes.run(params);
|
|
267
|
-
mergeData();
|
|
244
|
+
void mergeData().catch(reportBackgroundError);
|
|
268
245
|
} else if (dataSource && Object.keys(dataSource).length > 0) {
|
|
269
|
-
const res = await Promise.resolve(getEnumData(storage, cacheKey) || {
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
data: mergedData,
|
|
279
|
-
time: Date.now()
|
|
280
|
-
}));
|
|
246
|
+
const res = await Promise.resolve(getEnumData(storage, cacheKey) || { data: {} });
|
|
247
|
+
const mergedData = { ...res == null ? void 0 : res.data, ...dataSource };
|
|
248
|
+
await Promise.resolve(
|
|
249
|
+
setEnumData(storage, cacheKey, {
|
|
250
|
+
...res,
|
|
251
|
+
data: mergedData,
|
|
252
|
+
time: Date.now()
|
|
253
|
+
})
|
|
254
|
+
);
|
|
281
255
|
dispatch({
|
|
282
|
-
type:
|
|
256
|
+
type: "setProEnumDic",
|
|
283
257
|
payload: mergedData
|
|
284
258
|
});
|
|
285
259
|
} else {
|
|
286
|
-
const res = await Promise.resolve(getEnumData(storage, cacheKey) || {
|
|
287
|
-
data: {}
|
|
288
|
-
});
|
|
260
|
+
const res = await Promise.resolve(getEnumData(storage, cacheKey) || { data: {} });
|
|
289
261
|
dispatch({
|
|
290
|
-
type:
|
|
291
|
-
payload: {
|
|
292
|
-
...res?.data
|
|
293
|
-
}
|
|
262
|
+
type: "setProEnumDic",
|
|
263
|
+
payload: { ...res == null ? void 0 : res.data }
|
|
294
264
|
});
|
|
295
265
|
}
|
|
296
266
|
};
|
|
297
|
-
executeAsync();
|
|
298
|
-
}, [useRequest
|
|
299
|
-
const shareProEnumDic = async cacheData => {
|
|
267
|
+
void executeAsync().catch(reportBackgroundError);
|
|
268
|
+
}, [useRequest == null ? void 0 : useRequest.options]);
|
|
269
|
+
const shareProEnumDic = async (cacheData) => {
|
|
300
270
|
logDebug(cacheData);
|
|
301
|
-
const storageData = await Promise.resolve(getEnumData(storage, cacheKey) || {
|
|
302
|
-
|
|
303
|
-
});
|
|
271
|
+
const storageData = await Promise.resolve(getEnumData(storage, cacheKey) || { data: {} });
|
|
272
|
+
const storagePayload = typeof (storageData == null ? void 0 : storageData.data) === "object" && storageData.data !== null ? storageData.data : storageData;
|
|
304
273
|
dispatch({
|
|
305
|
-
type:
|
|
306
|
-
payload: {
|
|
307
|
-
...dataSource,
|
|
308
|
-
...cacheData,
|
|
309
|
-
...storageData
|
|
310
|
-
}
|
|
274
|
+
type: "setProEnumDic",
|
|
275
|
+
payload: { ...dataSource, ...cacheData, ...storagePayload }
|
|
311
276
|
});
|
|
312
277
|
};
|
|
313
278
|
useEffect(() => {
|
|
279
|
+
var _a2, _b2, _c, _d, _e, _f;
|
|
314
280
|
if (main) {
|
|
315
|
-
window
|
|
316
|
-
logDebug(locale
|
|
281
|
+
(_a2 = window == null ? void 0 : window.eventCenter) == null ? void 0 : _a2.publish("pro-enum-event", {});
|
|
282
|
+
logDebug((_c = (_b2 = locale) == null ? void 0 : _b2.ProEnum) == null ? void 0 : _c.mainInitOnce);
|
|
317
283
|
}
|
|
318
284
|
if (!main && share) {
|
|
319
|
-
window
|
|
320
|
-
logDebug(locale
|
|
285
|
+
(_d = window == null ? void 0 : window.eventCenter) == null ? void 0 : _d.subscribe("pro-enum-event", shareProEnumDic);
|
|
286
|
+
logDebug((_f = (_e = locale) == null ? void 0 : _e.ProEnum) == null ? void 0 : _f.sonInitEvent);
|
|
321
287
|
}
|
|
322
288
|
return () => {
|
|
323
|
-
|
|
289
|
+
var _a3;
|
|
290
|
+
(_a3 = window == null ? void 0 : window.eventCenter) == null ? void 0 : _a3.unsubscribe("pro-enum-event", shareProEnumDic);
|
|
324
291
|
};
|
|
325
292
|
}, []);
|
|
326
293
|
return enumRes;
|
|
327
294
|
};
|
|
328
|
-
|
|
295
|
+
var useEnumRequest_default = useEnumRequest;
|
|
296
|
+
export {
|
|
297
|
+
useEnumRequest_default as default
|
|
298
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useDeepCompareEffect, useRequest as useRequestFunc } from
|
|
1
|
+
import { useDeepCompareEffect, useRequest as useRequestFunc } from "ahooks";
|
|
2
2
|
import { replaceFrequentEnumCache } from "../utils/frequentEnum";
|
|
3
3
|
import { baseCacheKey } from "../utils";
|
|
4
4
|
const useFrequentEnumRequest = (props, dispatch) => {
|
|
@@ -6,61 +6,53 @@ const useFrequentEnumRequest = (props, dispatch) => {
|
|
|
6
6
|
frequentEnums,
|
|
7
7
|
fieldNames,
|
|
8
8
|
clear = true,
|
|
9
|
-
storage =
|
|
9
|
+
storage = "localStorage",
|
|
10
10
|
cacheKey = baseCacheKey,
|
|
11
11
|
dics,
|
|
12
12
|
dataSource
|
|
13
13
|
} = props;
|
|
14
|
-
const frequentEnumRes = useRequestFunc(
|
|
15
|
-
data: {}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
response = frequentEnums.transformResponse(res);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// 确保response.data存在,如果不存在则使用response本身
|
|
27
|
-
const enumData = response?.data || response;
|
|
28
|
-
|
|
29
|
-
// 替换缓存中的指定枚举(支持异步)
|
|
30
|
-
const updatedCacheData = await Promise.resolve(replaceFrequentEnumCache({
|
|
31
|
-
storage,
|
|
32
|
-
cacheKey,
|
|
33
|
-
enums: frequentEnums?.enums || [],
|
|
34
|
-
newData: enumData,
|
|
35
|
-
fieldNames,
|
|
36
|
-
clear
|
|
37
|
-
}));
|
|
38
|
-
|
|
39
|
-
// 同步数据到全局状态
|
|
40
|
-
dispatch({
|
|
41
|
-
type: 'setProEnumDic',
|
|
42
|
-
payload: {
|
|
43
|
-
...dics,
|
|
44
|
-
...dataSource,
|
|
45
|
-
...updatedCacheData.data
|
|
14
|
+
const frequentEnumRes = useRequestFunc(
|
|
15
|
+
(frequentEnums == null ? void 0 : frequentEnums.service) || (() => Promise.resolve({ data: {} })),
|
|
16
|
+
{
|
|
17
|
+
manual: true,
|
|
18
|
+
...frequentEnums == null ? void 0 : frequentEnums.options,
|
|
19
|
+
onSuccess: async (res) => {
|
|
20
|
+
let response = res;
|
|
21
|
+
if ((frequentEnums == null ? void 0 : frequentEnums.transformResponse) && typeof frequentEnums.transformResponse === "function") {
|
|
22
|
+
response = frequentEnums.transformResponse(res);
|
|
46
23
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
24
|
+
const enumData = (response == null ? void 0 : response.data) || response;
|
|
25
|
+
const updatedCacheData = await Promise.resolve(
|
|
26
|
+
replaceFrequentEnumCache({
|
|
27
|
+
storage,
|
|
28
|
+
cacheKey,
|
|
29
|
+
enums: (frequentEnums == null ? void 0 : frequentEnums.enums) || [],
|
|
30
|
+
newData: enumData,
|
|
31
|
+
fieldNames,
|
|
32
|
+
clear
|
|
33
|
+
})
|
|
34
|
+
);
|
|
35
|
+
dispatch({
|
|
36
|
+
type: "setProEnumDic",
|
|
37
|
+
payload: { ...dics, ...dataSource, ...updatedCacheData.data }
|
|
38
|
+
});
|
|
39
|
+
},
|
|
40
|
+
onError: (error) => {
|
|
41
|
+
console.warn("ProEnum: Frequent enum request failed:", error);
|
|
42
|
+
}
|
|
51
43
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
// 处理频繁枚举请求
|
|
44
|
+
);
|
|
55
45
|
useDeepCompareEffect(() => {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const params = Array.isArray(defaultParams) ? defaultParams?.[0] : defaultParams || {};
|
|
46
|
+
var _a;
|
|
47
|
+
if (frequentEnums && (frequentEnums == null ? void 0 : frequentEnums.service) && ((_a = frequentEnums == null ? void 0 : frequentEnums.enums) == null ? void 0 : _a.length)) {
|
|
48
|
+
const { defaultParams } = (frequentEnums == null ? void 0 : frequentEnums.options) || {};
|
|
49
|
+
const params = Array.isArray(defaultParams) ? defaultParams == null ? void 0 : defaultParams[0] : defaultParams || {};
|
|
61
50
|
frequentEnumRes.run(params);
|
|
62
51
|
}
|
|
63
|
-
}, [frequentEnums
|
|
52
|
+
}, [frequentEnums == null ? void 0 : frequentEnums.options]);
|
|
64
53
|
return frequentEnumRes;
|
|
65
54
|
};
|
|
66
|
-
|
|
55
|
+
var useFrequentEnumRequest_default = useFrequentEnumRequest;
|
|
56
|
+
export {
|
|
57
|
+
useFrequentEnumRequest_default as default
|
|
58
|
+
};
|