@gct-paas/core 0.1.4-dev.8 → 0.1.5-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.min.js +1 -0
- package/es/constants/core.mjs +5 -4
- package/es/constants/default-date-type/default-date-type.d.ts +70 -0
- package/es/constants/default-date-type/default-date-type.mjs +74 -0
- package/es/constants/editor-register/editor-register.mjs +17 -5
- package/es/constants/expression-type/BuiltOperators.d.ts +20 -0
- package/es/constants/expression-type/BuiltOperators.mjs +156 -0
- package/es/constants/expression-type/FunctionKeys.d.ts +1 -0
- package/es/constants/expression-type/FunctionKeys.mjs +77 -0
- package/es/constants/expression-type/editor.d.ts +8 -0
- package/es/constants/expression-type/editor.mjs +11 -0
- package/es/constants/expression-type/function.d.ts +7 -0
- package/es/constants/expression-type/function.mjs +864 -0
- package/es/constants/expression-type/index.d.ts +42 -0
- package/es/constants/expression-type/index.mjs +118 -0
- package/es/constants/expression-type/modeCfg.d.ts +30 -0
- package/es/constants/expression-type/modeCfg.mjs +261 -0
- package/es/constants/expression-type/variable.d.ts +12 -0
- package/es/constants/expression-type/variable.mjs +46 -0
- package/es/constants/form-container-type/form-container-type.mjs +17 -5
- package/es/constants/index.d.ts +8 -1
- package/es/constants/index.mjs +32 -5
- package/es/constants/page-designer/model.d.ts +4 -0
- package/es/constants/page-designer/model.mjs +17 -0
- package/es/constants/page-designer/regex.d.ts +2 -0
- package/es/constants/page-designer/regex.mjs +5 -0
- package/es/create-app-vue.mjs +15 -16
- package/es/enums/app-designer/index.d.ts +19 -0
- package/es/enums/app-designer/index.mjs +131 -63
- package/es/enums/appEnum.d.ts +5 -0
- package/es/enums/appEnum.mjs +682 -356
- package/es/enums/appStateEnum.mjs +17 -10
- package/es/enums/authActionEnum.mjs +63 -51
- package/es/enums/breakpointEnum.mjs +27 -26
- package/es/enums/cacheEnum.d.ts +0 -1
- package/es/enums/cacheEnum.mjs +22 -22
- package/es/enums/designEnum.d.ts +9 -3
- package/es/enums/designEnum.mjs +111 -69
- package/es/enums/developer-center/index.d.ts +1 -0
- package/es/enums/developer-center/integration.d.ts +4 -0
- package/es/enums/developer-center/integration.mjs +8 -0
- package/es/enums/exceptionEnum.mjs +21 -17
- package/es/enums/expressionEnum.d.ts +130 -0
- package/es/enums/expressionEnum.mjs +82 -0
- package/es/enums/globalEnum.d.ts +15 -0
- package/es/enums/globalEnum.mjs +60 -25
- package/es/enums/httpEnum.mjs +71 -61
- package/es/enums/index.d.ts +11 -5
- package/es/enums/index.mjs +45 -17
- package/es/enums/menuEnum.mjs +42 -38
- package/es/enums/page-designer/designer.d.ts +7 -8
- package/es/enums/page-designer/designer.mjs +404 -403
- package/es/enums/page-designer/index.d.ts +1 -0
- package/es/enums/page-designer/index.mjs +5 -0
- package/es/enums/page-designer/layout.d.ts +12 -0
- package/es/enums/page-designer/layout.mjs +17 -0
- package/es/enums/page-designer/panel.d.ts +78 -7
- package/es/enums/page-designer/panel.mjs +342 -195
- package/es/enums/page-designer/toolkit.mjs +13 -12
- package/es/enums/page-designer/widget.d.ts +5 -0
- package/es/enums/page-designer/widget.mjs +426 -334
- package/es/enums/pageEnum.mjs +14 -13
- package/es/enums/plugin-enum.d.ts +8 -4
- package/es/enums/plugin-enum.mjs +27 -7
- package/es/enums/processEnum.d.ts +54 -0
- package/es/enums/processEnum.mjs +96 -26
- package/es/enums/roleEnum.mjs +7 -6
- package/es/enums/sizeEnum.d.ts +18 -0
- package/es/enums/sizeEnum.mjs +28 -8
- package/es/global/gct/gct.d.ts +245 -13
- package/es/global/gct/gct.mjs +98 -95
- package/es/global/index.mjs +1 -0
- package/es/hooks/index.d.ts +0 -3
- package/es/hooks/index.mjs +4 -0
- package/es/hooks/use-app-inst/use-app-inst.mjs +11 -5
- package/es/hooks/use-modal/use-modal.mjs +16 -10
- package/es/hooks/use-sub-app-utils/use-sub-app-utils.d.ts +8 -12
- package/es/hooks/use-sub-app-utils/use-sub-app-utils.mjs +45 -25
- package/es/hooks/useCopyToClipboard.mjs +50 -50
- package/es/index.d.ts +2 -10
- package/es/index.mjs +130 -119
- package/es/interface/i-dictionary/i-dictionary-item.d.ts +6 -0
- package/es/interface/i-global-register/i-global-register.d.ts +8 -0
- package/es/interface/i-kit-info/i-kit-info.d.ts +20 -0
- package/es/interface/i-pinia-action/i-global-actions.d.ts +4 -6
- package/es/interface/i-pinia-getter/i-global-getters.d.ts +2 -0
- package/es/interface/i-pinia-state/i-global-state.d.ts +12 -12
- package/es/interface/index.d.ts +5 -10
- package/es/interface/model-designer/entity.d.ts +110 -0
- package/es/interface/open-util/i-message-util/i-message-util.d.ts +54 -0
- package/es/interface/{i-modal → open-util/i-modal}/i-modal.d.ts +9 -10
- package/es/interface/{i-modal-data → open-util/i-modal-data}/i-modal-data.d.ts +6 -0
- package/es/interface/open-util/i-modal-options/i-modal-options.d.ts +12 -0
- package/es/interface/open-util/i-overlay-container/i-overlay-container.d.ts +36 -0
- package/es/interface/open-util/i-overlay-controller/i-overlay-controller.d.ts +36 -0
- package/es/interface/open-util/index.d.ts +7 -0
- package/es/interface/provider/index.d.ts +0 -2
- package/es/locale/index.d.ts +11 -3
- package/es/locale/index.mjs +75 -56
- package/es/modules/env-manager/env-manager.const.mjs +16 -8
- package/es/modules/env-manager/env-manager.d.ts +2 -0
- package/es/modules/env-manager/env-manager.interface.d.ts +2 -0
- package/es/modules/env-manager/env-manager.interface.mjs +14 -7
- package/es/modules/env-manager/env-manager.mjs +108 -107
- package/es/modules/error-handler/error-handler.const.mjs +11 -16
- package/es/modules/error-handler/error-strategy.mjs +199 -175
- package/es/modules/error-handler/index.mjs +120 -106
- package/es/modules/mqtt/constants/mqtt.const.d.ts +33 -0
- package/es/modules/mqtt/constants/mqtt.const.mjs +24 -0
- package/es/modules/mqtt/enums/mqtt-status.enum.d.ts +20 -0
- package/es/modules/mqtt/enums/mqtt-status.enum.mjs +24 -0
- package/es/modules/mqtt/index.d.ts +5 -0
- package/es/modules/mqtt/index.mjs +4 -0
- package/es/modules/mqtt/interfaces/i-mqtt.d.ts +139 -0
- package/es/modules/mqtt/mqtt-client.d.ts +117 -0
- package/es/modules/mqtt/mqtt-client.mjs +229 -0
- package/es/modules/mqtt/mqtt-manager.d.ts +87 -0
- package/es/modules/mqtt/mqtt-manager.mjs +118 -0
- package/es/modules/platform-config/constants/index.mjs +4 -0
- package/es/modules/platform-config/constants/login.const.mjs +48 -45
- package/es/modules/platform-config/constants/org.const.mjs +57 -52
- package/es/modules/platform-config/constants/theme.const.mjs +11 -4
- package/es/modules/platform-config/constants/watermark.const.mjs +17 -12
- package/es/modules/platform-config/enums/deploy.enum.mjs +13 -6
- package/es/modules/platform-config/enums/login.enum.mjs +29 -15
- package/es/modules/platform-config/enums/platform.enum.d.ts +0 -15
- package/es/modules/platform-config/enums/platform.enum.mjs +17 -26
- package/es/modules/platform-config/index.d.ts +1 -1
- package/es/modules/platform-config/index.mjs +9 -0
- package/es/modules/platform-config/interfaces/index.d.ts +0 -1
- package/es/modules/platform-config/store.d.ts +5 -1
- package/es/modules/platform-config/store.mjs +68 -76
- package/es/modules/platform-config/useBasicSetting.mjs +47 -35
- package/es/modules/platform-config/useDeploySetting.mjs +29 -21
- package/es/modules/platform-config/useLoginSetting.mjs +151 -173
- package/es/modules/platform-config/useOrgSetting.mjs +63 -62
- package/es/modules/platform-config/useProjectSetting.mjs +14 -6
- package/es/modules/platform-config/useSecuritySetting.d.ts +1 -0
- package/es/modules/platform-config/useSecuritySetting.mjs +81 -56
- package/es/modules/platform-config/useThemeSetting.mjs +78 -59
- package/es/modules/platform-config/useWatermarkSetting.mjs +37 -23
- package/es/modules/user-stores/index.mjs +3 -0
- package/es/modules/user-stores/store/permission.store.mjs +27 -36
- package/es/modules/user-stores/store/tenant.store.mjs +20 -22
- package/es/modules/user-stores/store/user.store.d.ts +149 -1
- package/es/modules/user-stores/store/user.store.mjs +97 -94
- package/es/modules/user-stores/types/user.d.ts +1 -0
- package/es/router/index.mjs +25 -28
- package/es/setup-app.d.ts +8 -0
- package/es/setup-app.mjs +24 -0
- package/es/state/global-pinia-state/global-pinia-state.d.ts +15 -7
- package/es/state/global-pinia-state/global-pinia-state.mjs +43 -57
- package/es/state/index.d.ts +0 -9
- package/es/state/index.mjs +1 -0
- package/es/store/global-store.mjs +44 -51
- package/es/store/index.d.ts +8 -0
- package/es/store/index.mjs +35 -19
- package/es/store/storage-store.d.ts +9 -0
- package/es/store/storage-store.mjs +10 -0
- package/es/types/index.d.ts +22 -0
- package/es/utils/axios/interceptors.mjs +22 -18
- package/es/utils/cache-adapter/cache-adapter.d.ts +2 -0
- package/es/utils/cache-adapter/cache-adapter.mjs +64 -0
- package/es/utils/css-loader/css-loader.d.ts +36 -0
- package/es/utils/css-loader/css-loader.mjs +82 -0
- package/es/utils/design/design.d.ts +11 -0
- package/es/utils/design/design.mjs +21 -0
- package/es/utils/deviceFingerprint.mjs +77 -63
- package/es/utils/dictionary/dictionary.mjs +142 -145
- package/es/utils/file/base64Conver.d.ts +9 -0
- package/es/utils/file/base64Conver.mjs +40 -0
- package/es/utils/file/download.d.ts +44 -0
- package/es/utils/file/download.mjs +101 -0
- package/es/utils/file/parser.d.ts +3 -0
- package/es/utils/file/parser.mjs +29 -0
- package/es/utils/i18n/index.mjs +14 -3
- package/es/utils/index.d.ts +20 -5
- package/es/utils/index.mjs +34 -0
- package/es/utils/is-sort-filed/is-sort-filed.d.ts +10 -0
- package/es/utils/is-sort-filed/is-sort-filed.mjs +45 -0
- package/es/utils/kit-pkg-util/kit-pkg-util.d.ts +32 -0
- package/es/utils/kit-pkg-util/kit-pkg-util.mjs +73 -0
- package/es/utils/linked-list/linked-list.mjs +115 -118
- package/es/utils/linked-node/linked-node.mjs +41 -31
- package/es/utils/lowcode/utils.d.ts +1 -0
- package/es/utils/lowcode/utils.mjs +15 -0
- package/es/utils/lowcode/validate.d.ts +13 -0
- package/es/utils/lowcode/validate.mjs +23 -0
- package/es/utils/mitt/mitt.mjs +4 -4
- package/es/utils/model-loader/model-loader.mjs +288 -325
- package/es/utils/namespace/namespace.d.ts +8 -0
- package/es/utils/namespace/namespace.mjs +180 -163
- package/es/utils/openUtil/index.d.ts +2 -0
- package/es/utils/openUtil/index.mjs +2 -0
- package/es/utils/openUtil/modal/modal.d.ts +61 -0
- package/es/utils/openUtil/modal/modal.mjs +73 -0
- package/es/utils/openUtil/overlay-container/overlay-container.d.ts +100 -0
- package/es/utils/openUtil/overlay-container/overlay-container.mjs +145 -0
- package/es/utils/permission.d.ts +19 -0
- package/es/utils/permission.mjs +34 -0
- package/es/utils/plugin-pkg-util/plugin-pkg-util.d.ts +63 -0
- package/es/utils/plugin-pkg-util/plugin-pkg-util.mjs +119 -0
- package/es/utils/plugin-static-resource/plugin-static-resource.d.ts +2 -27
- package/es/utils/plugin-static-resource/plugin-static-resource.mjs +19 -42
- package/es/utils/style/index.mjs +94 -138
- package/es/utils/tools/tools.d.ts +12 -10
- package/es/utils/tools/tools.mjs +128 -53
- package/es/utils/treeHelper/treeHelper.d.ts +10 -9
- package/es/utils/treeHelper/treeHelper.mjs +205 -219
- package/es/utils/uploader/uploader.d.ts +20 -0
- package/es/utils/uploader/uploader.mjs +86 -0
- package/es/utils/useUUid.d.ts +41 -0
- package/es/utils/useUUid.mjs +85 -0
- package/es/utils/util.mjs +55 -35
- package/es/utils/uuid/uuid.d.ts +5 -0
- package/es/utils/uuid/uuid.mjs +38 -0
- package/es/utils/validate.d.ts +5 -0
- package/es/utils/validate.mjs +21 -0
- package/es/utils/value-helper/value-helper.mjs +113 -96
- package/package.json +19 -27
- package/dist/index.esm.min.mjs +0 -6103
- package/dist/index.min.cjs +0 -14
- package/dist/index.system.min.js +0 -14
- package/es/constants/editor-type/editor-type.d.ts +0 -244
- package/es/constants/editor-type/editor-type.mjs +0 -63
- package/es/controller/edit-form/edit-form.controller.d.ts +0 -28
- package/es/controller/edit-form/edit-form.controller.mjs +0 -47
- package/es/controller/editor/color-editor.controller.d.ts +0 -13
- package/es/controller/editor/color-editor.controller.mjs +0 -6
- package/es/controller/editor/length-unit-editor.controller.d.ts +0 -13
- package/es/controller/editor/length-unit-editor.controller.mjs +0 -6
- package/es/controller/editor-item/editor-item.controller.d.ts +0 -14
- package/es/controller/editor-item/editor-item.controller.mjs +0 -8
- package/es/controller/form/form.controller.d.ts +0 -76
- package/es/controller/form/form.controller.mjs +0 -147
- package/es/controller/form-collapse/form-collapse.controller.d.ts +0 -18
- package/es/controller/form-collapse/form-collapse.controller.mjs +0 -14
- package/es/controller/form-collapse-pane/form-collapse-pane.controller.d.ts +0 -18
- package/es/controller/form-collapse-pane/form-collapse-pane.controller.mjs +0 -14
- package/es/controller/form-edit-item/form-edit-item.controller.d.ts +0 -27
- package/es/controller/form-edit-item/form-edit-item.controller.mjs +0 -74
- package/es/controller/form-group/form-group.controller.d.ts +0 -18
- package/es/controller/form-group/form-group.controller.mjs +0 -14
- package/es/controller/form-item/form-item.controller.d.ts +0 -21
- package/es/controller/form-item/form-item.controller.mjs +0 -43
- package/es/controller/form-item-basic/form-item-basic.controller.d.ts +0 -57
- package/es/controller/form-item-basic/form-item-basic.controller.mjs +0 -49
- package/es/controller/form-item-hidden/form-item-hidden.controller.d.ts +0 -17
- package/es/controller/form-item-hidden/form-item-hidden.controller.mjs +0 -7
- package/es/controller/form-tab/form-tab.controller.d.ts +0 -18
- package/es/controller/form-tab/form-tab.controller.mjs +0 -14
- package/es/controller/form-tab-pane/form-tab-pane.controller.d.ts +0 -18
- package/es/controller/form-tab-pane/form-tab-pane.controller.mjs +0 -14
- package/es/controller/gct-form/gct-form.controller.d.ts +0 -101
- package/es/controller/gct-form/gct-form.controller.mjs +0 -214
- package/es/controller/index.d.ts +0 -15
- package/es/hooks/use-form/use-form.d.ts +0 -10
- package/es/hooks/use-form/use-form.mjs +0 -8
- package/es/hooks/use-gct-form-value/use-gct-form-value.d.ts +0 -22
- package/es/hooks/use-gct-form-value/use-gct-form-value.mjs +0 -89
- package/es/hooks/use-namespace/use-namespace.d.ts +0 -9
- package/es/hooks/use-namespace/use-namespace.mjs +0 -18
- package/es/interface/controller/edit-form/edit-form.controller.d.ts +0 -26
- package/es/interface/controller/editor/i-color-editor.controller.d.ts +0 -11
- package/es/interface/controller/editor/i-length-unit-editor.controller.d.ts +0 -11
- package/es/interface/controller/editor-item/editor-item.controller.d.ts +0 -19
- package/es/interface/controller/form/form.controller.d.ts +0 -121
- package/es/interface/controller/form-collapse/form-collapse.controller.d.ts +0 -23
- package/es/interface/controller/form-collapse-pane/form-collapse-pane.controller.d.ts +0 -23
- package/es/interface/controller/form-edit-item/form-edit-item.controller.d.ts +0 -59
- package/es/interface/controller/form-group/form-group.controller.d.ts +0 -24
- package/es/interface/controller/form-hidden-item/form-hidden-item.controller.d.ts +0 -24
- package/es/interface/controller/form-item/form-item.controller.d.ts +0 -40
- package/es/interface/controller/form-item-basic/form-item-basic.controller.d.ts +0 -51
- package/es/interface/controller/form-tab/form-tab.controller.d.ts +0 -23
- package/es/interface/controller/form-tab-pane/form-tab-pane.controller.d.ts +0 -23
- package/es/interface/controller/index.d.ts +0 -14
- package/es/interface/events/form/i-form.event.d.ts +0 -11
- package/es/interface/events/index.d.ts +0 -1
- package/es/interface/form/i-editor/i-check-switch.d.ts +0 -29
- package/es/interface/form/i-editor/i-checkbox-editor.d.ts +0 -9
- package/es/interface/form/i-editor/i-color-editor.d.ts +0 -13
- package/es/interface/form/i-editor/i-editor-basic.d.ts +0 -87
- package/es/interface/form/i-editor/i-icon-select-editor.d.ts +0 -21
- package/es/interface/form/i-editor/i-info-editor.d.ts +0 -21
- package/es/interface/form/i-editor/i-length-unit-editor.d.ts +0 -13
- package/es/interface/form/i-editor/i-model-field-select-editor.d.ts +0 -18
- package/es/interface/form/i-editor/i-number-editor.d.ts +0 -21
- package/es/interface/form/i-editor/i-picker-editor.d.ts +0 -30
- package/es/interface/form/i-editor/i-radio-editor.d.ts +0 -21
- package/es/interface/form/i-editor/i-select-editor.d.ts +0 -14
- package/es/interface/form/i-editor/i-span-editor.d.ts +0 -30
- package/es/interface/form/i-editor/i-switch-editor.d.ts +0 -14
- package/es/interface/form/i-editor/i-text-editor.d.ts +0 -46
- package/es/interface/form/i-editor/i-textarea-editor.d.ts +0 -25
- package/es/interface/form/i-form/i-edit-form.d.ts +0 -48
- package/es/interface/form/i-form/i-form-collapse-pane.d.ts +0 -30
- package/es/interface/form/i-form/i-form-collapse.d.ts +0 -35
- package/es/interface/form/i-form/i-form-container.d.ts +0 -53
- package/es/interface/form/i-form/i-form-edit-item.d.ts +0 -140
- package/es/interface/form/i-form/i-form-group-container.d.ts +0 -24
- package/es/interface/form/i-form/i-form-group.d.ts +0 -35
- package/es/interface/form/i-form/i-form-hidden-item.d.ts +0 -11
- package/es/interface/form/i-form/i-form-item-basic.d.ts +0 -126
- package/es/interface/form/i-form/i-form-item.d.ts +0 -11
- package/es/interface/form/i-form/i-form-tab-pane.d.ts +0 -23
- package/es/interface/form/i-form/i-form-tab.d.ts +0 -21
- package/es/interface/form/i-form/i-form.d.ts +0 -79
- package/es/interface/form/index.d.ts +0 -29
- package/es/interface/i-message-util/i-message-util.d.ts +0 -78
- package/es/interface/layout/i-flex-layout/i-flex-container.d.ts +0 -75
- package/es/interface/layout/i-flex-layout/i-flex-item.d.ts +0 -51
- package/es/interface/layout/i-grid-layout/i-grid-container.d.ts +0 -29
- package/es/interface/layout/i-grid-layout/i-grid-item-span.d.ts +0 -54
- package/es/interface/layout/i-grid-layout/i-grid-item.d.ts +0 -37
- package/es/interface/layout/i-layout-basis/i-layout-container-basis.d.ts +0 -11
- package/es/interface/layout/index.d.ts +0 -6
- package/es/interface/provider/i-editor-provider/i-editor-provider.d.ts +0 -24
- package/es/interface/provider/i-form-item-provider/i-form-item-provider.d.ts +0 -44
- package/es/interface/state/form/form.state.d.ts +0 -53
- package/es/interface/state/form-collapse/form-collapse.state.d.ts +0 -11
- package/es/interface/state/form-collapse-pane/form-collapse-pane.state.d.ts +0 -11
- package/es/interface/state/form-edit-item/form-edit-item.state.d.ts +0 -38
- package/es/interface/state/form-group/form-group.state.d.ts +0 -21
- package/es/interface/state/form-hidden-item/form-hidden-item.state.d.ts +0 -5
- package/es/interface/state/form-item/form-item.state.d.ts +0 -20
- package/es/interface/state/form-item-basic/form-item-basic.state.d.ts +0 -63
- package/es/interface/state/form-tab/form-tab.state.d.ts +0 -19
- package/es/interface/state/form-tab-pane/form-tab-pane.state.d.ts +0 -11
- package/es/interface/state/index.d.ts +0 -10
- package/es/modules/platform-config/interfaces/global-setting.interface.d.ts +0 -7
- package/es/register/editor-register/editor-register.d.ts +0 -49
- package/es/register/editor-register/editor-register.mjs +0 -57
- package/es/register/form-item-register/form-item-register.d.ts +0 -36
- package/es/register/form-item-register/form-item-register.mjs +0 -42
- package/es/register/index.d.ts +0 -21
- package/es/register/render-register/render-register.d.ts +0 -59
- package/es/register/render-register/render-register.mjs +0 -63
- package/es/state/form/form.state.d.ts +0 -24
- package/es/state/form/form.state.mjs +0 -16
- package/es/state/form-collapse/form-collapse.state.d.ts +0 -14
- package/es/state/form-collapse/form-collapse.state.mjs +0 -6
- package/es/state/form-collapse-pane/form-collapse-pane.state.d.ts +0 -14
- package/es/state/form-collapse-pane/form-collapse-pane.state.mjs +0 -6
- package/es/state/form-edit-item/form-edit-item.state.d.ts +0 -17
- package/es/state/form-edit-item/form-edit-item.state.mjs +0 -10
- package/es/state/form-group/form-group.state.d.ts +0 -21
- package/es/state/form-group/form-group.state.mjs +0 -14
- package/es/state/form-item/form-item.state.d.ts +0 -14
- package/es/state/form-item/form-item.state.mjs +0 -6
- package/es/state/form-item-basic/form-item-basic.state.d.ts +0 -17
- package/es/state/form-item-basic/form-item-basic.state.mjs +0 -9
- package/es/state/form-tab/form-tab.state.d.ts +0 -15
- package/es/state/form-tab/form-tab.state.mjs +0 -7
- package/es/state/form-tab-pane/form-tab-pane.state.d.ts +0 -14
- package/es/state/form-tab-pane/form-tab-pane.state.mjs +0 -6
- package/es/utils/props/gct-form-item/gct-form-item.props.d.ts +0 -63
- package/es/utils/props/gct-form-item/gct-form-item.props.mjs +0 -66
- package/es/utils/props/index.d.ts +0 -1
- package/es/utils/width-install/width-install.d.ts +0 -17
- package/es/utils/width-install/width-install.mjs +0 -19
|
@@ -1,220 +1,206 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
*/
|
|
207
|
-
static traverseAndBuildTree(treeData, callback, config = {}) {
|
|
208
|
-
config = this._getConfig(config);
|
|
209
|
-
const { children } = config;
|
|
210
|
-
return treeData.map((node) => {
|
|
211
|
-
const newNode = callback(node) || node;
|
|
212
|
-
if (children && node[children] && node[children].length > 0) {
|
|
213
|
-
newNode[children] = this.traverseAndBuildTree(node.children, callback);
|
|
214
|
-
}
|
|
215
|
-
return newNode;
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
|
|
1
|
+
//#region src/utils/treeHelper/treeHelper.ts
|
|
2
|
+
/**
|
|
3
|
+
* 树结构数据处理工具类
|
|
4
|
+
* 提供树形数据与列表数据的相互转换、节点查找、路径查找等功能
|
|
5
|
+
*/
|
|
6
|
+
var TreeHelper = class TreeHelper {
|
|
7
|
+
/**
|
|
8
|
+
* 默认配置
|
|
9
|
+
*/
|
|
10
|
+
static _DEFAULT_CONFIG = {
|
|
11
|
+
id: "id",
|
|
12
|
+
children: "children",
|
|
13
|
+
pid: "pid",
|
|
14
|
+
deep: true
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* 获取合并后的配置
|
|
18
|
+
* @param config 用户配置
|
|
19
|
+
* @returns 合并后的完整配置
|
|
20
|
+
*/
|
|
21
|
+
static _getConfig(config) {
|
|
22
|
+
return Object.assign({}, TreeHelper._DEFAULT_CONFIG, config);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* 将列表数据转换为树形结构
|
|
26
|
+
* @param list 列表数据
|
|
27
|
+
* @param config 配置项
|
|
28
|
+
* @param callBack 节点转换回调函数
|
|
29
|
+
* @returns 树形结构数据
|
|
30
|
+
*/
|
|
31
|
+
static listToTree(list, config = {}, callBack) {
|
|
32
|
+
const conf = TreeHelper._getConfig(config);
|
|
33
|
+
const nodeMap = /* @__PURE__ */ new Map();
|
|
34
|
+
const result = [];
|
|
35
|
+
const { id, children, pid, deep } = conf;
|
|
36
|
+
for (const node of list) {
|
|
37
|
+
const record = node;
|
|
38
|
+
if (!deep) record[children] = record[pid] === "ROOT" ? record[children] ?? [] : [];
|
|
39
|
+
else record[children] = record[children] ?? void 0;
|
|
40
|
+
nodeMap.set(record[id], callBack(node));
|
|
41
|
+
}
|
|
42
|
+
for (const node of list) {
|
|
43
|
+
const record = node;
|
|
44
|
+
const parent = nodeMap.get(record[pid]);
|
|
45
|
+
if (parent) {
|
|
46
|
+
const parentRecord = parent;
|
|
47
|
+
if (!parentRecord[children]) parentRecord[children] = [];
|
|
48
|
+
parentRecord[children].push(callBack(node));
|
|
49
|
+
} else result.push(callBack(node));
|
|
50
|
+
}
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* 将树形结构转换为列表数据
|
|
55
|
+
* @param tree 树形结构数据
|
|
56
|
+
* @param config 配置项
|
|
57
|
+
* @returns 列表数据
|
|
58
|
+
*/
|
|
59
|
+
static treeToList(tree, config = {}) {
|
|
60
|
+
const { children } = TreeHelper._getConfig(config);
|
|
61
|
+
const result = [...tree];
|
|
62
|
+
for (let i = 0; i < result.length; i++) {
|
|
63
|
+
const child = result[i][children];
|
|
64
|
+
if (!Array.isArray(child)) continue;
|
|
65
|
+
result.splice(i + 1, 0, ...child);
|
|
66
|
+
}
|
|
67
|
+
return result;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* 在树中查找单个节点
|
|
71
|
+
* @param tree 树形结构数据
|
|
72
|
+
* @param func 查找条件函数
|
|
73
|
+
* @param config 配置项
|
|
74
|
+
* @returns 找到的节点或 null
|
|
75
|
+
*/
|
|
76
|
+
static findNode(tree, func, config = {}) {
|
|
77
|
+
const { children } = TreeHelper._getConfig(config);
|
|
78
|
+
const list = tree ? [...tree] : [];
|
|
79
|
+
for (const node of list) {
|
|
80
|
+
if (func(node)) return node;
|
|
81
|
+
const child = node[children];
|
|
82
|
+
if (Array.isArray(child)) list.push(...child);
|
|
83
|
+
}
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* 在树中查找所有匹配的节点
|
|
88
|
+
* @param tree 树形结构数据
|
|
89
|
+
* @param func 查找条件函数
|
|
90
|
+
* @param config 配置项
|
|
91
|
+
* @returns 所有匹配的节点数组
|
|
92
|
+
*/
|
|
93
|
+
static findNodeAll(tree, func, config = {}) {
|
|
94
|
+
const { children } = TreeHelper._getConfig(config);
|
|
95
|
+
const list = tree ? [...tree] : [];
|
|
96
|
+
const result = [];
|
|
97
|
+
for (const node of list) {
|
|
98
|
+
if (func(node)) result.push(node);
|
|
99
|
+
const child = node[children];
|
|
100
|
+
if (Array.isArray(child)) list.push(...child);
|
|
101
|
+
}
|
|
102
|
+
return result;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* 查找节点的路径
|
|
106
|
+
* @param tree 树形结构数据
|
|
107
|
+
* @param func 查找条件函数
|
|
108
|
+
* @param config 配置项
|
|
109
|
+
* @returns 从根节点到目标节点的路径数组,未找到返回 null
|
|
110
|
+
*/
|
|
111
|
+
static findPath(tree, func, config = {}) {
|
|
112
|
+
const { children } = TreeHelper._getConfig(config);
|
|
113
|
+
const path = [];
|
|
114
|
+
const list = tree ? [...tree] : [];
|
|
115
|
+
const visitedSet = /* @__PURE__ */ new Set();
|
|
116
|
+
while (list.length) {
|
|
117
|
+
const node = list[0];
|
|
118
|
+
if (visitedSet.has(node)) {
|
|
119
|
+
path.pop();
|
|
120
|
+
list.shift();
|
|
121
|
+
} else {
|
|
122
|
+
visitedSet.add(node);
|
|
123
|
+
const child = node[children];
|
|
124
|
+
if (Array.isArray(child)) list.unshift(...child);
|
|
125
|
+
path.push(node);
|
|
126
|
+
if (func(node)) return path;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* 查找最近的符合条件的父节点
|
|
133
|
+
* @param tree 树形结构数据
|
|
134
|
+
* @param startId 起始节点 ID
|
|
135
|
+
* @param func 查找条件函数
|
|
136
|
+
* @param config 配置项
|
|
137
|
+
* @returns 找到的父节点或 undefined
|
|
138
|
+
*/
|
|
139
|
+
static findClosestParent(tree, startId, func, config = {}) {
|
|
140
|
+
const { id } = TreeHelper._getConfig(config);
|
|
141
|
+
return TreeHelper.findPath(tree, (node) => node[id] === startId, config)?.reverse().find((n) => func(n));
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* 将具有 id 和 parentId 的列表转换为树形结构
|
|
145
|
+
* @param list 列表数据,需要包含 id 和 parentId 字段
|
|
146
|
+
* @param callBack 节点转换回调函数
|
|
147
|
+
* @returns 树形结构数据
|
|
148
|
+
*/
|
|
149
|
+
static list_to_tree(list, callBack) {
|
|
150
|
+
const map = {};
|
|
151
|
+
const roots = [];
|
|
152
|
+
for (let i = 0; i < list.length; i++) {
|
|
153
|
+
const node = list[i];
|
|
154
|
+
map[node.id] = i;
|
|
155
|
+
node.children = [];
|
|
156
|
+
}
|
|
157
|
+
for (const node of list) if (node.parentId === "ROOT" || !node.parentId) roots.push(callBack(node));
|
|
158
|
+
else {
|
|
159
|
+
const current = node;
|
|
160
|
+
const parentIndex = map[node.parentId];
|
|
161
|
+
if (parentIndex !== void 0) list[parentIndex].children?.push(callBack(current));
|
|
162
|
+
}
|
|
163
|
+
return roots;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* 获取所有父级路径
|
|
167
|
+
* @param treeData 树形结构数据
|
|
168
|
+
* @param path 目标路径
|
|
169
|
+
* @returns 从根节点到目标节点的所有路径数组
|
|
170
|
+
*/
|
|
171
|
+
static getAllParentPath(treeData, path) {
|
|
172
|
+
return (TreeHelper.findPath(treeData, (n) => n.path === path) || []).map((item) => item.path);
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* 递归遍历树并且根据callback返回新数据再拼装成一个新树
|
|
176
|
+
*
|
|
177
|
+
* @static
|
|
178
|
+
* @param {IObject[]} treeData
|
|
179
|
+
* @param {Function} callback
|
|
180
|
+
* @param {Partial<ITreeHelperConfig>} [config={}]
|
|
181
|
+
* @return {*}
|
|
182
|
+
*/
|
|
183
|
+
static traverseAndBuildTree(treeData, callback, config = {}) {
|
|
184
|
+
config = this._getConfig(config);
|
|
185
|
+
const { children } = config;
|
|
186
|
+
return treeData.map((node) => {
|
|
187
|
+
const newNode = callback(node) || node;
|
|
188
|
+
if (children && node[children] && node[children].length > 0) newNode[children] = this.traverseAndBuildTree(node.children, callback);
|
|
189
|
+
return newNode;
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* 递归遍历树结构
|
|
194
|
+
* @param treeData 树形结构数据
|
|
195
|
+
* @param callBack 回调函数
|
|
196
|
+
* @param parentNode 父节点
|
|
197
|
+
*/
|
|
198
|
+
static eachTree(treeData, callBack, parentNode = {}) {
|
|
199
|
+
treeData.forEach((element) => {
|
|
200
|
+
const newNode = callBack(element, parentNode) || element;
|
|
201
|
+
if (element.children) TreeHelper.eachTree(element.children, callBack, newNode);
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
//#endregion
|
|
220
206
|
export { TreeHelper };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare class Uploader {
|
|
2
|
+
static getFiles({ multiple, acceptList, }: {
|
|
3
|
+
multiple: boolean;
|
|
4
|
+
acceptList?: string;
|
|
5
|
+
}): Promise<File[]>;
|
|
6
|
+
static beforeUploadFun(file: File, { maxSize, acceptList, beforeUpload, }: {
|
|
7
|
+
maxSize: number;
|
|
8
|
+
acceptList: string[];
|
|
9
|
+
beforeUpload?: (file: File) => Promise<unknown>;
|
|
10
|
+
}): Promise<undefined>;
|
|
11
|
+
static uploadByFile(file: File, isApp?: boolean, modelKey?: string): Promise<string>;
|
|
12
|
+
static toBase64(file: File): Promise<unknown>;
|
|
13
|
+
/**
|
|
14
|
+
* 图片压缩转Base64
|
|
15
|
+
*/
|
|
16
|
+
static compressToBase64(file: File, { quality, scale }?: {
|
|
17
|
+
quality?: number | undefined;
|
|
18
|
+
scale?: number | undefined;
|
|
19
|
+
}): Promise<unknown>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
//#region src/utils/uploader/uploader.ts
|
|
2
|
+
var Uploader = class {
|
|
3
|
+
static getFiles({ multiple, acceptList }) {
|
|
4
|
+
const input = document.createElement("input");
|
|
5
|
+
input.type = "file";
|
|
6
|
+
input.multiple = !!multiple;
|
|
7
|
+
input.accept = acceptList || "*";
|
|
8
|
+
input.click();
|
|
9
|
+
return new Promise((resolve, reject) => {
|
|
10
|
+
input.onchange = async () => {
|
|
11
|
+
const filelist = input.files || [];
|
|
12
|
+
resolve(Object.values(filelist));
|
|
13
|
+
};
|
|
14
|
+
input.onerror = async () => {
|
|
15
|
+
reject();
|
|
16
|
+
};
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
static async beforeUploadFun(file, { maxSize = 5, acceptList = [], beforeUpload }) {
|
|
20
|
+
if (file.name.indexOf(",") > -1) return Promise.reject(`文件名不能有逗号`);
|
|
21
|
+
if (beforeUpload) await beforeUpload(file);
|
|
22
|
+
if (file.size / 1024 / 1024 > maxSize) return Promise.reject(`【${file.name}】文件大小不能超过 ${maxSize}MB`);
|
|
23
|
+
if (acceptList.length) {
|
|
24
|
+
const filename = file?.name?.replaceAll(" ", "")?.match(/\.([A-Za-z0-9]+)$/)?.at(-1);
|
|
25
|
+
if (!acceptList.includes(`.${filename?.toLocaleLowerCase()}`)) return Promise.reject(`【${file.name}】支持的扩展名为${acceptList.join(" ")}`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
static async uploadByFile(file, isApp = false, modelKey) {
|
|
29
|
+
const formData = new FormData();
|
|
30
|
+
formData.append("file", file, file.name);
|
|
31
|
+
return "/" + await (isApp ? appUploadapis : passUploadapis)(formData, modelKey);
|
|
32
|
+
}
|
|
33
|
+
static toBase64(file) {
|
|
34
|
+
return new Promise((resolve, reject) => {
|
|
35
|
+
const reader = new FileReader();
|
|
36
|
+
reader.onloadend = function() {
|
|
37
|
+
resolve(reader.result);
|
|
38
|
+
};
|
|
39
|
+
reader.onerror = () => reject("转换失败");
|
|
40
|
+
if (file) reader.readAsDataURL(file);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* 图片压缩转Base64
|
|
45
|
+
*/
|
|
46
|
+
static compressToBase64(file, { quality = .8, scale = .8 } = {}) {
|
|
47
|
+
return new Promise((resolve, reject) => {
|
|
48
|
+
if (!file.type.startsWith("image/")) {
|
|
49
|
+
reject("请选择图片文件");
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (typeof scale !== "number" || scale <= 0 || scale > 1) {
|
|
53
|
+
reject("缩放比例必须在0-1之间");
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const reader = new FileReader();
|
|
57
|
+
reader.onload = (e) => {
|
|
58
|
+
const img = new Image();
|
|
59
|
+
img.onload = () => {
|
|
60
|
+
const width = Math.floor(img.width * scale);
|
|
61
|
+
const height = Math.floor(img.height * scale);
|
|
62
|
+
const canvas = document.createElement("canvas");
|
|
63
|
+
canvas.width = width;
|
|
64
|
+
canvas.height = height;
|
|
65
|
+
const ctx = canvas.getContext("2d");
|
|
66
|
+
ctx.imageSmoothingEnabled = true;
|
|
67
|
+
ctx.imageSmoothingQuality = "high";
|
|
68
|
+
ctx.drawImage(img, 0, 0, width, height);
|
|
69
|
+
resolve(canvas.toDataURL(file.type, quality));
|
|
70
|
+
};
|
|
71
|
+
img.onerror = () => reject("图片加载失败");
|
|
72
|
+
img.src = e.target?.result;
|
|
73
|
+
};
|
|
74
|
+
reader.onerror = () => reject("文件读取失败");
|
|
75
|
+
reader.readAsDataURL(file);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
async function appUploadapis(formData, modelKey) {
|
|
80
|
+
return _api.apaas.fileResource.postUpload({ ...modelKey ? { modelKey } : {} }, formData, { headers: { "Content-Type": "multipart/form-data;charset=UTF-8" } });
|
|
81
|
+
}
|
|
82
|
+
async function passUploadapis(formData) {
|
|
83
|
+
return _api.apaas.file.postUploadImage({ bucket: "IMAGE" }, formData, { headers: { "Content-Type": "multipart/form-data;charset=UTF-8" } });
|
|
84
|
+
}
|
|
85
|
+
//#endregion
|
|
86
|
+
export { Uploader };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
interface IRandomUUidOpts {
|
|
3
|
+
/** 是否需要拼接前缀(默认不需要) */
|
|
4
|
+
needPrefix?: boolean;
|
|
5
|
+
/** 随机串只能是字符串 */
|
|
6
|
+
isString?: boolean;
|
|
7
|
+
/** 前缀,默认前缀u_ */
|
|
8
|
+
prefix?: string;
|
|
9
|
+
/** 即将生成的uuid位数(不包含前缀, 默认8位) */
|
|
10
|
+
length?: number;
|
|
11
|
+
/** 类型 */
|
|
12
|
+
chars?: string;
|
|
13
|
+
/** 是否数字打头 */
|
|
14
|
+
numPref?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* 生成随机串
|
|
18
|
+
* @param uuids 不可用的uuid
|
|
19
|
+
* @param opts
|
|
20
|
+
* @param opts.needPrefix 是否需要拼接前缀(默认不需要)
|
|
21
|
+
* @param opts.isString 随机串只能是字符串
|
|
22
|
+
* @param opts.prefix 前缀,默认前缀u_
|
|
23
|
+
* @param opts.length 即将生成的uuid位数(不包含前缀, 默认8位)
|
|
24
|
+
* @param opts.chars 类型
|
|
25
|
+
* @param opts.numPref 数字打头
|
|
26
|
+
*/
|
|
27
|
+
export declare const randomUUID: {
|
|
28
|
+
(uuids?: string[], opts?: IRandomUUidOpts): string;
|
|
29
|
+
Generate(uuids?: string[], opts?: IRandomUUidOpts): {
|
|
30
|
+
next: () => string;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
export declare function useUUid(tableData: Ref<IObject[]>, keyAttr: Ref<string>, opts?: IRandomUUidOpts): {
|
|
34
|
+
oldUUids: import('vue').ComputedRef<any[]>;
|
|
35
|
+
flatTableData: import('vue').ComputedRef<IObject[]>;
|
|
36
|
+
getUuid: (uuidsProp?: string[], optsProp?: IRandomUUidOpts) => string;
|
|
37
|
+
getUuidGenerate: (uuidsProp?: string[], optsProp?: IRandomUUidOpts) => {
|
|
38
|
+
next: () => string;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
export {};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { computed, unref } from "vue";
|
|
2
|
+
//#region src/utils/useUUid.ts
|
|
3
|
+
/**
|
|
4
|
+
* 生成随机串
|
|
5
|
+
* @param uuids 不可用的uuid
|
|
6
|
+
* @param opts
|
|
7
|
+
* @param opts.needPrefix 是否需要拼接前缀(默认不需要)
|
|
8
|
+
* @param opts.isString 随机串只能是字符串
|
|
9
|
+
* @param opts.prefix 前缀,默认前缀u_
|
|
10
|
+
* @param opts.length 即将生成的uuid位数(不包含前缀, 默认8位)
|
|
11
|
+
* @param opts.chars 类型
|
|
12
|
+
* @param opts.numPref 数字打头
|
|
13
|
+
*/
|
|
14
|
+
var randomUUID = (uuids = [], opts) => {
|
|
15
|
+
const { needPrefix = false, isString = true, prefix = "u_", length = 8, chars = "", numPref = false } = opts || {};
|
|
16
|
+
let characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
17
|
+
if (chars === "capital&number") characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
|
18
|
+
else if (chars === "lowercase&number") characters = "abcdefghijklmnopqrstuvwxyz0123456789";
|
|
19
|
+
else if (chars === "lowercase") characters = "abcdefghijklmnopqrstuvwxyz";
|
|
20
|
+
let uuid;
|
|
21
|
+
while (!uuid) {
|
|
22
|
+
let id = "";
|
|
23
|
+
if (isString) {
|
|
24
|
+
if (numPref) id += Math.floor(Math.random() * 9) + 1;
|
|
25
|
+
for (let i = 0; i < length; i++) id += characters.charAt(Math.floor(Math.random() * characters.length));
|
|
26
|
+
} else id = `${needPrefix ? prefix : ""}${numPref ? Math.floor(Math.random() * 9) + 1 : ""}${Math.random().toString(36).substr(2, length)}`;
|
|
27
|
+
if (!uuids.includes(id)) uuid = id;
|
|
28
|
+
}
|
|
29
|
+
return uuid;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* uuid生成器
|
|
33
|
+
* @param uuids 已有uuid
|
|
34
|
+
*/
|
|
35
|
+
randomUUID.Generate = (uuids, opts) => {
|
|
36
|
+
const cloneUUids = Array.isArray(uuids) ? uuids.concat() : [];
|
|
37
|
+
return { next: () => {
|
|
38
|
+
const id = randomUUID(cloneUUids, opts);
|
|
39
|
+
cloneUUids.push(id);
|
|
40
|
+
return id;
|
|
41
|
+
} };
|
|
42
|
+
};
|
|
43
|
+
function useUUid(tableData, keyAttr, opts) {
|
|
44
|
+
const f_children = "children";
|
|
45
|
+
const f_key = "key";
|
|
46
|
+
const flatTableData = computed(() => {
|
|
47
|
+
return tableData.value.reduce((list, item) => {
|
|
48
|
+
list.push(item);
|
|
49
|
+
const nodes = item[f_children].map((ele) => {
|
|
50
|
+
return {
|
|
51
|
+
...ele,
|
|
52
|
+
_pid_: item.id
|
|
53
|
+
};
|
|
54
|
+
});
|
|
55
|
+
list.push(...nodes);
|
|
56
|
+
return list;
|
|
57
|
+
}, []);
|
|
58
|
+
});
|
|
59
|
+
const oldUUids = computed(() => {
|
|
60
|
+
return flatTableData.value.map((data) => {
|
|
61
|
+
if (data._pid_) return data[f_key].replace(new RegExp(`^${unref(keyAttr)}_*`), "");
|
|
62
|
+
return null;
|
|
63
|
+
}).filter((i) => i);
|
|
64
|
+
});
|
|
65
|
+
function getUuid(uuidsProp, optsProp) {
|
|
66
|
+
return randomUUID([...unref(oldUUids), ...uuidsProp ?? []], {
|
|
67
|
+
...opts,
|
|
68
|
+
...optsProp
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
function getUuidGenerate(uuidsProp, optsProp) {
|
|
72
|
+
return randomUUID.Generate([...unref(oldUUids), ...uuidsProp ?? []], {
|
|
73
|
+
...opts,
|
|
74
|
+
...optsProp
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
oldUUids,
|
|
79
|
+
flatTableData,
|
|
80
|
+
getUuid,
|
|
81
|
+
getUuidGenerate
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
//#endregion
|
|
85
|
+
export { randomUUID, useUUid };
|