vap1 0.0.1
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/basetype.d.ts +62 -0
- package/basetype.js +2 -0
- package/components/Box/Box.d.ts +118 -0
- package/components/Box/Box.js +150 -0
- package/components/Box/SelectBar.d.ts +90 -0
- package/components/Box/SelectBar.js +93 -0
- package/components/Box/_register.d.ts +49 -0
- package/components/Box/_register.js +29 -0
- package/components/Box/index.d.ts +9 -0
- package/components/Box/index.js +6 -0
- package/components/Lists/SList.d.ts +58 -0
- package/components/Lists/SList.js +167 -0
- package/components/SearchBar/ActionButtons.d.ts +49 -0
- package/components/SearchBar/ActionButtons.js +96 -0
- package/components/SearchBar/ByField.d.ts +3 -0
- package/components/SearchBar/ByField.js +193 -0
- package/components/SearchBar/ByKeyword.d.ts +3 -0
- package/components/SearchBar/ByKeyword.js +34 -0
- package/components/SearchBar/SearchField.d.ts +15 -0
- package/components/SearchBar/SearchField.js +25 -0
- package/components/SearchBar/SearchTags.d.ts +2 -0
- package/components/SearchBar/SearchTags.js +18 -0
- package/components/SearchBar/_FieldType.d.ts +8 -0
- package/components/SearchBar/_FieldType.js +45 -0
- package/components/SearchBar/_register.d.ts +65 -0
- package/components/SearchBar/_register.js +29 -0
- package/components/SearchBar/index.d.ts +134 -0
- package/components/SearchBar/index.js +33 -0
- package/components/Tables/ApiTable.d.ts +18 -0
- package/components/Tables/ApiTable.js +48 -0
- package/components/Tables/ApiTableModal.d.ts +22 -0
- package/components/Tables/ApiTableModal.js +73 -0
- package/components/Tables/Components/ActionBar.d.ts +56 -0
- package/components/Tables/Components/ActionBar.js +100 -0
- package/components/Tables/Components/Actions.d.ts +47 -0
- package/components/Tables/Components/Actions.js +91 -0
- package/components/Tables/Components/Summary.d.ts +11 -0
- package/components/Tables/Components/Summary.js +11 -0
- package/components/Tables/Components/index.d.ts +17 -0
- package/components/Tables/Components/index.js +19 -0
- package/components/Tables/STable.d.ts +5 -0
- package/components/Tables/STable.js +37 -0
- package/components/Tables/TopTable.d.ts +24 -0
- package/components/Tables/TopTable.js +157 -0
- package/components/Tables/TopTableModal.d.ts +5 -0
- package/components/Tables/TopTableModal.js +20 -0
- package/components/Tables/Util.d.ts +3 -0
- package/components/Tables/Util.js +41 -0
- package/components/Tables/VTable.d.ts +11 -0
- package/components/Tables/VTable.js +237 -0
- package/components/Tables/index.d.ts +81 -0
- package/components/Tables/index.js +20 -0
- package/components/TreeSelect/BaseTreeSelect.d.ts +33 -0
- package/components/TreeSelect/BaseTreeSelect.js +190 -0
- package/components/TreeSelect/DTreeSelect.d.ts +24 -0
- package/components/TreeSelect/DTreeSelect.js +66 -0
- package/components/TreeSelect/FTreeSelect.d.ts +11 -0
- package/components/TreeSelect/FTreeSelect.js +39 -0
- package/components/TreeSelect/STreeSelect.d.ts +14 -0
- package/components/TreeSelect/STreeSelect.js +52 -0
- package/components/TreeSelect/index.d.ts +94 -0
- package/components/TreeSelect/index.js +9 -0
- package/components/Trees/ActionTree.d.ts +54 -0
- package/components/Trees/ActionTree.js +657 -0
- package/components/Trees/BaseTree.d.ts +31 -0
- package/components/Trees/BaseTree.js +185 -0
- package/components/Trees/DTree.d.ts +48 -0
- package/components/Trees/DTree.js +142 -0
- package/components/Trees/FTree.d.ts +33 -0
- package/components/Trees/FTree.js +79 -0
- package/components/Trees/STree.d.ts +21 -0
- package/components/Trees/STree.js +92 -0
- package/components/Trees/index.d.ts +134 -0
- package/components/Trees/index.js +9 -0
- package/components/UForm/FormWrapper.d.ts +22 -0
- package/components/UForm/FormWrapper.js +270 -0
- package/components/UForm/UDescriptions.d.ts +5 -0
- package/components/UForm/UDescriptions.js +134 -0
- package/components/UForm/UForm.d.ts +33 -0
- package/components/UForm/UForm.js +484 -0
- package/components/UForm/UFormModal.d.ts +3 -0
- package/components/UForm/UFormModal.js +149 -0
- package/components/UForm/UInfo.d.ts +10 -0
- package/components/UForm/UInfo.js +75 -0
- package/components/UForm/UInfoModal.d.ts +3 -0
- package/components/UForm/UInfoModal.js +50 -0
- package/components/UForm/UModal.d.ts +3 -0
- package/components/UForm/UModal.js +24 -0
- package/components/UForm/_FieldType.d.ts +8 -0
- package/components/UForm/_FieldType.js +100 -0
- package/components/UForm/_FormUtils.d.ts +5 -0
- package/components/UForm/_FormUtils.js +75 -0
- package/components/UForm/_input.d.ts +59 -0
- package/components/UForm/_input.js +147 -0
- package/components/UForm/_register.d.ts +87 -0
- package/components/UForm/_register.js +44 -0
- package/components/UForm/index.d.ts +387 -0
- package/components/UForm/index.js +15 -0
- package/components/Upload/UploadFile.d.ts +3 -0
- package/components/Upload/UploadFile.js +40 -0
- package/components/Upload/UploadImage.d.ts +24 -0
- package/components/Upload/UploadImage.js +93 -0
- package/components/Upload/UploadModal.d.ts +50 -0
- package/components/Upload/UploadModal.js +140 -0
- package/components/Upload/index.d.ts +77 -0
- package/components/Upload/index.js +9 -0
- package/components/Upload/useUpload.d.ts +15 -0
- package/components/Upload/useUpload.js +93 -0
- package/components/_RegisterUtil.d.ts +1 -0
- package/components/_RegisterUtil.js +25 -0
- package/components/_adapt/Alert.d.ts +11 -0
- package/components/_adapt/Alert.js +43 -0
- package/components/_adapt/Button.d.ts +20 -0
- package/components/_adapt/Button.js +26 -0
- package/components/_adapt/Col.d.ts +53 -0
- package/components/_adapt/Col.js +90 -0
- package/components/_adapt/Collapse.d.ts +30 -0
- package/components/_adapt/Collapse.js +33 -0
- package/components/_adapt/Drawer.d.ts +12 -0
- package/components/_adapt/Drawer.js +11 -0
- package/components/_adapt/Dropdown.d.ts +15 -0
- package/components/_adapt/Dropdown.js +38 -0
- package/components/_adapt/Icon.d.ts +14 -0
- package/components/_adapt/Icon.js +34 -0
- package/components/_adapt/Image.d.ts +4 -0
- package/components/_adapt/Image.js +11 -0
- package/components/_adapt/Menu.d.ts +32 -0
- package/components/_adapt/Menu.js +25 -0
- package/components/_adapt/Modal.d.ts +23 -0
- package/components/_adapt/Modal.js +69 -0
- package/components/_adapt/Popconfirm.d.ts +5 -0
- package/components/_adapt/Popconfirm.js +34 -0
- package/components/_adapt/Popover.d.ts +5 -0
- package/components/_adapt/Popover.js +34 -0
- package/components/_adapt/Progress.d.ts +14 -0
- package/components/_adapt/Progress.js +56 -0
- package/components/_adapt/Row.d.ts +10 -0
- package/components/_adapt/Row.js +23 -0
- package/components/_adapt/Select.d.ts +14 -0
- package/components/_adapt/Select.js +47 -0
- package/components/_adapt/Tag.d.ts +7 -0
- package/components/_adapt/Tag.js +12 -0
- package/components/_adapt/Tooltip.d.ts +5 -0
- package/components/_adapt/Tooltip.js +11 -0
- package/components/_adapt/todo/ColorPicker.d.ts +3 -0
- package/components/_adapt/todo/ColorPicker.js +42 -0
- package/components/_adapt/todo/FloatButton.d.ts +2 -0
- package/components/_adapt/todo/FloatButton.js +6 -0
- package/components/_adapt/todo/Image.d.ts +2 -0
- package/components/_adapt/todo/Image.js +6 -0
- package/components/_adapt/todo/Segmented.d.ts +2 -0
- package/components/_adapt/todo/Segmented.js +6 -0
- package/components/_adapt/todo/Space.d.ts +2 -0
- package/components/_adapt/todo/Space.js +6 -0
- package/components/_adapt/utils.d.ts +12 -0
- package/components/_adapt/utils.js +93 -0
- package/components/_common/AutoComplete.d.ts +32 -0
- package/components/_common/AutoComplete.js +87 -0
- package/components/_common/CountUp.d.ts +38 -0
- package/components/_common/CountUp.js +60 -0
- package/components/_common/DateRange.d.ts +52 -0
- package/components/_common/DateRange.js +108 -0
- package/components/_common/HighLight.d.ts +15 -0
- package/components/_common/HighLight.js +37 -0
- package/components/_common/I18N.d.ts +7 -0
- package/components/_common/I18N.js +6 -0
- package/components/_common/Loading.d.ts +9 -0
- package/components/_common/Loading.js +52 -0
- package/components/_common/MonthRange.d.ts +46 -0
- package/components/_common/MonthRange.js +130 -0
- package/components/_common/PromiseLabel.d.ts +11 -0
- package/components/_common/PromiseLabel.js +34 -0
- package/components/_common/Role.d.ts +5 -0
- package/components/_common/Role.js +11 -0
- package/components/_common/Upagination.d.ts +21 -0
- package/components/_common/Upagination.js +106 -0
- package/components/_setup/Const.d.ts +205 -0
- package/components/_setup/Const.js +112 -0
- package/components/_setup/I18N/enUS.d.ts +1 -0
- package/components/_setup/I18N/enUS.js +106 -0
- package/components/_setup/I18N/index.d.ts +3 -0
- package/components/_setup/I18N/index.js +5 -0
- package/components/_setup/I18N/zhCN.d.ts +3 -0
- package/components/_setup/I18N/zhCN.js +109 -0
- package/components/_setup/I18N/zhHK.d.ts +1 -0
- package/components/_setup/I18N/zhHK.js +107 -0
- package/components/_setup/ICON/IconTypes.d.ts +1 -0
- package/components/_setup/ICON/IconTypes.js +10 -0
- package/components/_setup/SearchField/SearchFieldAdvance.d.ts +1 -0
- package/components/_setup/SearchField/SearchFieldAdvance.js +57 -0
- package/components/_setup/SearchField/SearchFieldDate.d.ts +1 -0
- package/components/_setup/SearchField/SearchFieldDate.js +186 -0
- package/components/_setup/SearchField/SearchFieldInput.d.ts +3 -0
- package/components/_setup/SearchField/SearchFieldInput.js +20 -0
- package/components/_setup/SearchField/SearchFieldSelect.d.ts +1 -0
- package/components/_setup/SearchField/SearchFieldSelect.js +106 -0
- package/components/_setup/SearchField/SearchFieldTree.d.ts +1 -0
- package/components/_setup/SearchField/SearchFieldTree.js +191 -0
- package/components/_setup/SelectBar/SelectList.d.ts +1 -0
- package/components/_setup/SelectBar/SelectList.js +21 -0
- package/components/_setup/SelectBar/SelectTree.d.ts +1 -0
- package/components/_setup/SelectBar/SelectTree.js +11 -0
- package/components/_setup/UForm/UFormAdvanceInput.d.ts +1 -0
- package/components/_setup/UForm/UFormAdvanceInput.js +300 -0
- package/components/_setup/UForm/UFormAdvanceSelect.d.ts +0 -0
- package/components/_setup/UForm/UFormAdvanceSelect.js +26 -0
- package/components/_setup/UForm/UFormCrontab.d.ts +1 -0
- package/components/_setup/UForm/UFormCrontab.js +199 -0
- package/components/_setup/UForm/UFormDate.d.ts +1 -0
- package/components/_setup/UForm/UFormDate.js +313 -0
- package/components/_setup/UForm/UFormInput.d.ts +1 -0
- package/components/_setup/UForm/UFormInput.js +159 -0
- package/components/_setup/UForm/UFormJSON.d.ts +1 -0
- package/components/_setup/UForm/UFormJSON.js +219 -0
- package/components/_setup/UForm/UFormOrg.d.ts +1 -0
- package/components/_setup/UForm/UFormOrg.js +121 -0
- package/components/_setup/UForm/UFormRole.d.ts +1 -0
- package/components/_setup/UForm/UFormRole.js +47 -0
- package/components/_setup/UForm/UFormSearch.d.ts +0 -0
- package/components/_setup/UForm/UFormSearch.js +35 -0
- package/components/_setup/UForm/UFormSelect.d.ts +1 -0
- package/components/_setup/UForm/UFormSelect.js +179 -0
- package/components/_setup/UForm/UFormTree.d.ts +0 -0
- package/components/_setup/UForm/UFormTree.js +134 -0
- package/components/_setup/UForm/UFormUpload.d.ts +1 -0
- package/components/_setup/UForm/UFormUpload.js +173 -0
- package/components/_setup/UForm/_utils.d.ts +11 -0
- package/components/_setup/UForm/_utils.js +41 -0
- package/components/_setup/index.d.ts +21 -0
- package/components/_setup/index.js +25 -0
- package/components/index.d.ts +7 -0
- package/components/index.js +16 -0
- package/deps/JsonView.d.ts +6 -0
- package/deps/JsonView.js +57 -0
- package/deps/SpringBoot.d.ts +4 -0
- package/deps/SpringBoot.js +18 -0
- package/deps/SpringCloud.d.ts +14 -0
- package/deps/SpringCloud.js +29 -0
- package/deps/_editor/advance/_Audio.d.ts +0 -0
- package/deps/_editor/advance/_Audio.js +1 -0
- package/deps/_editor/advance/_Image.d.ts +2 -0
- package/deps/_editor/advance/_Image.js +89 -0
- package/deps/_editor/advance/_Table.d.ts +0 -0
- package/deps/_editor/advance/_Table.js +1 -0
- package/deps/_editor/advance/_Video.d.ts +0 -0
- package/deps/_editor/advance/_Video.js +1 -0
- package/deps/_editor/base/Element.d.ts +5 -0
- package/deps/_editor/base/Element.js +43 -0
- package/deps/_editor/base/Leaf.d.ts +3 -0
- package/deps/_editor/base/Leaf.js +36 -0
- package/deps/_editor/base/Support.d.ts +2 -0
- package/deps/_editor/base/Support.js +78 -0
- package/deps/_editor/base/types.d.ts +156 -0
- package/deps/_editor/base/types.js +10 -0
- package/deps/_editor/i18n.d.ts +1 -0
- package/deps/_editor/i18n.js +31 -0
- package/deps/_editor/tools/Button.d.ts +6 -0
- package/deps/_editor/tools/Button.js +86 -0
- package/deps/_editor/tools/ToolBar.d.ts +8 -0
- package/deps/_editor/tools/ToolBar.js +10 -0
- package/deps/_editor/tools/_BlockButton.d.ts +4 -0
- package/deps/_editor/tools/_BlockButton.js +77 -0
- package/deps/_editor/tools/_InsertButton.d.ts +6 -0
- package/deps/_editor/tools/_InsertButton.js +65 -0
- package/deps/_editor/tools/_MarkButton.d.ts +6 -0
- package/deps/_editor/tools/_MarkButton.js +45 -0
- package/deps/_editor/tools/_TxtButton.d.ts +7 -0
- package/deps/_editor/tools/_TxtButton.js +187 -0
- package/deps/_editor/utils/ParseHtml.d.ts +0 -0
- package/deps/_editor/utils/ParseHtml.js +220 -0
- package/deps/api-audit.d.ts +1 -0
- package/deps/api-audit.js +6 -0
- package/deps/api-data.d.ts +0 -0
- package/deps/api-data.js +1 -0
- package/deps/apis/useSource.d.ts +0 -0
- package/deps/apis/useSource.js +152 -0
- package/deps/echarts.d.ts +26 -0
- package/deps/echarts.js +71 -0
- package/deps/editor.d.ts +34 -0
- package/deps/editor.js +111 -0
- package/deps/registerEditor.d.ts +1 -0
- package/deps/registerEditor.js +15 -0
- package/hooks/_list.d.ts +87 -0
- package/hooks/_list.js +13 -0
- package/hooks/index.d.ts +14 -0
- package/hooks/index.js +49 -0
- package/hooks/useAjax.d.ts +14 -0
- package/hooks/useAjax.js +43 -0
- package/hooks/useAjaxAction.d.ts +13 -0
- package/hooks/useAjaxAction.js +42 -0
- package/hooks/useAjaxQuery.d.ts +40 -0
- package/hooks/useAjaxQuery.js +81 -0
- package/hooks/useApi.d.ts +69 -0
- package/hooks/useApi.js +352 -0
- package/hooks/useApiGlobal.d.ts +0 -0
- package/hooks/useApiGlobal.js +5 -0
- package/hooks/useApp.d.ts +243 -0
- package/hooks/useApp.js +17 -0
- package/hooks/useArray.d.ts +21 -0
- package/hooks/useArray.js +182 -0
- package/hooks/useCounter.d.ts +0 -0
- package/hooks/useCounter.js +82 -0
- package/hooks/useDefault.d.ts +6 -0
- package/hooks/useDefault.js +16 -0
- package/hooks/useDoLoad.d.ts +17 -0
- package/hooks/useDoLoad.js +44 -0
- package/hooks/useEffectFunction.d.ts +8 -0
- package/hooks/useEffectFunction.js +16 -0
- package/hooks/useEffectOnce.d.ts +5 -0
- package/hooks/useEffectOnce.js +23 -0
- package/hooks/useError.d.ts +5 -0
- package/hooks/useError.js +21 -0
- package/hooks/useFirstMountState.d.ts +6 -0
- package/hooks/useFirstMountState.js +18 -0
- package/hooks/useGenkey.d.ts +2 -0
- package/hooks/useGenkey.js +16 -0
- package/hooks/useGetSet.d.ts +11 -0
- package/hooks/useGetSet.js +27 -0
- package/hooks/useGlobal.d.ts +19 -0
- package/hooks/useGlobal.js +62 -0
- package/hooks/useGlobal_back.d.ts +1 -0
- package/hooks/useGlobal_back.js +11 -0
- package/hooks/useHover.d.ts +8 -0
- package/hooks/useHover.js +49 -0
- package/hooks/useMemoPromise.d.ts +6 -0
- package/hooks/useMemoPromise.js +42 -0
- package/hooks/useModals.d.ts +40 -0
- package/hooks/useModals.js +98 -0
- package/hooks/useMountedState.d.ts +5 -0
- package/hooks/useMountedState.js +20 -0
- package/hooks/useOpenState.d.ts +28 -0
- package/hooks/useOpenState.js +23 -0
- package/hooks/usePromise.d.ts +7 -0
- package/hooks/usePromise.js +22 -0
- package/hooks/useQueue.d.ts +12 -0
- package/hooks/useQueue.js +34 -0
- package/hooks/useSetState.d.ts +9 -0
- package/hooks/useSetState.js +26 -0
- package/hooks/useStateList.d.ts +13 -0
- package/hooks/useStateList.js +59 -0
- package/hooks/useToggle.d.ts +6 -0
- package/hooks/useToggle.js +12 -0
- package/hooks/useUnmountPromise.d.ts +6 -0
- package/hooks/useUnmountPromise.js +36 -0
- package/hooks/useUpdate.d.ts +7 -0
- package/hooks/useUpdate.js +15 -0
- package/hooks/useUpdateEffect.d.ts +6 -0
- package/hooks/useUpdateEffect.js +18 -0
- package/index.d.ts +139 -0
- package/index.js +161 -0
- package/login/Base65.d.ts +8 -0
- package/login/Base65.js +65 -0
- package/login/Password.d.ts +61 -0
- package/login/Password.js +124 -0
- package/login/SM4.d.ts +20 -0
- package/login/SM4.js +193 -0
- package/login/cems/index.d.ts +10 -0
- package/login/cems/index.js +17 -0
- package/login/jit/index.d.ts +32 -0
- package/login/jit/index.js +180 -0
- package/login/jit/pnxclient.d.ts +54 -0
- package/login/jit/pnxclient.js +575 -0
- package/login/sso/index.d.ts +0 -0
- package/login/sso/index.js +0 -0
- package/login/vap/index.d.ts +1 -0
- package/login/vap/index.js +6 -0
- package/login/xrtx/index.d.ts +2 -0
- package/login/xrtx/index.js +33 -0
- package/package.json +1 -0
- package/screen/Comment.d.ts +31 -0
- package/screen/Comment.js +29 -0
- package/screen/EchartContent.d.ts +0 -0
- package/screen/EchartContent.js +63 -0
- package/screen/Page.d.ts +13 -0
- package/screen/Page.js +74 -0
- package/screen/index.d.ts +3 -0
- package/screen/index.js +9 -0
- package/screen/render.d.ts +5 -0
- package/screen/render.js +10 -0
- package/utils/Ajax.d.ts +85 -0
- package/utils/Ajax.js +147 -0
- package/utils/ArrayUtil.d.ts +22 -0
- package/utils/ArrayUtil.js +51 -0
- package/utils/CacheUtil.d.ts +20 -0
- package/utils/CacheUtil.js +86 -0
- package/utils/Const.d.ts +14 -0
- package/utils/Const.js +37 -0
- package/utils/CustomApp.d.ts +242 -0
- package/utils/CustomApp.js +18 -0
- package/utils/EventUtil.d.ts +22 -0
- package/utils/EventUtil.js +63 -0
- package/utils/Format.d.ts +28 -0
- package/utils/Format.js +206 -0
- package/utils/Global.d.ts +276 -0
- package/utils/Global.js +125 -0
- package/utils/Logger.d.ts +5 -0
- package/utils/Logger.js +32 -0
- package/utils/PageUtil.d.ts +24 -0
- package/utils/PageUtil.js +87 -0
- package/utils/Renders/ApiGetRender.d.ts +23 -0
- package/utils/Renders/ApiGetRender.js +192 -0
- package/utils/Renders/ApiPostRender.d.ts +17 -0
- package/utils/Renders/ApiPostRender.js +161 -0
- package/utils/Renders/DateRender.d.ts +8 -0
- package/utils/Renders/DateRender.js +35 -0
- package/utils/Renders/DictRender.d.ts +23 -0
- package/utils/Renders/DictRender.js +258 -0
- package/utils/Renders/FileRender.d.ts +3 -0
- package/utils/Renders/FileRender.js +46 -0
- package/utils/Renders/ListRender.d.ts +23 -0
- package/utils/Renders/ListRender.js +111 -0
- package/utils/Renders/NumberRender.d.ts +19 -0
- package/utils/Renders/NumberRender.js +65 -0
- package/utils/Renders/StatusRender.d.ts +12 -0
- package/utils/Renders/StatusRender.js +68 -0
- package/utils/Renders/StringRender.d.ts +14 -0
- package/utils/Renders/StringRender.js +194 -0
- package/utils/Renders/_define.d.ts +26 -0
- package/utils/Renders/_define.js +64 -0
- package/utils/Renders/index.d.ts +9 -0
- package/utils/Renders/index.js +42 -0
- package/utils/StringUtil.d.ts +124 -0
- package/utils/StringUtil.js +352 -0
- package/utils/TreeUtil.d.ts +42 -0
- package/utils/TreeUtil.js +69 -0
- package/utils/VAP.d.ts +16 -0
- package/utils/VAP.js +78 -0
- package/utils/XHR.d.ts +9 -0
- package/utils/XHR.js +53 -0
- package/utils/_AjaxUtil.d.ts +11 -0
- package/utils/_AjaxUtil.js +45 -0
- package/utils/_Support.d.ts +22 -0
- package/utils/_Support.js +106 -0
- package/utils/i18n.d.ts +60 -0
- package/utils/i18n.js +184 -0
- package/utils/index.d.ts +19 -0
- package/utils/index.js +54 -0
- package/utils/screenful.d.ts +15 -0
- package/utils/screenful.js +64 -0
- package/widget/index.d.ts +39 -0
- package/widget/index.js +21 -0
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { PlainObject } from '../basetype';
|
|
3
|
+
import type { Language } from '../utils/_Support';
|
|
4
|
+
import type { ApiGetRender } from '../utils/Renders/ApiGetRender';
|
|
5
|
+
import type { ApiPostRender } from '../utils/Renders/ApiPostRender';
|
|
6
|
+
import type { Render } from '../utils/Renders/_define';
|
|
7
|
+
/**
|
|
8
|
+
* 系统皮肤信息
|
|
9
|
+
*/
|
|
10
|
+
export interface GlobalTheme {
|
|
11
|
+
/**
|
|
12
|
+
* 皮肤代码
|
|
13
|
+
*/
|
|
14
|
+
theme: string;
|
|
15
|
+
/**
|
|
16
|
+
* Logo 图片
|
|
17
|
+
*/
|
|
18
|
+
logo: string;
|
|
19
|
+
/**
|
|
20
|
+
* 当前语言
|
|
21
|
+
*/
|
|
22
|
+
lang: Language;
|
|
23
|
+
/**
|
|
24
|
+
* 是否暗色模式
|
|
25
|
+
*/
|
|
26
|
+
darkMode: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* 是隐藏导航,在URL 里面加入参数则隐藏,隐藏后只显示内容区
|
|
29
|
+
* ?__HIDE=true
|
|
30
|
+
*/
|
|
31
|
+
isHide: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* 当前皮肤是否处于 insight 系列皮肤 ,用于一些交互性差异
|
|
34
|
+
* insight 系列皮肤与普通皮肤有一些差异,一般情况下不要用这个属性,高度问题后续提供方案
|
|
35
|
+
*/
|
|
36
|
+
isInsight: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* 是否为打印模式,在URL 里面加入参数则为打印模式,打印模式页面可与正常页面有所不同
|
|
39
|
+
* ?__PRINT=true
|
|
40
|
+
*/
|
|
41
|
+
isPrint: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* 内容区域宽度
|
|
44
|
+
*/
|
|
45
|
+
contentWidth: number;
|
|
46
|
+
/**
|
|
47
|
+
* 内容区域高度
|
|
48
|
+
*/
|
|
49
|
+
contentHeight: number;
|
|
50
|
+
/**
|
|
51
|
+
* 是否在全屏状态
|
|
52
|
+
* */
|
|
53
|
+
isFullScreen: boolean;
|
|
54
|
+
}
|
|
55
|
+
export type MenuCrumb = {
|
|
56
|
+
id: string;
|
|
57
|
+
name: string;
|
|
58
|
+
icon?: string;
|
|
59
|
+
path?: string;
|
|
60
|
+
sign?: string;
|
|
61
|
+
};
|
|
62
|
+
export type OpenOptions = {
|
|
63
|
+
/**
|
|
64
|
+
* 打开方式
|
|
65
|
+
* auto :自动
|
|
66
|
+
* blank: 新标签页
|
|
67
|
+
* self: 本页面
|
|
68
|
+
* top: 顶层页
|
|
69
|
+
*/
|
|
70
|
+
target?: 'auto' | 'blank' | 'self' | 'top';
|
|
71
|
+
/**
|
|
72
|
+
* 是否进行资源检测,默认为 false,
|
|
73
|
+
* 如果需要打开还未载入且需要传HASH参数的模块时,可以设为true,否则可能无法找到URL
|
|
74
|
+
*/
|
|
75
|
+
notCheck?: true;
|
|
76
|
+
/**
|
|
77
|
+
* 向下一个页面传 Status 类型参数
|
|
78
|
+
* 说明 Status 类型参数不会体现在 url 里面,仅支持从 props 里面取出
|
|
79
|
+
*/
|
|
80
|
+
status?: any;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* 系统菜单信息
|
|
84
|
+
*/
|
|
85
|
+
export interface GlobalMenu {
|
|
86
|
+
/**
|
|
87
|
+
* 全部系统菜单
|
|
88
|
+
*/
|
|
89
|
+
menus: PlainObject[];
|
|
90
|
+
/**
|
|
91
|
+
* 当前菜单
|
|
92
|
+
*/
|
|
93
|
+
current: PlainObject;
|
|
94
|
+
/**
|
|
95
|
+
* 当前面包屑导航
|
|
96
|
+
*/
|
|
97
|
+
crumbs: MenuCrumb[];
|
|
98
|
+
/**
|
|
99
|
+
* 方法 - 菜单跳转
|
|
100
|
+
* @param menu 参数支持
|
|
101
|
+
* 1. 一个路径:如 /admin/#/user
|
|
102
|
+
* 2. 一个菜单: 如 { root:'/admin', route:'/user' }
|
|
103
|
+
* 3. 一个地址: 如 https://www.qq.com ,(弹出新的TAB面面)
|
|
104
|
+
* 4. 菜单ID : 如 "1" , 将会通过 id 获取具体菜单(打开特殊 sign 菜单用此项)
|
|
105
|
+
*
|
|
106
|
+
* @param
|
|
107
|
+
*
|
|
108
|
+
*/
|
|
109
|
+
toMenu: (menu: any, options?: OpenOptions) => void;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* 系统用户
|
|
113
|
+
*/
|
|
114
|
+
export interface GlobalUser {
|
|
115
|
+
/**
|
|
116
|
+
* 用户信息
|
|
117
|
+
*/
|
|
118
|
+
info: Record<string, any>;
|
|
119
|
+
/**
|
|
120
|
+
* 获取用户自定义kv配置
|
|
121
|
+
*
|
|
122
|
+
* getConfig(module) : 返回 modlue 下所有 kv配置
|
|
123
|
+
* getConfig(module,key) : 返回 modlue 下指定 key 配置,如果modlue没有加载的情况下,会载入module下的所有 key
|
|
124
|
+
* getConfig(module,key,true) : 返回 modlue 下指定 key 配置,如果modlue没有加载的情况下,会载入module下指定的 key
|
|
125
|
+
*/
|
|
126
|
+
/**
|
|
127
|
+
* 获取用户自定义kv配置
|
|
128
|
+
* 指定 模块 : 返回一个Map
|
|
129
|
+
*/
|
|
130
|
+
getConfig(module: string): Promise<Map<string, string>>;
|
|
131
|
+
/**
|
|
132
|
+
* 获取用户自定义kv配置
|
|
133
|
+
* 指定 模块 和 key : 返回一个字串
|
|
134
|
+
*/
|
|
135
|
+
getConfig(module: string, key: string): Promise<string>;
|
|
136
|
+
/**
|
|
137
|
+
* 获取用户自定义kv配置
|
|
138
|
+
* 指定 模块 和 key , fetch = true: 返回一个字串,强制获取
|
|
139
|
+
*/
|
|
140
|
+
getConfig(module: string, key: string, fetch: boolean): Promise<string>;
|
|
141
|
+
/**
|
|
142
|
+
* 设置用户自定义属性
|
|
143
|
+
*/
|
|
144
|
+
setConfig: (module: string, key: string, value: string, needUpdate?: boolean) => Promise<boolean>;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* 系统内置 render
|
|
148
|
+
*/
|
|
149
|
+
export interface GlobalRender {
|
|
150
|
+
/**
|
|
151
|
+
* 角色 ID => 角色名称,支持多个ID,以逗号分隔
|
|
152
|
+
*/
|
|
153
|
+
roleRender: ApiGetRender;
|
|
154
|
+
/**
|
|
155
|
+
* 机构 CODE => 机构名称
|
|
156
|
+
*/
|
|
157
|
+
orgRender: ApiPostRender;
|
|
158
|
+
/**
|
|
159
|
+
* 通用I P Render,用于统一跳转
|
|
160
|
+
* 通过 IP 地址生成一个链接
|
|
161
|
+
*/
|
|
162
|
+
ipRender: (ip: string) => React.ReactNode;
|
|
163
|
+
/**
|
|
164
|
+
* 通用 idCard Render,用于统一跳转
|
|
165
|
+
* 通过 身份证号生成一一个目标链接
|
|
166
|
+
*/
|
|
167
|
+
idRender: (idCard: string) => React.ReactNode;
|
|
168
|
+
/**
|
|
169
|
+
* 通用 应用系统 Render,用于统一跳转
|
|
170
|
+
* 通过 系统ID生成一个链接
|
|
171
|
+
*/
|
|
172
|
+
sysRender: ApiPostRender;
|
|
173
|
+
/**
|
|
174
|
+
* 常用字符串长度截取的Render
|
|
175
|
+
*/
|
|
176
|
+
str12Render: Render;
|
|
177
|
+
str16Render: Render;
|
|
178
|
+
str20Render: Render;
|
|
179
|
+
str24Render: Render;
|
|
180
|
+
str36Render: Render;
|
|
181
|
+
str48Render: Render;
|
|
182
|
+
str60Render: Render;
|
|
183
|
+
}
|
|
184
|
+
type ApiTask = {
|
|
185
|
+
api: string;
|
|
186
|
+
param?: PlainObject;
|
|
187
|
+
downApi?: (workId: string, data?: PlainObject) => string;
|
|
188
|
+
};
|
|
189
|
+
type FileTask = {
|
|
190
|
+
url: string;
|
|
191
|
+
fileName: string;
|
|
192
|
+
fileSize?: number;
|
|
193
|
+
delay?: number;
|
|
194
|
+
};
|
|
195
|
+
/**
|
|
196
|
+
* 系统通用下载
|
|
197
|
+
*/
|
|
198
|
+
export interface GlobalDownload {
|
|
199
|
+
/**
|
|
200
|
+
* 直接下载 说明:
|
|
201
|
+
* 1. 避免各和应用自己弄自己的下载,提供统一的下载方法,不会弹新窗口
|
|
202
|
+
* 2. url为下载地址 ,默认下载方法为 GET
|
|
203
|
+
* 3. 如果下载方法为 POST 需要传第二个参数,使用FormData 方式随请求一起发送
|
|
204
|
+
*/
|
|
205
|
+
download: (url: string, postParam?: PlainObject) => void;
|
|
206
|
+
/**
|
|
207
|
+
* 方法 - 添加下载任务到下载队列 ,有动态进度,需要满足下载规范
|
|
208
|
+
*/
|
|
209
|
+
addTask: (taskInfo: ApiTask) => void;
|
|
210
|
+
/**
|
|
211
|
+
* 方法 - 添加下载链接到下载队列 ,默认直接完成
|
|
212
|
+
* 通过 delay 可以设置假进度,(常用于延时下载)单位为毫秒,但不一定会准确,例如 delay:5000 可能 会在 4 - 6 秒之间完成
|
|
213
|
+
*/
|
|
214
|
+
addFileTask: (taskInfo: FileTask) => void;
|
|
215
|
+
}
|
|
216
|
+
export interface App {
|
|
217
|
+
/**
|
|
218
|
+
* 全局-皮肤信息
|
|
219
|
+
*/
|
|
220
|
+
theme: GlobalTheme;
|
|
221
|
+
/**
|
|
222
|
+
* 全局-菜单信息
|
|
223
|
+
*/
|
|
224
|
+
menu: GlobalMenu;
|
|
225
|
+
/**
|
|
226
|
+
* 全局-用户信息,用户扩展配置设定方法
|
|
227
|
+
*/
|
|
228
|
+
user: GlobalUser;
|
|
229
|
+
/**
|
|
230
|
+
* 全局-通用 Render
|
|
231
|
+
*/
|
|
232
|
+
render: GlobalRender;
|
|
233
|
+
/**
|
|
234
|
+
* 全局-下载
|
|
235
|
+
*/
|
|
236
|
+
download: GlobalDownload;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* 返回系统内全局信息
|
|
240
|
+
* 包括皮肤、菜单、用户、等
|
|
241
|
+
*/
|
|
242
|
+
export declare const useApp: (() => App);
|
|
243
|
+
export {};
|
package/hooks/useApp.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useApp = void 0;
|
|
4
|
+
const _Support_1 = require("../utils/_Support");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
;
|
|
7
|
+
;
|
|
8
|
+
;
|
|
9
|
+
;
|
|
10
|
+
;
|
|
11
|
+
const _V_APPACTION = (0, _Support_1.globalDefault)('_V_APPACTION', (0, react_1.createContext)(null));
|
|
12
|
+
/**
|
|
13
|
+
* 返回系统内全局信息
|
|
14
|
+
* 包括皮肤、菜单、用户、等
|
|
15
|
+
*/
|
|
16
|
+
const useApp = () => (0, react_1.useContext)(_V_APPACTION);
|
|
17
|
+
exports.useApp = useApp;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { StaticListState, ListInit } from './_list';
|
|
2
|
+
type ArrayOption = ListInit & {
|
|
3
|
+
/**
|
|
4
|
+
* 页面大小,默认为 VLIST 大小
|
|
5
|
+
* 默认为 0 :为0时,不分页,非0时分页
|
|
6
|
+
* 说明:如果设置分页,为前端算法处理的假分页,不需要请求后台
|
|
7
|
+
* */
|
|
8
|
+
pageSize?: number;
|
|
9
|
+
/**
|
|
10
|
+
* 说明:
|
|
11
|
+
* 使用 api 模式时,会自动请求
|
|
12
|
+
* 如果不想输入时就请求,需要传 autoLoad = false
|
|
13
|
+
*/
|
|
14
|
+
autoLoad?: boolean;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* 静态数组 Table,支持 CRUD(不调接口)
|
|
18
|
+
* 同样适用于 VTable 等组件
|
|
19
|
+
*/
|
|
20
|
+
export declare const useArray: (options: ArrayOption) => StaticListState;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.useArray = void 0;
|
|
16
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
17
|
+
const react_1 = require("react");
|
|
18
|
+
const antd_1 = require("antd");
|
|
19
|
+
const utils_1 = require("../utils");
|
|
20
|
+
const _list_1 = require("./_list");
|
|
21
|
+
const useSetState_1 = require("./useSetState");
|
|
22
|
+
const useEffectFunction_1 = require("./useEffectFunction");
|
|
23
|
+
const getList = (result) => {
|
|
24
|
+
if (lodash_1.default.has(result, 'code')) {
|
|
25
|
+
if (result.code != '0') {
|
|
26
|
+
if (result.message) {
|
|
27
|
+
antd_1.message.error(result.message);
|
|
28
|
+
}
|
|
29
|
+
return [];
|
|
30
|
+
}
|
|
31
|
+
if (lodash_1.default.has(result, 'list')) {
|
|
32
|
+
return result.list;
|
|
33
|
+
}
|
|
34
|
+
if (lodash_1.default.has(result, 'data') && lodash_1.default.isArray(result.data)) {
|
|
35
|
+
return result.data;
|
|
36
|
+
}
|
|
37
|
+
return [];
|
|
38
|
+
}
|
|
39
|
+
if (lodash_1.default.isArray(result)) {
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
return [];
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* 静态数组 Table,支持 CRUD(不调接口)
|
|
46
|
+
* 同样适用于 VTable 等组件
|
|
47
|
+
*/
|
|
48
|
+
const useArray = (options) => {
|
|
49
|
+
const AllRef = (0, react_1.useRef)(null);
|
|
50
|
+
const BASE = Object.assign(Object.assign({}, _list_1.DEFAULT_STATE), { pageSize: 0 });
|
|
51
|
+
if (options.rowKey)
|
|
52
|
+
BASE.rowKey = options.rowKey;
|
|
53
|
+
let lastQueryRef = (0, react_1.useRef)(options.param || {});
|
|
54
|
+
let pageToRef = (0, react_1.useRef)(null);
|
|
55
|
+
let orderByRef = (0, react_1.useRef)(null);
|
|
56
|
+
if (options.pageSize && options.pageSize > 0)
|
|
57
|
+
BASE.pageSize = options.pageSize;
|
|
58
|
+
const [state, setState] = (0, useSetState_1.useSetState)(BASE);
|
|
59
|
+
const queryRef = () => {
|
|
60
|
+
const param = lastQueryRef.current;
|
|
61
|
+
const pageTo = pageToRef.current;
|
|
62
|
+
const orderBy = orderByRef.current;
|
|
63
|
+
let list = AllRef.current.slice(0);
|
|
64
|
+
lodash_1.default.keys(param).map(field => {
|
|
65
|
+
if (lodash_1.default.endsWith('_'))
|
|
66
|
+
return;
|
|
67
|
+
const keyword = lodash_1.default.toLower(param[field] + '');
|
|
68
|
+
list = list.filter(item => {
|
|
69
|
+
if (lodash_1.default.has(item, field)) {
|
|
70
|
+
return lodash_1.default.toLower(item[field] + '').indexOf(keyword) >= 0;
|
|
71
|
+
}
|
|
72
|
+
return true;
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
if (orderBy != null) {
|
|
76
|
+
list = lodash_1.default.orderBy(list, orderBy.order, orderBy.by);
|
|
77
|
+
}
|
|
78
|
+
if (pageTo == null) {
|
|
79
|
+
setState({ isQuerying: false, list, total: list.length, totalAcc: list.length, param, pageNo: 1, });
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
let start = pageTo.pageSize * (pageTo.pageNo - 1);
|
|
83
|
+
let count = pageTo.pageSize;
|
|
84
|
+
setState({ isQuerying: false, list: list.slice(start, count), total: list.length, totalAcc: list.length, param, pageNo: 1, });
|
|
85
|
+
};
|
|
86
|
+
const queryApi = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
87
|
+
const param = lastQueryRef.current;
|
|
88
|
+
setState({ isQuerying: true });
|
|
89
|
+
const resp = yield utils_1.Ajax.POST(options.api, param);
|
|
90
|
+
const list = getList(resp);
|
|
91
|
+
AllRef.current = list;
|
|
92
|
+
const pageTo = pageToRef.current;
|
|
93
|
+
if (pageTo == null) {
|
|
94
|
+
setState({ isQuerying: false, list, total: list.length, totalAcc: list.length, param, pageNo: 1, });
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
let start = pageTo.pageSize * (pageTo.pageNo - 1);
|
|
98
|
+
let count = pageTo.pageSize;
|
|
99
|
+
setState({ isQuerying: false, list: list.slice(start, count), total: list.length, totalAcc: list.length, param, pageNo: 1, });
|
|
100
|
+
});
|
|
101
|
+
const query = (param, clean) => {
|
|
102
|
+
if (clean) {
|
|
103
|
+
lastQueryRef.current = param || {};
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
lastQueryRef.current = lodash_1.default.merge(lastQueryRef.current, param);
|
|
107
|
+
}
|
|
108
|
+
if (lodash_1.default.has(param, 'order_') && lodash_1.default.has(param, 'by_')) {
|
|
109
|
+
orderByRef.current = { order: param.order_, by: param.by_ };
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
orderByRef.current = null;
|
|
113
|
+
}
|
|
114
|
+
if (options.pageSize && options.pageSize > 0) {
|
|
115
|
+
pageToRef.current = { pageNo: 1, pageSize: options.pageSize };
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
pageToRef.current = null;
|
|
119
|
+
}
|
|
120
|
+
if (options.api) {
|
|
121
|
+
queryApi();
|
|
122
|
+
}
|
|
123
|
+
else if (AllRef.current != null && lodash_1.default.isArray(AllRef.current)) {
|
|
124
|
+
queryRef();
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
console.error('list 与 api 到少需要指定一项');
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
(0, useEffectFunction_1.useEffectFunction)(() => {
|
|
131
|
+
if (lodash_1.default.isArray(options.list))
|
|
132
|
+
AllRef.current = options.list;
|
|
133
|
+
if (options.autoLoad !== false)
|
|
134
|
+
query(options.param || {}, true);
|
|
135
|
+
});
|
|
136
|
+
const pageTo = (pageNo, pageSize) => {
|
|
137
|
+
if (options.pageSize && options.pageSize > 0) {
|
|
138
|
+
// pageToRef.current = { pageNo: 1, pageSize: options.pageSize }
|
|
139
|
+
console.error('静态Array默认不翻页,如果需要翻页,需要指定pageSize');
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
pageToRef.current = { pageNo, pageSize };
|
|
143
|
+
if (AllRef.current != null && lodash_1.default.isArray(AllRef.current)) {
|
|
144
|
+
queryRef();
|
|
145
|
+
}
|
|
146
|
+
else if (options.api) {
|
|
147
|
+
queryApi();
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
console.error('list 与 api 到少需要指定一项');
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
const orderBy = (order, by) => {
|
|
154
|
+
if (order == null || by == null) {
|
|
155
|
+
orderByRef.current = null;
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
orderByRef.current = { order, by };
|
|
159
|
+
}
|
|
160
|
+
if (AllRef.current != null && lodash_1.default.isArray(AllRef.current)) {
|
|
161
|
+
queryRef();
|
|
162
|
+
}
|
|
163
|
+
else if (options.api) {
|
|
164
|
+
queryApi();
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
console.error('list 与 api 到少需要指定一项');
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
const setList = (list) => {
|
|
171
|
+
AllRef.current = list.slice();
|
|
172
|
+
if (options.pageSize && options.pageSize > 0) {
|
|
173
|
+
pageToRef.current = { pageNo: 1, pageSize: options.pageSize };
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
pageToRef.current = null;
|
|
177
|
+
}
|
|
178
|
+
queryRef();
|
|
179
|
+
};
|
|
180
|
+
return Object.assign(Object.assign({}, state), { mode: 'static', query, pageTo, orderBy, setList });
|
|
181
|
+
};
|
|
182
|
+
exports.useArray = useArray;
|
|
File without changes
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// import { useMemo } from 'react';
|
|
2
|
+
// import { useGetSet } from './useGetSet';
|
|
3
|
+
// import { IHookStateInitAction, IHookStateSetAction, resolveHookState } from './_hookState';
|
|
4
|
+
// interface CounterActions {
|
|
5
|
+
// inc: (delta?: number) => void;
|
|
6
|
+
// dec: (delta?: number) => void;
|
|
7
|
+
// get: () => number;
|
|
8
|
+
// set: (value: IHookStateSetAction<number>) => void;
|
|
9
|
+
// reset: (value?: IHookStateSetAction<number>) => void;
|
|
10
|
+
// }
|
|
11
|
+
// type UseCounter = (initialValue?: IHookStateInitAction<number>, max?: number, min?: number) => [number, CounterActions];
|
|
12
|
+
// /**
|
|
13
|
+
// * 使用方法参考
|
|
14
|
+
// * https://github.com/streamich/react-use/blob/master/docs/useCounter.md
|
|
15
|
+
// */
|
|
16
|
+
// export const useCounter: UseCounter = (initialValue: IHookStateInitAction<number> = 0, max: number | null = null, min: number | null = null) => {
|
|
17
|
+
// let init = resolveHookState(initialValue);
|
|
18
|
+
// typeof init !== 'number' &&
|
|
19
|
+
// console.error('initialValue has to be a number, got ' + typeof initialValue);
|
|
20
|
+
// if (typeof min === 'number') {
|
|
21
|
+
// init = Math.max(init, min);
|
|
22
|
+
// } else if (min !== null) {
|
|
23
|
+
// console.error('min has to be a number, got ' + typeof min);
|
|
24
|
+
// }
|
|
25
|
+
// if (typeof max === 'number') {
|
|
26
|
+
// init = Math.min(init, max);
|
|
27
|
+
// } else if (max !== null) {
|
|
28
|
+
// console.error('max has to be a number, got ' + typeof max);
|
|
29
|
+
// }
|
|
30
|
+
// const [get, setInternal] = useGetSet(init);
|
|
31
|
+
// return [
|
|
32
|
+
// get(),
|
|
33
|
+
// useMemo(() => {
|
|
34
|
+
// const set = (newState: IHookStateSetAction<number>) => {
|
|
35
|
+
// const prevState = get();
|
|
36
|
+
// let rState = resolveHookState(newState, prevState);
|
|
37
|
+
// if (prevState !== rState) {
|
|
38
|
+
// if (typeof min === 'number') {
|
|
39
|
+
// rState = Math.max(rState, min);
|
|
40
|
+
// }
|
|
41
|
+
// if (typeof max === 'number') {
|
|
42
|
+
// rState = Math.min(rState, max);
|
|
43
|
+
// }
|
|
44
|
+
// prevState !== rState && setInternal(rState);
|
|
45
|
+
// }
|
|
46
|
+
// };
|
|
47
|
+
// return {
|
|
48
|
+
// get,
|
|
49
|
+
// set,
|
|
50
|
+
// inc: (delta: IHookStateSetAction<number> = 1) => {
|
|
51
|
+
// const rDelta = resolveHookState(delta, get());
|
|
52
|
+
// if (typeof rDelta !== 'number') {
|
|
53
|
+
// console.error(
|
|
54
|
+
// 'delta has to be a number or function returning a number, got ' + typeof rDelta
|
|
55
|
+
// );
|
|
56
|
+
// }
|
|
57
|
+
// set((num: number) => num + rDelta);
|
|
58
|
+
// },
|
|
59
|
+
// dec: (delta: IHookStateSetAction<number> = 1) => {
|
|
60
|
+
// const rDelta = resolveHookState(delta, get());
|
|
61
|
+
// if (typeof rDelta !== 'number') {
|
|
62
|
+
// console.error(
|
|
63
|
+
// 'delta has to be a number or function returning a number, got ' + typeof rDelta
|
|
64
|
+
// );
|
|
65
|
+
// }
|
|
66
|
+
// set((num: number) => num - rDelta);
|
|
67
|
+
// },
|
|
68
|
+
// reset: (value: IHookStateSetAction<number> = init) => {
|
|
69
|
+
// const rValue = resolveHookState(value, get());
|
|
70
|
+
// if (typeof rValue !== 'number') {
|
|
71
|
+
// console.error(
|
|
72
|
+
// 'value has to be a number or function returning a number, got ' + typeof rValue
|
|
73
|
+
// );
|
|
74
|
+
// }
|
|
75
|
+
// // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
76
|
+
// init = rValue;
|
|
77
|
+
// set(rValue);
|
|
78
|
+
// },
|
|
79
|
+
// };
|
|
80
|
+
// }, [init, min, max]),
|
|
81
|
+
// ];
|
|
82
|
+
// }
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
/**
|
|
3
|
+
* 使用方法参考
|
|
4
|
+
* https://github.com/streamich/react-use/blob/master/docs/useDefault.md
|
|
5
|
+
*/
|
|
6
|
+
export declare const useDefault: <TStateType>(defaultValue: TStateType, initialValue: TStateType | (() => TStateType)) => readonly [TStateType, import("react").Dispatch<import("react").SetStateAction<TStateType>>];
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useDefault = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
/**
|
|
6
|
+
* 使用方法参考
|
|
7
|
+
* https://github.com/streamich/react-use/blob/master/docs/useDefault.md
|
|
8
|
+
*/
|
|
9
|
+
const useDefault = (defaultValue, initialValue) => {
|
|
10
|
+
const [value, setValue] = (0, react_1.useState)(initialValue);
|
|
11
|
+
if (value === undefined || value === null) {
|
|
12
|
+
return [defaultValue, setValue];
|
|
13
|
+
}
|
|
14
|
+
return [value, setValue];
|
|
15
|
+
};
|
|
16
|
+
exports.useDefault = useDefault;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 说明: doLoad 是一个更高阶的 doSetState, 支持异步方法,说明:可能会有BUG (尤其是在方法速度慢的时候)
|
|
3
|
+
*
|
|
4
|
+
* const [state,doLoad] = useDoLoad({a:1,b:2,c:3});
|
|
5
|
+
*
|
|
6
|
+
* doLoad({b:5})
|
|
7
|
+
*
|
|
8
|
+
* doLoad((prevState)=>return {
|
|
9
|
+
* c:prevState + 1
|
|
10
|
+
* })
|
|
11
|
+
*
|
|
12
|
+
* doLoad(async (prevState) =>{
|
|
13
|
+
* const resp = await Ajax.GET('API')
|
|
14
|
+
* return { c:resp.xxx }
|
|
15
|
+
* })
|
|
16
|
+
*/
|
|
17
|
+
export declare const useDoLoad: <T extends object>(initValue: T) => [T, (patch: Partial<T> | ((prevState: T) => Partial<T>) | ((prevState: T) => Promise<Partial<T>>)) => void];
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useDoLoad = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const useSetState_1 = require("./useSetState");
|
|
6
|
+
/**
|
|
7
|
+
* 说明: doLoad 是一个更高阶的 doSetState, 支持异步方法,说明:可能会有BUG (尤其是在方法速度慢的时候)
|
|
8
|
+
*
|
|
9
|
+
* const [state,doLoad] = useDoLoad({a:1,b:2,c:3});
|
|
10
|
+
*
|
|
11
|
+
* doLoad({b:5})
|
|
12
|
+
*
|
|
13
|
+
* doLoad((prevState)=>return {
|
|
14
|
+
* c:prevState + 1
|
|
15
|
+
* })
|
|
16
|
+
*
|
|
17
|
+
* doLoad(async (prevState) =>{
|
|
18
|
+
* const resp = await Ajax.GET('API')
|
|
19
|
+
* return { c:resp.xxx }
|
|
20
|
+
* })
|
|
21
|
+
*/
|
|
22
|
+
const useDoLoad = (initValue) => {
|
|
23
|
+
const [state, setState] = (0, useSetState_1.useSetState)(initValue);
|
|
24
|
+
const ref = (0, react_1.useRef)(state);
|
|
25
|
+
(0, react_1.useEffect)(() => {
|
|
26
|
+
ref.current = state;
|
|
27
|
+
}, [state]);
|
|
28
|
+
const doLoader = (patch) => {
|
|
29
|
+
if (patch instanceof Function) {
|
|
30
|
+
let result = patch(ref.current);
|
|
31
|
+
if (result instanceof Promise) {
|
|
32
|
+
result.then((resp) => setState(resp));
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
setState(result);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
setState(patch);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
return [state, doLoader];
|
|
43
|
+
};
|
|
44
|
+
exports.useDoLoad = useDoLoad;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useEffectFunction = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
/**
|
|
6
|
+
* 简写 useEffect 用于方法执行,
|
|
7
|
+
* 支持异步方法
|
|
8
|
+
* 不支持 Return (unmount),
|
|
9
|
+
* 默认没有 deps
|
|
10
|
+
*/
|
|
11
|
+
const useEffectFunction = (fn, deps = []) => {
|
|
12
|
+
(0, react_1.useEffect)(() => {
|
|
13
|
+
fn();
|
|
14
|
+
}, deps);
|
|
15
|
+
};
|
|
16
|
+
exports.useEffectFunction = useEffectFunction;
|