@gct-paas/core 0.1.4-dev.6 → 0.1.4-dev.8
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.mjs +6103 -0
- package/dist/index.min.cjs +13 -14
- package/dist/index.system.min.js +13 -14
- package/es/constants/core.mjs +0 -1
- package/es/constants/editor-register/editor-register.mjs +0 -1
- package/es/constants/editor-type/editor-type.d.ts +65 -1
- package/es/constants/editor-type/editor-type.mjs +14 -1
- package/es/constants/form-container-type/form-container-type.mjs +0 -1
- package/es/constants/index.d.ts +4 -0
- package/es/constants/index.mjs +2 -7
- package/es/controller/edit-form/edit-form.controller.mjs +0 -1
- package/es/controller/editor/color-editor.controller.mjs +0 -1
- package/es/controller/editor/length-unit-editor.controller.mjs +0 -1
- package/es/controller/editor-item/editor-item.controller.mjs +0 -1
- package/es/controller/form/form.controller.mjs +5 -4
- package/es/controller/form-collapse/form-collapse.controller.mjs +4 -3
- package/es/controller/form-collapse-pane/form-collapse-pane.controller.mjs +4 -3
- package/es/controller/form-edit-item/form-edit-item.controller.d.ts +1 -0
- package/es/controller/form-edit-item/form-edit-item.controller.mjs +6 -2
- package/es/controller/form-group/form-group.controller.mjs +4 -3
- package/es/controller/form-item/form-item.controller.d.ts +1 -0
- package/es/controller/form-item/form-item.controller.mjs +7 -3
- package/es/controller/form-item-basic/form-item-basic.controller.mjs +3 -2
- package/es/controller/form-item-hidden/form-item-hidden.controller.mjs +0 -1
- package/es/controller/form-tab/form-tab.controller.mjs +4 -3
- package/es/controller/form-tab-pane/form-tab-pane.controller.mjs +4 -3
- package/es/controller/gct-form/gct-form.controller.mjs +5 -4
- package/es/create-app-vue.mjs +5 -5
- package/es/enums/app-designer/index.d.ts +13 -1
- package/es/enums/app-designer/index.mjs +8 -2
- package/es/enums/appEnum.d.ts +17 -66
- package/es/enums/appEnum.mjs +18 -14
- package/es/enums/appStateEnum.mjs +0 -1
- package/es/enums/authActionEnum.mjs +0 -1
- package/es/enums/breakpointEnum.mjs +0 -1
- package/es/enums/cacheEnum.mjs +0 -1
- package/es/enums/designEnum.mjs +0 -1
- package/es/enums/exceptionEnum.mjs +0 -1
- package/es/enums/globalEnum.d.ts +38 -0
- package/es/enums/globalEnum.mjs +25 -0
- package/es/enums/httpEnum.mjs +0 -1
- package/es/enums/index.d.ts +13 -0
- package/es/enums/index.mjs +15 -20
- package/es/enums/menuEnum.mjs +0 -1
- package/es/enums/page-designer/designer.d.ts +17 -3
- package/es/enums/page-designer/designer.mjs +85 -6
- package/es/enums/page-designer/panel.mjs +0 -1
- package/es/enums/page-designer/toolkit.mjs +0 -1
- package/es/enums/page-designer/widget.d.ts +2 -1
- package/es/enums/page-designer/widget.mjs +3 -3
- package/es/enums/pageEnum.mjs +0 -1
- package/es/enums/plugin-enum.mjs +0 -1
- package/es/enums/processEnum.mjs +0 -1
- package/es/enums/roleEnum.mjs +0 -1
- package/es/enums/sizeEnum.mjs +0 -1
- package/es/global/gct/gct.d.ts +3 -14
- package/es/global/gct/gct.mjs +20 -16
- package/es/hooks/index.d.ts +2 -0
- package/es/hooks/use-app-inst/use-app-inst.d.ts +8 -0
- package/es/hooks/use-app-inst/use-app-inst.mjs +8 -0
- package/es/hooks/use-form/use-form.mjs +0 -1
- package/es/hooks/use-gct-form-value/use-gct-form-value.d.ts +1 -1
- package/es/hooks/use-gct-form-value/use-gct-form-value.mjs +0 -4
- package/es/hooks/use-modal/use-modal.mjs +0 -1
- package/es/hooks/use-namespace/use-namespace.mjs +11 -2
- package/es/hooks/use-sub-app-utils/use-sub-app-utils.d.ts +31 -0
- package/es/hooks/use-sub-app-utils/use-sub-app-utils.mjs +30 -0
- package/es/hooks/useCopyToClipboard.d.ts +3 -3
- package/es/hooks/useCopyToClipboard.mjs +0 -1
- package/es/index.d.ts +5 -1
- package/es/index.mjs +61 -42
- package/es/interface/controller/form-edit-item/form-edit-item.controller.d.ts +5 -0
- package/es/interface/controller/index.d.ts +0 -1
- package/es/interface/form/i-editor/i-editor-basic.d.ts +2 -2
- package/es/interface/form/i-editor/i-model-field-select-editor.d.ts +18 -0
- package/es/interface/form/i-form/i-form-collapse-pane.d.ts +4 -0
- package/es/interface/form/i-form/i-form-item-basic.d.ts +1 -1
- package/es/interface/form/i-form/i-form-tab-pane.d.ts +4 -0
- package/es/interface/form/index.d.ts +1 -0
- package/es/interface/i-app-context/i-app-context.d.ts +34 -0
- package/es/interface/i-field-code-chain/i-field-code-chain.d.ts +17 -0
- package/es/interface/i-global-var/i-global-var.d.ts +15 -0
- package/es/interface/i-mobile-home-menu-item/i-mobile-home-menu-item.d.ts +94 -0
- package/es/interface/i-pinia-action/i-global-actions.d.ts +8 -20
- package/es/interface/i-pinia-getter/i-global-getters.d.ts +1 -1
- package/es/interface/i-pinia-state/i-global-state.d.ts +7 -14
- package/es/interface/index.d.ts +5 -2
- package/es/interface/open-util/i-open-window-options/i-open-window-options.d.ts +59 -0
- package/es/interface/state/index.d.ts +0 -1
- package/es/locale/index.mjs +1 -2
- package/es/modules/env-manager/env-manager.const.mjs +0 -1
- package/es/modules/env-manager/env-manager.interface.mjs +0 -1
- package/es/modules/env-manager/env-manager.mjs +7 -8
- package/es/modules/error-handler/error-handler.const.mjs +1 -30
- package/es/modules/error-handler/error-strategy.mjs +4 -2
- package/es/modules/error-handler/index.mjs +0 -1
- package/es/modules/platform-config/constants/index.d.ts +7 -0
- package/es/modules/platform-config/constants/login.const.d.ts +15 -0
- package/es/modules/platform-config/constants/login.const.mjs +50 -0
- package/es/modules/platform-config/constants/org.const.d.ts +9 -0
- package/es/modules/platform-config/constants/org.const.mjs +54 -0
- package/es/modules/platform-config/constants/theme.const.d.ts +9 -0
- package/es/modules/platform-config/constants/theme.const.mjs +5 -0
- package/es/modules/platform-config/constants/watermark.const.d.ts +16 -0
- package/es/modules/platform-config/constants/watermark.const.mjs +14 -0
- package/es/modules/platform-config/enums/deploy.enum.d.ts +10 -0
- package/es/modules/platform-config/enums/deploy.enum.mjs +7 -0
- package/es/modules/platform-config/enums/index.d.ts +6 -0
- package/es/modules/platform-config/{constants.d.ts → enums/login.enum.d.ts} +3 -7
- package/es/modules/platform-config/enums/login.enum.mjs +16 -0
- package/es/modules/platform-config/enums/platform.enum.d.ts +27 -0
- package/es/modules/platform-config/{types.mjs → enums/platform.enum.mjs} +0 -1
- package/es/modules/platform-config/index.d.ts +6 -17
- package/es/modules/platform-config/interfaces/global-setting.interface.d.ts +7 -0
- package/es/modules/platform-config/interfaces/index.d.ts +7 -0
- package/es/modules/platform-config/interfaces/login-config.interface.d.ts +17 -0
- package/es/modules/platform-config/interfaces/platform-map.interface.d.ts +8 -0
- package/es/modules/platform-config/interfaces/theme-setting.interface.d.ts +30 -0
- package/es/modules/platform-config/store.d.ts +221 -0
- package/es/modules/platform-config/store.mjs +78 -0
- package/es/modules/platform-config/useBasicSetting.d.ts +6 -2
- package/es/modules/platform-config/useBasicSetting.mjs +4 -15
- package/es/modules/platform-config/useDeploySetting.d.ts +9 -4
- package/es/modules/platform-config/useDeploySetting.mjs +4 -9
- package/es/modules/platform-config/useLoginSetting.d.ts +8 -10
- package/es/modules/platform-config/useLoginSetting.mjs +24 -30
- package/es/modules/platform-config/useOrgSetting.d.ts +19 -1
- package/es/modules/platform-config/useOrgSetting.mjs +9 -64
- package/es/modules/platform-config/useProjectSetting.d.ts +12 -0
- package/es/modules/platform-config/useProjectSetting.mjs +11 -0
- package/es/modules/platform-config/useSecuritySetting.d.ts +5 -1
- package/es/modules/platform-config/useSecuritySetting.mjs +0 -11
- package/es/modules/platform-config/useThemeSetting.d.ts +7 -4
- package/es/modules/platform-config/useThemeSetting.mjs +5 -14
- package/es/modules/platform-config/useWatermarkSetting.d.ts +4 -1
- package/es/modules/platform-config/useWatermarkSetting.mjs +2 -24
- package/es/modules/user-stores/index.d.ts +3 -0
- package/es/modules/user-stores/store/permission.store.d.ts +21 -0
- package/es/modules/user-stores/store/permission.store.mjs +38 -0
- package/es/modules/user-stores/store/tenant.store.d.ts +9 -0
- package/es/modules/user-stores/store/tenant.store.mjs +24 -0
- package/es/modules/user-stores/store/user.store.d.ts +154 -0
- package/es/modules/user-stores/store/user.store.mjs +100 -0
- package/es/modules/user-stores/types/permission.d.ts +1 -0
- package/es/modules/user-stores/types/tenant.d.ts +1 -0
- package/es/modules/user-stores/types/user.d.ts +14 -0
- package/es/register/editor-register/editor-register.d.ts +5 -13
- package/es/register/editor-register/editor-register.mjs +8 -17
- package/es/register/form-item-register/form-item-register.d.ts +4 -15
- package/es/register/form-item-register/form-item-register.mjs +7 -17
- package/es/register/index.d.ts +18 -1
- package/es/register/render-register/render-register.mjs +0 -1
- package/es/router/index.mjs +0 -1
- package/es/state/form/form.state.mjs +0 -1
- package/es/state/form-collapse/form-collapse.state.mjs +0 -1
- package/es/state/form-collapse-pane/form-collapse-pane.state.mjs +0 -1
- package/es/state/form-edit-item/form-edit-item.state.mjs +0 -1
- package/es/state/form-group/form-group.state.mjs +0 -1
- package/es/state/form-item/form-item.state.mjs +0 -1
- package/es/state/form-item-basic/form-item-basic.state.mjs +0 -1
- package/es/state/form-tab/form-tab.state.mjs +0 -1
- package/es/state/form-tab-pane/form-tab-pane.state.mjs +0 -1
- package/es/state/global-pinia-state/global-pinia-state.d.ts +8 -25
- package/es/state/global-pinia-state/global-pinia-state.mjs +30 -16
- package/es/store/global-store.d.ts +1 -0
- package/es/store/global-store.mjs +34 -32
- package/es/store/index.d.ts +2 -3
- package/es/store/index.mjs +0 -1
- package/es/types/index.d.ts +14 -3
- package/es/utils/axios/interceptors.mjs +3 -23
- package/es/utils/deviceFingerprint.d.ts +17 -0
- package/es/utils/deviceFingerprint.mjs +73 -0
- package/es/utils/dictionary/dictionary.mjs +0 -1
- package/es/utils/i18n/index.d.ts +2 -1
- package/es/utils/i18n/index.mjs +3 -4
- package/es/utils/index.d.ts +11 -2
- package/es/utils/linked-list/linked-list.d.ts +72 -0
- package/es/utils/linked-list/linked-list.mjs +119 -0
- package/es/utils/linked-node/linked-node.d.ts +31 -0
- package/es/utils/linked-node/linked-node.mjs +32 -0
- package/es/utils/mitt/mitt.d.ts +1 -0
- package/es/utils/mitt/mitt.mjs +5 -0
- package/es/utils/model-loader/model-loader.d.ts +118 -0
- package/es/utils/model-loader/model-loader.mjs +326 -0
- package/es/utils/namespace/namespace.mjs +0 -1
- package/es/utils/plugin-static-resource/plugin-static-resource.mjs +0 -1
- package/es/utils/props/gct-form-item/gct-form-item.props.d.ts +63 -0
- package/es/utils/props/gct-form-item/gct-form-item.props.mjs +66 -0
- package/es/utils/props/index.d.ts +1 -0
- package/es/utils/style/index.d.ts +16 -0
- package/es/utils/style/index.mjs +141 -0
- package/es/utils/tools/tools.d.ts +13 -10
- package/es/utils/tools/tools.mjs +19 -11
- package/es/utils/treeHelper/treeHelper.d.ts +117 -0
- package/es/utils/treeHelper/treeHelper.mjs +220 -0
- package/es/utils/util.d.ts +39 -0
- package/es/utils/util.mjs +40 -0
- package/es/utils/value-helper/value-helper.d.ts +49 -0
- package/es/utils/value-helper/value-helper.mjs +109 -0
- package/es/utils/width-install/width-install.mjs +0 -2
- package/package.json +34 -36
- package/es/controller/index.mjs +0 -17
- package/es/enums/page-designer/index.mjs +0 -6
- package/es/global/index.mjs +0 -3
- package/es/hooks/index.mjs +0 -7
- package/es/interface/controller/edit-form/edit-form.controller.mjs +0 -1
- package/es/interface/controller/editor/i-color-editor.controller.mjs +0 -1
- package/es/interface/controller/editor/i-length-unit-editor.controller.mjs +0 -1
- package/es/interface/controller/editor-item/editor-item.controller.mjs +0 -1
- package/es/interface/controller/form/form.controller.mjs +0 -3
- package/es/interface/controller/form-collapse/form-collapse.controller.mjs +0 -1
- package/es/interface/controller/form-collapse-pane/form-collapse-pane.controller.mjs +0 -1
- package/es/interface/controller/form-edit-item/form-edit-item.controller.mjs +0 -1
- package/es/interface/controller/form-group/form-group.controller.mjs +0 -1
- package/es/interface/controller/form-hidden-item/form-hidden-item.controller.mjs +0 -1
- package/es/interface/controller/form-item/form-item.controller.mjs +0 -1
- package/es/interface/controller/form-item-basic/form-item-basic.controller.mjs +0 -1
- package/es/interface/controller/form-tab/form-tab.controller.mjs +0 -1
- package/es/interface/controller/form-tab-pane/form-tab-pane.controller.mjs +0 -1
- package/es/interface/controller/i-designer-controller.d.ts +0 -116
- package/es/interface/controller/i-designer-controller.mjs +0 -1
- package/es/interface/controller/index.mjs +0 -1
- package/es/interface/events/form/i-form.event.mjs +0 -1
- package/es/interface/events/index.mjs +0 -1
- package/es/interface/form/i-editor/i-check-switch.mjs +0 -3
- package/es/interface/form/i-editor/i-checkbox-editor.mjs +0 -3
- package/es/interface/form/i-editor/i-color-editor.mjs +0 -3
- package/es/interface/form/i-editor/i-editor-basic.mjs +0 -1
- package/es/interface/form/i-editor/i-icon-select-editor.mjs +0 -3
- package/es/interface/form/i-editor/i-info-editor.mjs +0 -3
- package/es/interface/form/i-editor/i-length-unit-editor.mjs +0 -3
- package/es/interface/form/i-editor/i-number-editor.mjs +0 -3
- package/es/interface/form/i-editor/i-picker-editor.mjs +0 -3
- package/es/interface/form/i-editor/i-radio-editor.mjs +0 -3
- package/es/interface/form/i-editor/i-select-editor.mjs +0 -3
- package/es/interface/form/i-editor/i-span-editor.mjs +0 -3
- package/es/interface/form/i-editor/i-switch-editor.mjs +0 -3
- package/es/interface/form/i-editor/i-text-editor.mjs +0 -3
- package/es/interface/form/i-editor/i-textarea-editor.mjs +0 -3
- package/es/interface/form/i-form/i-edit-form.mjs +0 -1
- package/es/interface/form/i-form/i-form-collapse-pane.mjs +0 -1
- package/es/interface/form/i-form/i-form-collapse.mjs +0 -1
- package/es/interface/form/i-form/i-form-container.mjs +0 -1
- package/es/interface/form/i-form/i-form-edit-item.mjs +0 -1
- package/es/interface/form/i-form/i-form-group-container.mjs +0 -1
- package/es/interface/form/i-form/i-form-group.mjs +0 -1
- package/es/interface/form/i-form/i-form-hidden-item.mjs +0 -1
- package/es/interface/form/i-form/i-form-item-basic.mjs +0 -1
- package/es/interface/form/i-form/i-form-item.mjs +0 -1
- package/es/interface/form/i-form/i-form-tab-pane.mjs +0 -1
- package/es/interface/form/i-form/i-form-tab.mjs +0 -1
- package/es/interface/form/i-form/i-form.mjs +0 -1
- package/es/interface/form/index.mjs +0 -1
- package/es/interface/hooks/i-designer-hooks.d.ts +0 -26
- package/es/interface/hooks/i-designer-hooks.mjs +0 -3
- package/es/interface/hooks/index.d.ts +0 -1
- package/es/interface/hooks/index.mjs +0 -1
- package/es/interface/i-dictionary/i-dictionary-item.mjs +0 -1
- package/es/interface/i-dictionary/i-dictionary.mjs +0 -1
- package/es/interface/i-import-style-map/i-import-style-map.mjs +0 -1
- package/es/interface/i-message-util/i-message-util.mjs +0 -1
- package/es/interface/i-modal/i-modal.mjs +0 -3
- package/es/interface/i-modal-data/i-modal-data.mjs +0 -1
- package/es/interface/i-pinia-action/i-global-actions.mjs +0 -1
- package/es/interface/i-pinia-getter/i-global-getters.mjs +0 -1
- package/es/interface/i-pinia-state/i-global-state.mjs +0 -1
- package/es/interface/index.mjs +0 -1
- package/es/interface/layout/i-flex-layout/i-flex-container.mjs +0 -1
- package/es/interface/layout/i-flex-layout/i-flex-item.mjs +0 -1
- package/es/interface/layout/i-grid-layout/i-grid-container.mjs +0 -1
- package/es/interface/layout/i-grid-layout/i-grid-item-span.mjs +0 -1
- package/es/interface/layout/i-grid-layout/i-grid-item.mjs +0 -1
- package/es/interface/layout/i-layout-basis/i-layout-container-basis.mjs +0 -1
- package/es/interface/layout/index.mjs +0 -1
- package/es/interface/low-code-types/index.d.ts +0 -4
- package/es/interface/low-code-types/index.mjs +0 -5
- package/es/interface/low-code-types/modal-types.d.ts +0 -67
- package/es/interface/low-code-types/modal-types.mjs +0 -3
- package/es/interface/low-code-types/model/index.d.ts +0 -5338
- package/es/interface/low-code-types/model/index.mjs +0 -1
- package/es/interface/low-code-types/schema/index.d.ts +0 -12
- package/es/interface/low-code-types/schema/index.mjs +0 -1
- package/es/interface/low-code-types/widget-basic-types.d.ts +0 -667
- package/es/interface/low-code-types/widget-basic-types.mjs +0 -3
- package/es/interface/provider/i-editor-provider/i-editor-provider.mjs +0 -1
- package/es/interface/provider/i-form-item-provider/i-form-item-provider.mjs +0 -1
- package/es/interface/provider/i-provider-basic/i-provider-basic.mjs +0 -1
- package/es/interface/provider/index.mjs +0 -1
- package/es/interface/state/form/form.state.mjs +0 -1
- package/es/interface/state/form-collapse/form-collapse.state.mjs +0 -1
- package/es/interface/state/form-collapse-pane/form-collapse-pane.state.mjs +0 -1
- package/es/interface/state/form-edit-item/form-edit-item.state.mjs +0 -1
- package/es/interface/state/form-group/form-group.state.mjs +0 -1
- package/es/interface/state/form-hidden-item/form-hidden-item.state.mjs +0 -1
- package/es/interface/state/form-item/form-item.state.mjs +0 -1
- package/es/interface/state/form-item-basic/form-item-basic.state.mjs +0 -1
- package/es/interface/state/form-tab/form-tab.state.mjs +0 -1
- package/es/interface/state/form-tab-pane/form-tab-pane.state.mjs +0 -1
- package/es/interface/state/i-designer-state.d.ts +0 -27
- package/es/interface/state/i-designer-state.mjs +0 -1
- package/es/interface/state/index.mjs +0 -1
- package/es/interface/style/i-border.mjs +0 -1
- package/es/interface/style/i-font.mjs +0 -1
- package/es/interface/style/i-margin.mjs +0 -1
- package/es/interface/style/i-padding.mjs +0 -1
- package/es/interface/style/i-position.mjs +0 -1
- package/es/interface/style/i-spacing.mjs +0 -1
- package/es/interface/style/index.mjs +0 -1
- package/es/modules/api-service/api-manage.d.ts +0 -26
- package/es/modules/api-service/api-manage.mjs +0 -33
- package/es/modules/api-service/api-service.d.ts +0 -96
- package/es/modules/api-service/api-service.interface.d.ts +0 -159
- package/es/modules/api-service/api-service.interface.mjs +0 -4
- package/es/modules/api-service/api-service.mjs +0 -173
- package/es/modules/api-service/http.enum.d.ts +0 -76
- package/es/modules/api-service/http.enum.mjs +0 -63
- package/es/modules/api-service/http.util.d.ts +0 -113
- package/es/modules/api-service/http.util.mjs +0 -160
- package/es/modules/api-service/index.d.ts +0 -8
- package/es/modules/api-service/index.mjs +0 -13
- package/es/modules/env-manager/index.mjs +0 -5
- package/es/modules/error-handler/error-handler.interface.mjs +0 -1
- package/es/modules/platform-config/constants.mjs +0 -63
- package/es/modules/platform-config/index.mjs +0 -17
- package/es/modules/platform-config/types.d.ts +0 -67
- package/es/provider/i-designer-provider/i-designer-provider.d.ts +0 -102
- package/es/provider/i-designer-provider/i-designer-provider.mjs +0 -1
- package/es/provider/index.d.ts +0 -1
- package/es/provider/index.mjs +0 -1
- package/es/register/designer-register/designer-register.d.ts +0 -53
- package/es/register/designer-register/designer-register.mjs +0 -68
- package/es/register/index.mjs +0 -6
- package/es/state/index.mjs +0 -12
- package/es/utils/index.mjs +0 -10
- package/es/utils/plugin-pkg-util/plugin-pkg-util.d.ts +0 -96
- package/es/utils/plugin-pkg-util/plugin-pkg-util.mjs +0 -260
package/es/utils/tools/tools.mjs
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { getCookie, setCookie, clearCookie } from 'qx-util';
|
|
2
2
|
import { mergeWith, cloneDeep, unionWith, isEqual } from 'lodash-es';
|
|
3
|
-
import '../../constants/index.mjs';
|
|
4
|
-
import '../../enums/index.mjs';
|
|
5
3
|
import { CoreConst } from '../../constants/core.mjs';
|
|
4
|
+
import '../../enums/app-designer/index.mjs';
|
|
5
|
+
import '../../enums/page-designer/designer.mjs';
|
|
6
|
+
import '../../enums/breakpointEnum.mjs';
|
|
6
7
|
import { TIMEZONE_KEY } from '../../enums/cacheEnum.mjs';
|
|
8
|
+
import qs from 'qs';
|
|
7
9
|
|
|
8
|
-
"use strict";
|
|
9
10
|
function getToken() {
|
|
10
11
|
return getCookie(CoreConst.TOKEN);
|
|
11
12
|
}
|
|
@@ -26,13 +27,6 @@ function setTenant(tenant) {
|
|
|
26
27
|
clearCookie(CoreConst.TENANT, true);
|
|
27
28
|
}
|
|
28
29
|
}
|
|
29
|
-
function getPathQuery() {
|
|
30
|
-
const params = location.pathname.replace("/src/projects", "").split("/");
|
|
31
|
-
return {
|
|
32
|
-
aid: params[2],
|
|
33
|
-
pid: params[3]
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
30
|
const isMobile = (() => {
|
|
37
31
|
const ua = navigator.userAgent;
|
|
38
32
|
const mobileRegex = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/;
|
|
@@ -56,5 +50,19 @@ function deepMerge(target, source) {
|
|
|
56
50
|
}
|
|
57
51
|
});
|
|
58
52
|
}
|
|
53
|
+
function stringifyMatrixParams(params) {
|
|
54
|
+
const str = qs.stringify(params, {
|
|
55
|
+
encode: true,
|
|
56
|
+
delimiter: ";"
|
|
57
|
+
});
|
|
58
|
+
return str ? `;${str}` : "";
|
|
59
|
+
}
|
|
60
|
+
function parseMatrixParams(path) {
|
|
61
|
+
const idx = path.indexOf(";");
|
|
62
|
+
if (idx === -1) return {};
|
|
63
|
+
return qs.parse(path, {
|
|
64
|
+
delimiter: ";"
|
|
65
|
+
});
|
|
66
|
+
}
|
|
59
67
|
|
|
60
|
-
export { deepMerge,
|
|
68
|
+
export { deepMerge, getTenant, getTimezone, getToken, isMobile, parseMatrixParams, setTenant, setToken, stringifyMatrixParams };
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 节点判断函数类型
|
|
3
|
+
*/
|
|
4
|
+
type Fn<T> = (node: T, parent?: T) => boolean | unknown;
|
|
5
|
+
/**
|
|
6
|
+
* 树结构辅助配置接口
|
|
7
|
+
*/
|
|
8
|
+
interface ITreeHelperConfig {
|
|
9
|
+
/** 节点 ID 字段名 */
|
|
10
|
+
id: string;
|
|
11
|
+
/** 子节点字段名 */
|
|
12
|
+
children: string;
|
|
13
|
+
/** 父节点 ID 字段名 */
|
|
14
|
+
pid: string;
|
|
15
|
+
/** 是否深度遍历 */
|
|
16
|
+
deep: boolean;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* 带子节点的对象接口
|
|
20
|
+
*/
|
|
21
|
+
interface IWithChildren<R> {
|
|
22
|
+
children?: R[];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* 树结构数据处理工具类
|
|
26
|
+
* 提供树形数据与列表数据的相互转换、节点查找、路径查找等功能
|
|
27
|
+
*/
|
|
28
|
+
export declare class TreeHelper {
|
|
29
|
+
/**
|
|
30
|
+
* 默认配置
|
|
31
|
+
*/
|
|
32
|
+
private static readonly _DEFAULT_CONFIG;
|
|
33
|
+
/**
|
|
34
|
+
* 获取合并后的配置
|
|
35
|
+
* @param config 用户配置
|
|
36
|
+
* @returns 合并后的完整配置
|
|
37
|
+
*/
|
|
38
|
+
private static _getConfig;
|
|
39
|
+
/**
|
|
40
|
+
* 将列表数据转换为树形结构
|
|
41
|
+
* @param list 列表数据
|
|
42
|
+
* @param config 配置项
|
|
43
|
+
* @param callBack 节点转换回调函数
|
|
44
|
+
* @returns 树形结构数据
|
|
45
|
+
*/
|
|
46
|
+
static listToTree<T extends IObject = IObject, R = T>(list: T[], config: Partial<ITreeHelperConfig> | undefined, callBack: (node: T) => R): R[];
|
|
47
|
+
/**
|
|
48
|
+
* 将树形结构转换为列表数据
|
|
49
|
+
* @param tree 树形结构数据
|
|
50
|
+
* @param config 配置项
|
|
51
|
+
* @returns 列表数据
|
|
52
|
+
*/
|
|
53
|
+
static treeToList<T extends IObject = IObject>(tree: T[], config?: Partial<ITreeHelperConfig>): T[];
|
|
54
|
+
/**
|
|
55
|
+
* 在树中查找单个节点
|
|
56
|
+
* @param tree 树形结构数据
|
|
57
|
+
* @param func 查找条件函数
|
|
58
|
+
* @param config 配置项
|
|
59
|
+
* @returns 找到的节点或 null
|
|
60
|
+
*/
|
|
61
|
+
static findNode<T extends IObject = IObject>(tree: T[], func: Fn<T>, config?: Partial<ITreeHelperConfig>): T | null;
|
|
62
|
+
/**
|
|
63
|
+
* 在树中查找所有匹配的节点
|
|
64
|
+
* @param tree 树形结构数据
|
|
65
|
+
* @param func 查找条件函数
|
|
66
|
+
* @param config 配置项
|
|
67
|
+
* @returns 所有匹配的节点数组
|
|
68
|
+
*/
|
|
69
|
+
static findNodeAll<T extends IObject = IObject>(tree: T[], func: Fn<T>, config?: Partial<ITreeHelperConfig>): T[];
|
|
70
|
+
/**
|
|
71
|
+
* 查找节点的路径
|
|
72
|
+
* @param tree 树形结构数据
|
|
73
|
+
* @param func 查找条件函数
|
|
74
|
+
* @param config 配置项
|
|
75
|
+
* @returns 从根节点到目标节点的路径数组,未找到返回 null
|
|
76
|
+
*/
|
|
77
|
+
static findPath<T extends IObject = IObject>(tree: T[], func: Fn<T>, config?: Partial<ITreeHelperConfig>): T[] | null;
|
|
78
|
+
/**
|
|
79
|
+
* 查找最近的符合条件的父节点
|
|
80
|
+
* @param tree 树形结构数据
|
|
81
|
+
* @param startId 起始节点 ID
|
|
82
|
+
* @param func 查找条件函数
|
|
83
|
+
* @param config 配置项
|
|
84
|
+
* @returns 找到的父节点或 undefined
|
|
85
|
+
*/
|
|
86
|
+
static findClosestParent<T extends IObject = IObject>(tree: T[], startId: string | number, func: Fn<T>, config?: Partial<ITreeHelperConfig>): T | undefined;
|
|
87
|
+
/**
|
|
88
|
+
* 将具有 id 和 parentId 的列表转换为树形结构
|
|
89
|
+
* @param list 列表数据,需要包含 id 和 parentId 字段
|
|
90
|
+
* @param callBack 节点转换回调函数
|
|
91
|
+
* @returns 树形结构数据
|
|
92
|
+
*/
|
|
93
|
+
static list_to_tree<T extends {
|
|
94
|
+
id?: string;
|
|
95
|
+
parentId?: string;
|
|
96
|
+
}, R = T>(list: T[], callBack?: (n: T & IWithChildren<R>) => R): R[];
|
|
97
|
+
/**
|
|
98
|
+
* 获取所有父级路径
|
|
99
|
+
* @param treeData 树形结构数据
|
|
100
|
+
* @param path 目标路径
|
|
101
|
+
* @returns 从根节点到目标节点的所有路径数组
|
|
102
|
+
*/
|
|
103
|
+
static getAllParentPath(treeData: object & {
|
|
104
|
+
path: string;
|
|
105
|
+
}[], path: string): string[];
|
|
106
|
+
/**
|
|
107
|
+
* 递归遍历树并且根据callback返回新数据再拼装成一个新树
|
|
108
|
+
*
|
|
109
|
+
* @static
|
|
110
|
+
* @param {IObject[]} treeData
|
|
111
|
+
* @param {Function} callback
|
|
112
|
+
* @param {Partial<ITreeHelperConfig>} [config={}]
|
|
113
|
+
* @return {*}
|
|
114
|
+
*/
|
|
115
|
+
static traverseAndBuildTree(treeData: IObject[], callback: (node: IObject) => IObject | unknown, config?: Partial<ITreeHelperConfig>): IObject[];
|
|
116
|
+
}
|
|
117
|
+
export {};
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
class TreeHelper {
|
|
2
|
+
/**
|
|
3
|
+
* 默认配置
|
|
4
|
+
*/
|
|
5
|
+
static _DEFAULT_CONFIG = {
|
|
6
|
+
id: "id",
|
|
7
|
+
children: "children",
|
|
8
|
+
pid: "pid",
|
|
9
|
+
deep: true
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* 获取合并后的配置
|
|
13
|
+
* @param config 用户配置
|
|
14
|
+
* @returns 合并后的完整配置
|
|
15
|
+
*/
|
|
16
|
+
static _getConfig(config) {
|
|
17
|
+
return Object.assign({}, TreeHelper._DEFAULT_CONFIG, config);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* 将列表数据转换为树形结构
|
|
21
|
+
* @param list 列表数据
|
|
22
|
+
* @param config 配置项
|
|
23
|
+
* @param callBack 节点转换回调函数
|
|
24
|
+
* @returns 树形结构数据
|
|
25
|
+
*/
|
|
26
|
+
static listToTree(list, config = {}, callBack) {
|
|
27
|
+
const conf = TreeHelper._getConfig(config);
|
|
28
|
+
const nodeMap = /* @__PURE__ */ new Map();
|
|
29
|
+
const result = [];
|
|
30
|
+
const { id, children, pid, deep } = conf;
|
|
31
|
+
for (const node of list) {
|
|
32
|
+
const record = node;
|
|
33
|
+
if (!deep) {
|
|
34
|
+
record[children] = record[pid] === "ROOT" ? record[children] ?? [] : [];
|
|
35
|
+
} else {
|
|
36
|
+
record[children] = record[children] ?? void 0;
|
|
37
|
+
}
|
|
38
|
+
nodeMap.set(record[id], callBack(node));
|
|
39
|
+
}
|
|
40
|
+
for (const node of list) {
|
|
41
|
+
const record = node;
|
|
42
|
+
const parent = nodeMap.get(record[pid]);
|
|
43
|
+
if (parent) {
|
|
44
|
+
const parentRecord = parent;
|
|
45
|
+
if (!parentRecord[children]) {
|
|
46
|
+
parentRecord[children] = [];
|
|
47
|
+
}
|
|
48
|
+
parentRecord[children].push(callBack(node));
|
|
49
|
+
} else {
|
|
50
|
+
result.push(callBack(node));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return result;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* 将树形结构转换为列表数据
|
|
57
|
+
* @param tree 树形结构数据
|
|
58
|
+
* @param config 配置项
|
|
59
|
+
* @returns 列表数据
|
|
60
|
+
*/
|
|
61
|
+
static treeToList(tree, config = {}) {
|
|
62
|
+
const { children } = TreeHelper._getConfig(config);
|
|
63
|
+
const result = [...tree];
|
|
64
|
+
for (let i = 0; i < result.length; i++) {
|
|
65
|
+
const record = result[i];
|
|
66
|
+
const child = record[children];
|
|
67
|
+
if (!Array.isArray(child)) continue;
|
|
68
|
+
result.splice(i + 1, 0, ...child);
|
|
69
|
+
}
|
|
70
|
+
return result;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* 在树中查找单个节点
|
|
74
|
+
* @param tree 树形结构数据
|
|
75
|
+
* @param func 查找条件函数
|
|
76
|
+
* @param config 配置项
|
|
77
|
+
* @returns 找到的节点或 null
|
|
78
|
+
*/
|
|
79
|
+
static findNode(tree, func, config = {}) {
|
|
80
|
+
const { children } = TreeHelper._getConfig(config);
|
|
81
|
+
const list = tree ? [...tree] : [];
|
|
82
|
+
for (const node of list) {
|
|
83
|
+
if (func(node)) return node;
|
|
84
|
+
const record = node;
|
|
85
|
+
const child = record[children];
|
|
86
|
+
if (Array.isArray(child)) {
|
|
87
|
+
list.push(...child);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* 在树中查找所有匹配的节点
|
|
94
|
+
* @param tree 树形结构数据
|
|
95
|
+
* @param func 查找条件函数
|
|
96
|
+
* @param config 配置项
|
|
97
|
+
* @returns 所有匹配的节点数组
|
|
98
|
+
*/
|
|
99
|
+
static findNodeAll(tree, func, config = {}) {
|
|
100
|
+
const { children } = TreeHelper._getConfig(config);
|
|
101
|
+
const list = tree ? [...tree] : [];
|
|
102
|
+
const result = [];
|
|
103
|
+
for (const node of list) {
|
|
104
|
+
if (func(node)) result.push(node);
|
|
105
|
+
const record = node;
|
|
106
|
+
const child = record[children];
|
|
107
|
+
if (Array.isArray(child)) {
|
|
108
|
+
list.push(...child);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return result;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* 查找节点的路径
|
|
115
|
+
* @param tree 树形结构数据
|
|
116
|
+
* @param func 查找条件函数
|
|
117
|
+
* @param config 配置项
|
|
118
|
+
* @returns 从根节点到目标节点的路径数组,未找到返回 null
|
|
119
|
+
*/
|
|
120
|
+
static findPath(tree, func, config = {}) {
|
|
121
|
+
const { children } = TreeHelper._getConfig(config);
|
|
122
|
+
const path = [];
|
|
123
|
+
const list = tree ? [...tree] : [];
|
|
124
|
+
const visitedSet = /* @__PURE__ */ new Set();
|
|
125
|
+
while (list.length) {
|
|
126
|
+
const node = list[0];
|
|
127
|
+
if (visitedSet.has(node)) {
|
|
128
|
+
path.pop();
|
|
129
|
+
list.shift();
|
|
130
|
+
} else {
|
|
131
|
+
visitedSet.add(node);
|
|
132
|
+
const record = node;
|
|
133
|
+
const child = record[children];
|
|
134
|
+
if (Array.isArray(child)) {
|
|
135
|
+
list.unshift(...child);
|
|
136
|
+
}
|
|
137
|
+
path.push(node);
|
|
138
|
+
if (func(node)) return path;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* 查找最近的符合条件的父节点
|
|
145
|
+
* @param tree 树形结构数据
|
|
146
|
+
* @param startId 起始节点 ID
|
|
147
|
+
* @param func 查找条件函数
|
|
148
|
+
* @param config 配置项
|
|
149
|
+
* @returns 找到的父节点或 undefined
|
|
150
|
+
*/
|
|
151
|
+
static findClosestParent(tree, startId, func, config = {}) {
|
|
152
|
+
const { id } = TreeHelper._getConfig(config);
|
|
153
|
+
const path = TreeHelper.findPath(
|
|
154
|
+
tree,
|
|
155
|
+
(node) => node[id] === startId,
|
|
156
|
+
config
|
|
157
|
+
);
|
|
158
|
+
return path?.reverse().find((n) => func(n));
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* 将具有 id 和 parentId 的列表转换为树形结构
|
|
162
|
+
* @param list 列表数据,需要包含 id 和 parentId 字段
|
|
163
|
+
* @param callBack 节点转换回调函数
|
|
164
|
+
* @returns 树形结构数据
|
|
165
|
+
*/
|
|
166
|
+
static list_to_tree(list, callBack = (n) => n) {
|
|
167
|
+
const map = {};
|
|
168
|
+
const roots = [];
|
|
169
|
+
for (let i = 0; i < list.length; i++) {
|
|
170
|
+
const node = list[i];
|
|
171
|
+
map[node.id] = i;
|
|
172
|
+
node.children = [];
|
|
173
|
+
}
|
|
174
|
+
for (const node of list) {
|
|
175
|
+
if (node.parentId === "ROOT" || !node.parentId) {
|
|
176
|
+
roots.push(callBack(node));
|
|
177
|
+
} else {
|
|
178
|
+
const current = node;
|
|
179
|
+
const parentIndex = map[node.parentId];
|
|
180
|
+
if (parentIndex !== void 0) {
|
|
181
|
+
const parent = list[parentIndex];
|
|
182
|
+
parent.children?.push(callBack(current));
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return roots;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* 获取所有父级路径
|
|
190
|
+
* @param treeData 树形结构数据
|
|
191
|
+
* @param path 目标路径
|
|
192
|
+
* @returns 从根节点到目标节点的所有路径数组
|
|
193
|
+
*/
|
|
194
|
+
static getAllParentPath(treeData, path) {
|
|
195
|
+
const menuList = TreeHelper.findPath(treeData, (n) => n.path === path);
|
|
196
|
+
return (menuList || []).map((item) => item.path);
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* 递归遍历树并且根据callback返回新数据再拼装成一个新树
|
|
200
|
+
*
|
|
201
|
+
* @static
|
|
202
|
+
* @param {IObject[]} treeData
|
|
203
|
+
* @param {Function} callback
|
|
204
|
+
* @param {Partial<ITreeHelperConfig>} [config={}]
|
|
205
|
+
* @return {*}
|
|
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
|
+
|
|
220
|
+
export { TreeHelper };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { IOpenWindowOptions } from '../interface';
|
|
2
|
+
/**
|
|
3
|
+
* 替换url中的参数,格式为xxx/{aid}/xxx/{pid}/{bid?}
|
|
4
|
+
*
|
|
5
|
+
* @export
|
|
6
|
+
* @param {string} url - 原始 URL 字符串
|
|
7
|
+
* @param {IObject} data - 用于替换占位符的数据对象
|
|
8
|
+
* @return {string} 处理后的 URL 字符串
|
|
9
|
+
*/
|
|
10
|
+
export declare function genUrl(url: string, data: IObject): string;
|
|
11
|
+
/**
|
|
12
|
+
* 打开新窗口
|
|
13
|
+
*
|
|
14
|
+
* @export
|
|
15
|
+
* @param {string} url - 要打开的 URL
|
|
16
|
+
* @param {IOpenWindowOptions} [options] - 窗口配置选项
|
|
17
|
+
* @return {Window | null} 新打开的窗口对象,如果打开失败则返回 null
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* // 简单打开新窗口
|
|
22
|
+
* openWindow('https://example.com');
|
|
23
|
+
*
|
|
24
|
+
* // 使用 URL 参数替换
|
|
25
|
+
* openWindow('/user/{id}/profile', {
|
|
26
|
+
* genUrlData: { id: '123' }
|
|
27
|
+
* });
|
|
28
|
+
*
|
|
29
|
+
* // 完整配置
|
|
30
|
+
* openWindow('https://example.com', {
|
|
31
|
+
* target: '_blank',
|
|
32
|
+
* noopener: true,
|
|
33
|
+
* noreferrer: true,
|
|
34
|
+
* routePath: '/dashboard',
|
|
35
|
+
* optionStr: 'width=800,height=600'
|
|
36
|
+
* });
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export declare function openWindow(url: string, options?: IOpenWindowOptions): Window | null;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
function genUrl(url, data) {
|
|
2
|
+
let result = url;
|
|
3
|
+
Object.keys(data).forEach((key) => {
|
|
4
|
+
result = result.replace(`{${key}}`, data[key] ?? "");
|
|
5
|
+
result = result.replace(`{${key}?}`, data[key] ?? "");
|
|
6
|
+
});
|
|
7
|
+
result = result.replace(/\/\{[a-z]+\?\}/g, "");
|
|
8
|
+
return result;
|
|
9
|
+
}
|
|
10
|
+
function openWindow(url, options) {
|
|
11
|
+
const {
|
|
12
|
+
target = "_blank",
|
|
13
|
+
noopener = true,
|
|
14
|
+
noreferrer = true,
|
|
15
|
+
genUrlData,
|
|
16
|
+
routePath = "",
|
|
17
|
+
optionStr = ""
|
|
18
|
+
} = options || {};
|
|
19
|
+
const features = [];
|
|
20
|
+
if (noopener) {
|
|
21
|
+
features.push("noopener=yes");
|
|
22
|
+
}
|
|
23
|
+
if (noreferrer) {
|
|
24
|
+
features.push("noreferrer=yes");
|
|
25
|
+
}
|
|
26
|
+
let finalUrl = url;
|
|
27
|
+
if (genUrlData) {
|
|
28
|
+
finalUrl = genUrl(finalUrl, genUrlData);
|
|
29
|
+
}
|
|
30
|
+
if (routePath) {
|
|
31
|
+
finalUrl += routePath;
|
|
32
|
+
}
|
|
33
|
+
let featuresStr = features.join(",");
|
|
34
|
+
if (optionStr) {
|
|
35
|
+
featuresStr = featuresStr ? `${featuresStr},${optionStr}` : optionStr;
|
|
36
|
+
}
|
|
37
|
+
return window.open(finalUrl, target, featuresStr);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export { genUrl, openWindow };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Ref, ToRefs, ComputedGetter, ComputedSetter } from 'vue';
|
|
2
|
+
export declare function afterValueSet<U>(value: Ref<U>, afterSet: (i: U) => void): Ref<U>;
|
|
3
|
+
export declare function afterFieldSet<T extends object>(object: T | Ref<T>, afterSet: <F extends keyof T>(field: F, v: T[F]) => void): ToRefs<T>;
|
|
4
|
+
/**
|
|
5
|
+
* 属性修改的时候不修改并抛出事件
|
|
6
|
+
* @author lingxiaoming
|
|
7
|
+
* @date 2024-07-17 03:30:44
|
|
8
|
+
* @export
|
|
9
|
+
* @template T
|
|
10
|
+
* @param {(T | Ref<T>)} object (对象必须有该属性,即使是undefined,否则无法监控)
|
|
11
|
+
* @param {<F extends keyof T>(field: F, v: T[F], newObj: T) => void} emitSet newObj是将要修改成的完整数据
|
|
12
|
+
* @return {*} {ToRefs<T>}
|
|
13
|
+
*/
|
|
14
|
+
export declare function emitFieldSet<T extends object>(object: T | Ref<T>, emitSet: <F extends keyof T>(field: F, v: T[F], newObj: T) => void): ToRefs<T>;
|
|
15
|
+
/**
|
|
16
|
+
* 解析数值和单位
|
|
17
|
+
* @author lingxiaoming
|
|
18
|
+
* @date 2024-07-15 06:06:41
|
|
19
|
+
* @param {string} str
|
|
20
|
+
* @return {*} {({ value: number; unit: string } | null)}
|
|
21
|
+
*/
|
|
22
|
+
export declare function parseValueUnit(str: string): {
|
|
23
|
+
value: number;
|
|
24
|
+
unit: string;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* 增强computed,当属性变更时,自动调用set方法
|
|
28
|
+
* @author lingxiaoming
|
|
29
|
+
* @date 2024-08-26 10:19:01
|
|
30
|
+
* @export
|
|
31
|
+
* @param {{
|
|
32
|
+
* get: ComputedGetter<T>;
|
|
33
|
+
* set: ComputedSetter<T>;
|
|
34
|
+
* deep: boolean; //为true时,深层属性变更也会触发set
|
|
35
|
+
* }} opts
|
|
36
|
+
*/
|
|
37
|
+
export declare function computedEx<T>(opts: {
|
|
38
|
+
get: ComputedGetter<T>;
|
|
39
|
+
set: ComputedSetter<T>;
|
|
40
|
+
deep?: boolean;
|
|
41
|
+
}): Ref<T, T>;
|
|
42
|
+
/**
|
|
43
|
+
* 缓存函数返回值,下次相同参数调用时直接返回缓存值
|
|
44
|
+
* @export
|
|
45
|
+
* @template T
|
|
46
|
+
* @param cb
|
|
47
|
+
* @return {*}
|
|
48
|
+
*/
|
|
49
|
+
export declare function cacheFnReturn<T extends Function>(cb: T): T;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { isRef, computed, ref, watch } from 'vue';
|
|
2
|
+
|
|
3
|
+
function afterValueSet(value, afterSet) {
|
|
4
|
+
const newVal = computed({
|
|
5
|
+
get: () => value.value,
|
|
6
|
+
set: (v) => {
|
|
7
|
+
value.value = v;
|
|
8
|
+
afterSet(v);
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
return newVal;
|
|
12
|
+
}
|
|
13
|
+
function afterFieldSet(object, afterSet) {
|
|
14
|
+
const keys = Object.keys(isRef(object) ? object.value : object);
|
|
15
|
+
const result = {};
|
|
16
|
+
keys.forEach((key) => {
|
|
17
|
+
result[key] = computed({
|
|
18
|
+
get: () => {
|
|
19
|
+
return (isRef(object) ? object.value : object)[key];
|
|
20
|
+
},
|
|
21
|
+
set(v) {
|
|
22
|
+
(isRef(object) ? object.value : object)[key] = v;
|
|
23
|
+
afterSet(key, v);
|
|
24
|
+
}
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
function emitFieldSet(object, emitSet) {
|
|
31
|
+
const keys = Object.keys(isRef(object) ? object.value : object);
|
|
32
|
+
const result = {};
|
|
33
|
+
let cacheData = {};
|
|
34
|
+
keys.forEach((key) => {
|
|
35
|
+
result[key] = computed({
|
|
36
|
+
get: () => {
|
|
37
|
+
cacheData = {};
|
|
38
|
+
return (isRef(object) ? object.value : object)[key];
|
|
39
|
+
},
|
|
40
|
+
set(v) {
|
|
41
|
+
const objVal = isRef(object) ? object.value : object;
|
|
42
|
+
cacheData[key] = v;
|
|
43
|
+
const newObj = { ...objVal, ...cacheData };
|
|
44
|
+
emitSet(key, v, newObj);
|
|
45
|
+
}
|
|
46
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
return result;
|
|
50
|
+
}
|
|
51
|
+
function parseValueUnit(str) {
|
|
52
|
+
if (str === "nullpx") {
|
|
53
|
+
return {
|
|
54
|
+
value: 0,
|
|
55
|
+
unit: "px"
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
const regex = /^(\d+\.?\d*)([a-zA-Z%]+)$/;
|
|
59
|
+
const match = str.match(regex);
|
|
60
|
+
if (match) {
|
|
61
|
+
return {
|
|
62
|
+
value: parseFloat(match[1]),
|
|
63
|
+
unit: match[2]
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
throw new Error("Invalid value");
|
|
67
|
+
}
|
|
68
|
+
function computedEx(opts) {
|
|
69
|
+
const result = ref();
|
|
70
|
+
let clear;
|
|
71
|
+
const watchDeep = () => {
|
|
72
|
+
if (!opts.deep) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
clear = watch(
|
|
76
|
+
() => result.value,
|
|
77
|
+
(v) => {
|
|
78
|
+
opts.set(v);
|
|
79
|
+
},
|
|
80
|
+
{ deep: true }
|
|
81
|
+
);
|
|
82
|
+
};
|
|
83
|
+
watch(
|
|
84
|
+
() => opts.get(),
|
|
85
|
+
(v) => {
|
|
86
|
+
if (clear) {
|
|
87
|
+
clear();
|
|
88
|
+
}
|
|
89
|
+
result.value = v;
|
|
90
|
+
watchDeep();
|
|
91
|
+
},
|
|
92
|
+
{ immediate: true }
|
|
93
|
+
);
|
|
94
|
+
return result;
|
|
95
|
+
}
|
|
96
|
+
function cacheFnReturn(cb) {
|
|
97
|
+
const cacheReturn = /* @__PURE__ */ new Map();
|
|
98
|
+
return function(...args) {
|
|
99
|
+
const key = JSON.stringify(args);
|
|
100
|
+
if (cacheReturn.has(key)) {
|
|
101
|
+
return cacheReturn.get(key);
|
|
102
|
+
}
|
|
103
|
+
const result = cb(...args);
|
|
104
|
+
cacheReturn.set(key, result);
|
|
105
|
+
return result;
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export { afterFieldSet, afterValueSet, cacheFnReturn, computedEx, emitFieldSet, parseValueUnit };
|