custom-variant-form 2.2.9
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/README.md +202 -0
- package/babel.config.js +5 -0
- package/index_template/index_dev.html +19 -0
- package/index_template/index_prod.html +28 -0
- package/install-render.js +29 -0
- package/install.js +41 -0
- package/jsconfig.json +10 -0
- package/license.txt +8 -0
- package/package.json +56 -0
- package/public/favicon.ico +0 -0
- package/public/index.html +19 -0
- package/src/App.vue +45 -0
- package/src/assets/ft-images/t1.png +0 -0
- package/src/assets/ft-images/t2.png +0 -0
- package/src/assets/ft-images/t3.png +0 -0
- package/src/assets/ft-images/t4.png +0 -0
- package/src/assets/ft-images/t5.png +0 -0
- package/src/assets/ft-images/t6.png +0 -0
- package/src/assets/ft-images/t7.png +0 -0
- package/src/assets/ft-images/t8.png +0 -0
- package/src/assets/vform-logo.png +0 -0
- package/src/components/code-editor/index.vue +134 -0
- package/src/components/form-designer/designer.js +962 -0
- package/src/components/form-designer/form-widget/container-widget/container-wrapper.vue +107 -0
- package/src/components/form-designer/form-widget/container-widget/containerMixin.js +93 -0
- package/src/components/form-designer/form-widget/container-widget/grid-col-widget.vue +314 -0
- package/src/components/form-designer/form-widget/container-widget/grid-widget.vue +93 -0
- package/src/components/form-designer/form-widget/container-widget/index.js +24 -0
- package/src/components/form-designer/form-widget/container-widget/tab-widget.vue +123 -0
- package/src/components/form-designer/form-widget/container-widget/table-cell-widget.vue +347 -0
- package/src/components/form-designer/form-widget/container-widget/table-widget.vue +116 -0
- package/src/components/form-designer/form-widget/field-widget/button-widget.vue +87 -0
- package/src/components/form-designer/form-widget/field-widget/cascader-widget.vue +120 -0
- package/src/components/form-designer/form-widget/field-widget/checkbox-widget.vue +105 -0
- package/src/components/form-designer/form-widget/field-widget/color-widget.vue +99 -0
- package/src/components/form-designer/form-widget/field-widget/date-range-widget.vue +104 -0
- package/src/components/form-designer/form-widget/field-widget/date-widget.vue +103 -0
- package/src/components/form-designer/form-widget/field-widget/divider-widget.vue +83 -0
- package/src/components/form-designer/form-widget/field-widget/fieldMixin.js +613 -0
- package/src/components/form-designer/form-widget/field-widget/file-upload-widget.vue +313 -0
- package/src/components/form-designer/form-widget/field-widget/form-item-wrapper.vue +331 -0
- package/src/components/form-designer/form-widget/field-widget/html-text-widget.vue +82 -0
- package/src/components/form-designer/form-widget/field-widget/index.js +10 -0
- package/src/components/form-designer/form-widget/field-widget/input-widget.vue +112 -0
- package/src/components/form-designer/form-widget/field-widget/number-widget.vue +103 -0
- package/src/components/form-designer/form-widget/field-widget/picture-upload-widget.vue +280 -0
- package/src/components/form-designer/form-widget/field-widget/radio-widget.vue +105 -0
- package/src/components/form-designer/form-widget/field-widget/rate-widget.vue +102 -0
- package/src/components/form-designer/form-widget/field-widget/rich-editor-widget.vue +123 -0
- package/src/components/form-designer/form-widget/field-widget/select-widget.vue +123 -0
- package/src/components/form-designer/form-widget/field-widget/slider-widget.vue +100 -0
- package/src/components/form-designer/form-widget/field-widget/slot-widget.vue +102 -0
- package/src/components/form-designer/form-widget/field-widget/static-content-wrapper.vue +196 -0
- package/src/components/form-designer/form-widget/field-widget/static-text-widget.vue +83 -0
- package/src/components/form-designer/form-widget/field-widget/switch-widget.vue +101 -0
- package/src/components/form-designer/form-widget/field-widget/textarea-widget.vue +99 -0
- package/src/components/form-designer/form-widget/field-widget/time-range-widget.vue +104 -0
- package/src/components/form-designer/form-widget/field-widget/time-widget.vue +103 -0
- package/src/components/form-designer/form-widget/index.vue +272 -0
- package/src/components/form-designer/index.vue +500 -0
- package/src/components/form-designer/refMixinDesign.js +28 -0
- package/src/components/form-designer/setting-panel/form-setting.vue +354 -0
- package/src/components/form-designer/setting-panel/index.vue +367 -0
- package/src/components/form-designer/setting-panel/option-items-setting.vue +234 -0
- package/src/components/form-designer/setting-panel/property-editor/allowCreate-editor.vue +24 -0
- package/src/components/form-designer/setting-panel/property-editor/appendButton-editor.vue +28 -0
- package/src/components/form-designer/setting-panel/property-editor/appendButtonDisabled-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/automaticDropdown-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/border-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/buttonIcon-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/buttonStyle-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/clearable-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/columnWidth-editor.vue +26 -0
- package/src/components/form-designer/setting-panel/property-editor/container-grid/colHeight-editor.vue +28 -0
- package/src/components/form-designer/setting-panel/property-editor/container-grid/gutter-editor.vue +81 -0
- package/src/components/form-designer/setting-panel/property-editor/container-grid-col/grid-col-offset-editor.vue +24 -0
- package/src/components/form-designer/setting-panel/property-editor/container-grid-col/grid-col-pull-editor.vue +24 -0
- package/src/components/form-designer/setting-panel/property-editor/container-grid-col/grid-col-push-editor.vue +24 -0
- package/src/components/form-designer/setting-panel/property-editor/container-grid-col/grid-col-responsive-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/container-grid-col/grid-col-span-editor.vue +48 -0
- package/src/components/form-designer/setting-panel/property-editor/container-sub-form/showBlankRow-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/container-sub-form/showRowNumber-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/container-sub-form/sub-form-labelAlign-editor.vue +36 -0
- package/src/components/form-designer/setting-panel/property-editor/container-tab/tab-customClass-editor.vue +119 -0
- package/src/components/form-designer/setting-panel/property-editor/container-table-cell/cellHeight-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/container-table-cell/cellWidth-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/container-table-cell/wordBreak-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/customClass-editor.vue +40 -0
- package/src/components/form-designer/setting-panel/property-editor/defaultValue-editor.vue +25 -0
- package/src/components/form-designer/setting-panel/property-editor/disabled-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/displayStyle-editor.vue +26 -0
- package/src/components/form-designer/setting-panel/property-editor/editable-editor.vue +24 -0
- package/src/components/form-designer/setting-panel/property-editor/endPlaceholder-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/event-handler/eventMixin.js +12 -0
- package/src/components/form-designer/setting-panel/property-editor/event-handler/onAppendButtonClick-editor.vue +30 -0
- package/src/components/form-designer/setting-panel/property-editor/event-handler/onBeforeUpload-editor.vue +30 -0
- package/src/components/form-designer/setting-panel/property-editor/event-handler/onBlur-editor.vue +30 -0
- package/src/components/form-designer/setting-panel/property-editor/event-handler/onChange-editor.vue +30 -0
- package/src/components/form-designer/setting-panel/property-editor/event-handler/onClick-editor.vue +30 -0
- package/src/components/form-designer/setting-panel/property-editor/event-handler/onCreated-editor.vue +31 -0
- package/src/components/form-designer/setting-panel/property-editor/event-handler/onFileRemove.vue +30 -0
- package/src/components/form-designer/setting-panel/property-editor/event-handler/onFocus-editor.vue +30 -0
- package/src/components/form-designer/setting-panel/property-editor/event-handler/onInput-editor.vue +30 -0
- package/src/components/form-designer/setting-panel/property-editor/event-handler/onMounted-editor.vue +30 -0
- package/src/components/form-designer/setting-panel/property-editor/event-handler/onRemoteQuery-editor.vue +30 -0
- package/src/components/form-designer/setting-panel/property-editor/event-handler/onSubFormRowAdd-editor.vue +30 -0
- package/src/components/form-designer/setting-panel/property-editor/event-handler/onSubFormRowChange-editor.vue +30 -0
- package/src/components/form-designer/setting-panel/property-editor/event-handler/onSubFormRowDelete-editor.vue +30 -0
- package/src/components/form-designer/setting-panel/property-editor/event-handler/onSubFormRowInsert-editor.vue +30 -0
- package/src/components/form-designer/setting-panel/property-editor/event-handler/onUploadError-editor.vue +30 -0
- package/src/components/form-designer/setting-panel/property-editor/event-handler/onUploadSuccess-editor.vue +30 -0
- package/src/components/form-designer/setting-panel/property-editor/event-handler/onValidate-editor.vue +30 -0
- package/src/components/form-designer/setting-panel/property-editor/field-button/button-type-editor.vue +32 -0
- package/src/components/form-designer/setting-panel/property-editor/field-button/circle-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/field-button/icon-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/field-button/plain-editor.vue +24 -0
- package/src/components/form-designer/setting-panel/property-editor/field-button/round-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/field-cascader/cascader-defaultValue-editor.vue +18 -0
- package/src/components/form-designer/setting-panel/property-editor/field-cascader/cascader-multiple-editor.vue +24 -0
- package/src/components/form-designer/setting-panel/property-editor/field-cascader/checkStrictly-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/field-cascader/showAllLevels-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/field-checkbox/checkbox-defaultValue-editor.vue +18 -0
- package/src/components/form-designer/setting-panel/property-editor/field-color/color-defaultValue-editor.vue +25 -0
- package/src/components/form-designer/setting-panel/property-editor/field-date/date-defaultValue-editor.vue +26 -0
- package/src/components/form-designer/setting-panel/property-editor/field-date/date-format-editor.vue +30 -0
- package/src/components/form-designer/setting-panel/property-editor/field-date/date-type-editor.vue +30 -0
- package/src/components/form-designer/setting-panel/property-editor/field-date/date-valueFormat-editor.vue +26 -0
- package/src/components/form-designer/setting-panel/property-editor/field-date-range/date-range-defaultValue-editor.vue +26 -0
- package/src/components/form-designer/setting-panel/property-editor/field-date-range/date-range-format-editor.vue +30 -0
- package/src/components/form-designer/setting-panel/property-editor/field-date-range/date-range-type-editor.vue +27 -0
- package/src/components/form-designer/setting-panel/property-editor/field-date-range/date-range-valueFormat-editor.vue +26 -0
- package/src/components/form-designer/setting-panel/property-editor/field-divider/contentPosition-editor.vue +27 -0
- package/src/components/form-designer/setting-panel/property-editor/field-file-upload/file-upload-fileTypes-editor.vue +44 -0
- package/src/components/form-designer/setting-panel/property-editor/field-html-text/htmlContent-editor.vue +29 -0
- package/src/components/form-designer/setting-panel/property-editor/field-number/controlsPosition-editor.vue +27 -0
- package/src/components/form-designer/setting-panel/property-editor/field-picture-upload/picture-upload-fileTypes-editor.vue +44 -0
- package/src/components/form-designer/setting-panel/property-editor/field-radio/radio-defaultValue-editor.vue +18 -0
- package/src/components/form-designer/setting-panel/property-editor/field-rate/allowHalf-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/field-rate/highThreshold-editor.vue +24 -0
- package/src/components/form-designer/setting-panel/property-editor/field-rate/lowThreshold-editor.vue +24 -0
- package/src/components/form-designer/setting-panel/property-editor/field-rate/rate-defaultValue-editor.vue +26 -0
- package/src/components/form-designer/setting-panel/property-editor/field-rate/rate-max-editor.vue +25 -0
- package/src/components/form-designer/setting-panel/property-editor/field-rate/showScore-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/field-rate/showText-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/field-select/select-defaultValue-editor.vue +18 -0
- package/src/components/form-designer/setting-panel/property-editor/field-slider/range-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/field-slider/showStops-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/field-slider/vertical-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/field-static-text/fontSize-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/field-static-text/preWrap-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/field-static-text/textContent-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/field-switch/activeColor-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/field-switch/activeText-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/field-switch/inactiveColor-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/field-switch/inactiveText-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/field-switch/switch-defaultValue-editor.vue +25 -0
- package/src/components/form-designer/setting-panel/property-editor/field-switch/switchWidth-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/field-time/time-defaultValue-editor.vue +26 -0
- package/src/components/form-designer/setting-panel/property-editor/field-time/time-format-editor.vue +27 -0
- package/src/components/form-designer/setting-panel/property-editor/field-time-range/time-range-defaultValue-editor.vue +26 -0
- package/src/components/form-designer/setting-panel/property-editor/field-time-range/time-range-format-editor.vue +27 -0
- package/src/components/form-designer/setting-panel/property-editor/fileMaxSize-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/filterable-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/hidden-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/index.js +10 -0
- package/src/components/form-designer/setting-panel/property-editor/label-editor.vue +30 -0
- package/src/components/form-designer/setting-panel/property-editor/labelAlign-editor.vue +42 -0
- package/src/components/form-designer/setting-panel/property-editor/labelHidden-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/labelIconClass-editor.vue +28 -0
- package/src/components/form-designer/setting-panel/property-editor/labelIconPosition-editor.vue +37 -0
- package/src/components/form-designer/setting-panel/property-editor/labelTooltip-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/labelWidth-editor.vue +25 -0
- package/src/components/form-designer/setting-panel/property-editor/limit-editor.vue +24 -0
- package/src/components/form-designer/setting-panel/property-editor/max-editor.vue +39 -0
- package/src/components/form-designer/setting-panel/property-editor/maxLength-editor.vue +40 -0
- package/src/components/form-designer/setting-panel/property-editor/min-editor.vue +40 -0
- package/src/components/form-designer/setting-panel/property-editor/minLength-editor.vue +41 -0
- package/src/components/form-designer/setting-panel/property-editor/multiple-editor.vue +24 -0
- package/src/components/form-designer/setting-panel/property-editor/multipleLimit-editor.vue +24 -0
- package/src/components/form-designer/setting-panel/property-editor/multipleSelect-editor.vue +24 -0
- package/src/components/form-designer/setting-panel/property-editor/name-editor.vue +89 -0
- package/src/components/form-designer/setting-panel/property-editor/optionItems-editor.vue +28 -0
- package/src/components/form-designer/setting-panel/property-editor/placeholder-editor.vue +24 -0
- package/src/components/form-designer/setting-panel/property-editor/precision-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/prefixIcon-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/propertyMixin.js +55 -0
- package/src/components/form-designer/setting-panel/property-editor/readonly-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/remote-editor.vue +25 -0
- package/src/components/form-designer/setting-panel/property-editor/required-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/requiredHint-editor.vue +24 -0
- package/src/components/form-designer/setting-panel/property-editor/rows-editor.vue +24 -0
- package/src/components/form-designer/setting-panel/property-editor/showFileList-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/showPassword-editor.vue +24 -0
- package/src/components/form-designer/setting-panel/property-editor/showWordLimit-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/size-editor.vue +38 -0
- package/src/components/form-designer/setting-panel/property-editor/startPlaceholder-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/step-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/suffixIcon-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/textAlign-editor.vue +35 -0
- package/src/components/form-designer/setting-panel/property-editor/type-editor.vue +33 -0
- package/src/components/form-designer/setting-panel/property-editor/uploadTip-editor.vue +24 -0
- package/src/components/form-designer/setting-panel/property-editor/uploadURL-editor.vue +28 -0
- package/src/components/form-designer/setting-panel/property-editor/validation-editor.vue +48 -0
- package/src/components/form-designer/setting-panel/property-editor/validationHint-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor/withCredentials-editor.vue +23 -0
- package/src/components/form-designer/setting-panel/property-editor-factory.js +173 -0
- package/src/components/form-designer/setting-panel/propertyRegister.js +215 -0
- package/src/components/form-designer/toolbar-panel/index.vue +886 -0
- package/src/components/form-designer/widget-panel/index.vue +394 -0
- package/src/components/form-designer/widget-panel/templatesConfig.js +58 -0
- package/src/components/form-designer/widget-panel/widgetsConfig.js +934 -0
- package/src/components/form-render/container-item/container-item-wrapper.vue +37 -0
- package/src/components/form-render/container-item/containerItemMixin.js +221 -0
- package/src/components/form-render/container-item/grid-col-item.vue +126 -0
- package/src/components/form-render/container-item/grid-item.vue +59 -0
- package/src/components/form-render/container-item/index.js +24 -0
- package/src/components/form-render/container-item/sub-form-item.vue +417 -0
- package/src/components/form-render/container-item/tab-item.vue +99 -0
- package/src/components/form-render/container-item/table-cell-item.vue +72 -0
- package/src/components/form-render/container-item/table-item.vue +70 -0
- package/src/components/form-render/index.vue +721 -0
- package/src/components/form-render/refMixin.js +30 -0
- package/src/components/svg-icon/index.vue +49 -0
- package/src/components/v-table/index.vue +106 -0
- package/src/extension/components/tag/index.js +9 -0
- package/src/extension/components/tag/tag-item.vue +49 -0
- package/src/extension/components/tag/tag-schema.js +33 -0
- package/src/extension/components/tag/tag-widget.vue +53 -0
- package/src/extension/extension-helper.js +23 -0
- package/src/extension/extension-loader.js +174 -0
- package/src/extension/samples/alert/alert-widget.vue +72 -0
- package/src/extension/samples/card/card-item.vue +100 -0
- package/src/extension/samples/card/card-widget.vue +132 -0
- package/src/extension/samples/extension-schema.js +36 -0
- package/src/extension/samples/extension-sfc-generator.js +50 -0
- package/src/iconfont/iconfont.css +29 -0
- package/src/iconfont/iconfont.eot +0 -0
- package/src/iconfont/iconfont.js +1 -0
- package/src/iconfont/iconfont.json +37 -0
- package/src/iconfont/iconfont.svg +35 -0
- package/src/iconfont/iconfont.ttf +0 -0
- package/src/iconfont/iconfont.woff +0 -0
- package/src/iconfont/iconfont.woff2 +0 -0
- package/src/icons/index.js +3 -0
- package/src/icons/svg/alert.svg +1 -0
- package/src/icons/svg/button.svg +1 -0
- package/src/icons/svg/card.svg +1 -0
- package/src/icons/svg/cascader-field.svg +1 -0
- package/src/icons/svg/checkbox-field.svg +1 -0
- package/src/icons/svg/color-field.svg +1 -0
- package/src/icons/svg/custom-component.svg +1 -0
- package/src/icons/svg/data-table.svg +1 -0
- package/src/icons/svg/date-field.svg +1 -0
- package/src/icons/svg/date-range-field.svg +1 -0
- package/src/icons/svg/divider.svg +1 -0
- package/src/icons/svg/document.svg +1 -0
- package/src/icons/svg/drag.svg +1 -0
- package/src/icons/svg/file-upload-field.svg +1 -0
- package/src/icons/svg/github.svg +1 -0
- package/src/icons/svg/grid.svg +1 -0
- package/src/icons/svg/html-text.svg +1 -0
- package/src/icons/svg/node-tree.svg +1 -0
- package/src/icons/svg/number-field.svg +1 -0
- package/src/icons/svg/picture-upload-field.svg +1 -0
- package/src/icons/svg/radio-field.svg +1 -0
- package/src/icons/svg/rate-field.svg +1 -0
- package/src/icons/svg/redo.svg +1 -0
- package/src/icons/svg/rich-editor-field.svg +1 -0
- package/src/icons/svg/section.svg +1 -0
- package/src/icons/svg/select-field.svg +1 -0
- package/src/icons/svg/slider-field.svg +1 -0
- package/src/icons/svg/slot-component.svg +1 -0
- package/src/icons/svg/slot-field.svg +1 -0
- package/src/icons/svg/static-text.svg +1 -0
- package/src/icons/svg/sub-form.svg +1 -0
- package/src/icons/svg/switch-field.svg +1 -0
- package/src/icons/svg/tab.svg +1 -0
- package/src/icons/svg/table.svg +1 -0
- package/src/icons/svg/tag-field.svg +4 -0
- package/src/icons/svg/text-field.svg +1 -0
- package/src/icons/svg/textarea-field.svg +1 -0
- package/src/icons/svg/time-field.svg +1 -0
- package/src/icons/svg/time-range-field.svg +1 -0
- package/src/icons/svg/undo.svg +1 -0
- package/src/icons/svg/vue-sfc.svg +1 -0
- package/src/lang/en-US.js +354 -0
- package/src/lang/en-US_extension.js +35 -0
- package/src/lang/en-US_render.js +38 -0
- package/src/lang/zh-CN.js +354 -0
- package/src/lang/zh-CN_extension.js +35 -0
- package/src/lang/zh-CN_render.js +38 -0
- package/src/main.js +29 -0
- package/src/styles/global.scss +108 -0
- package/src/styles/index.scss +15 -0
- package/src/utils/beautifierLoader.js +77 -0
- package/src/utils/code-generator.js +91 -0
- package/src/utils/config.js +9 -0
- package/src/utils/debug-console.js +7 -0
- package/src/utils/directive.js +74 -0
- package/src/utils/emitter.js +34 -0
- package/src/utils/format.js +214 -0
- package/src/utils/i18n.js +95 -0
- package/src/utils/sfc-generator.js +583 -0
- package/src/utils/smart-vue-i18n/index.js +56 -0
- package/src/utils/smart-vue-i18n/utils.js +47 -0
- package/src/utils/util.js +376 -0
- package/src/utils/validators.js +127 -0
- package/src/utils/vue2js-generator.js +144 -0
- package/src/utils/vue3js-generator.js +70 -0
- package/vue.config.js +93 -0
package/README.md
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
# Variant Form
|
|
2
|
+
#### 一款高效的Vue低代码表单,可视化设计,一键生成源码,享受更多摸鱼时间。
|
|
3
|
+
|
|
4
|
+

|
|
5
|
+
|
|
6
|
+
<br/>
|
|
7
|
+
|
|
8
|
+
### 立即体验
|
|
9
|
+
[在线Demo](http://120.92.142.115/)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### 🎉🎉<mark>基于VForm的全栈低代码平台已发布</mark>🎉🎉
|
|
13
|
+

|
|
14
|
+
<br/>
|
|
15
|
+
[美乐低代码——立即进入](https://melecode.com/) (私有部署、开箱即用️,已开源✌✌)️
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### 立即体验VForm Pro高级版(提供商业支持)
|
|
19
|
+
[Pro Demo](https://www.vform666.com/pro/)
|
|
20
|
+
|
|
21
|
+
### 视频教程集合:
|
|
22
|
+
[B站观看](https://space.bilibili.com/626932375)
|
|
23
|
+
|
|
24
|
+
### Vue 3正式版已发布
|
|
25
|
+
[立即进入](https://gitee.com/vdpadmin/variant-form3-vite)
|
|
26
|
+
|
|
27
|
+
### 🎉🎉基于Vant组件库的Mobile版本已发布🎉🎉
|
|
28
|
+
[立即进入](https://vform666.com/vform-mobile.html)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### 友情链接
|
|
32
|
+
|
|
33
|
+
[Fantastic-admin](https://hooray.gitee.io/fantastic-admin/) —— 一款开箱即用的 Vue 中后台管理系统框架(支持Vue2/Vue3)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
<br/>
|
|
37
|
+
|
|
38
|
+
### 功能一览
|
|
39
|
+
```
|
|
40
|
+
> 拖拽式可视化表单设计;
|
|
41
|
+
> 支持PC、Pad、H5三种布局;
|
|
42
|
+
> 支持运行时动态加载表单;
|
|
43
|
+
> 支持表单复杂交互控制;
|
|
44
|
+
> 支持自定义CSS样式;
|
|
45
|
+
> 支持自定义校验逻辑;
|
|
46
|
+
> 支持国际化多语言;
|
|
47
|
+
> 兼容IE 11浏览器;
|
|
48
|
+
> 可导出Vue组件、HTML源码;
|
|
49
|
+
> 可导出Vue的SFC单文件组件;
|
|
50
|
+
> 支持开发自定义组件;
|
|
51
|
+
> 支持响应式自适应布局;
|
|
52
|
+
> 支持VS Code插件;
|
|
53
|
+
> 更多功能等你探究...;
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### 安装依赖
|
|
57
|
+
```
|
|
58
|
+
npm install --registry=https://registry.npmmirror.com
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### 开发调试
|
|
62
|
+
```
|
|
63
|
+
npm run serve
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### 生产打包
|
|
67
|
+
```
|
|
68
|
+
npm run build
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### 表单设计器 + 表单渲染器打包
|
|
72
|
+
```
|
|
73
|
+
npm run lib
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### 表单渲染器打包
|
|
77
|
+
```
|
|
78
|
+
npm run lib-render
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### 浏览器兼容性
|
|
82
|
+
```Chrome(及同内核的浏览器如QQ浏览器、360浏览器等等),Edge, Firefox,Safari,IE 11```
|
|
83
|
+
|
|
84
|
+
<br/>
|
|
85
|
+
|
|
86
|
+
### 跟Vue项目集成
|
|
87
|
+
|
|
88
|
+
<br/>
|
|
89
|
+
|
|
90
|
+
#### 1. 安装包
|
|
91
|
+
```bash
|
|
92
|
+
npm i vform-builds
|
|
93
|
+
```
|
|
94
|
+
或
|
|
95
|
+
```bash
|
|
96
|
+
yarn add vform-builds
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
<br/>
|
|
100
|
+
|
|
101
|
+
#### 2. 引入并全局注册VForm组件
|
|
102
|
+
```javascript
|
|
103
|
+
import Vue from 'vue'
|
|
104
|
+
import App from './App.vue'
|
|
105
|
+
|
|
106
|
+
import ElementUI from 'element-ui' //引入element-ui库
|
|
107
|
+
import VForm from 'vform-builds' //引入VForm库
|
|
108
|
+
|
|
109
|
+
import 'element-ui/lib/theme-chalk/index.css' //引入element-ui样式
|
|
110
|
+
import 'vform-builds/dist/VFormDesigner.css' //引入VForm样式
|
|
111
|
+
|
|
112
|
+
Vue.config.productionTip = false
|
|
113
|
+
|
|
114
|
+
Vue.use(ElementUI) //全局注册element-ui
|
|
115
|
+
Vue.use(VForm) //全局注册VForm(同时注册了v-form-designer和v-form-render组件)
|
|
116
|
+
|
|
117
|
+
new Vue({
|
|
118
|
+
render: h => h(App),
|
|
119
|
+
}).$mount('#app')
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
<br/>
|
|
123
|
+
|
|
124
|
+
#### 3. 在Vue模板中使用表单设计器组件
|
|
125
|
+
```html
|
|
126
|
+
<template>
|
|
127
|
+
<v-form-designer></v-form-designer>
|
|
128
|
+
</template>
|
|
129
|
+
|
|
130
|
+
<script>
|
|
131
|
+
export default {
|
|
132
|
+
data() {
|
|
133
|
+
return {
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
</script>
|
|
138
|
+
|
|
139
|
+
<style lang="scss">
|
|
140
|
+
body {
|
|
141
|
+
margin: 0; /* 如果页面出现垂直滚动条,则加入此行CSS以消除之 */
|
|
142
|
+
}
|
|
143
|
+
</style>
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
<br/>
|
|
147
|
+
|
|
148
|
+
#### 4. 在Vue模板中使用表单渲染器组件
|
|
149
|
+
```html
|
|
150
|
+
<template>
|
|
151
|
+
<div>
|
|
152
|
+
<v-form-render :form-json="formJson" :form-data="formData" :option-data="optionData" ref="vFormRef">
|
|
153
|
+
</v-form-render>
|
|
154
|
+
<el-button type="primary" @click="submitForm">Submit</el-button>
|
|
155
|
+
</div>
|
|
156
|
+
</template>
|
|
157
|
+
<script>
|
|
158
|
+
export default {
|
|
159
|
+
data() {
|
|
160
|
+
return {
|
|
161
|
+
formJson: {"widgetList":[],"formConfig":{"labelWidth":80,"labelPosition":"left","size":"","labelAlign":"label-left-align","cssCode":"","customClass":"","functions":"","layoutType":"PC","onFormCreated":"","onFormMounted":"","onFormDataChange":""}},
|
|
162
|
+
formData: {},
|
|
163
|
+
optionData: {}
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
methods: {
|
|
167
|
+
submitForm() {
|
|
168
|
+
this.$refs.vFormRef.getFormData().then(formData => {
|
|
169
|
+
// Form Validation OK
|
|
170
|
+
alert( JSON.stringify(formData) )
|
|
171
|
+
}).catch(error => {
|
|
172
|
+
// Form Validation failed
|
|
173
|
+
this.$message.error(error)
|
|
174
|
+
})
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
</script>
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
<br/>
|
|
182
|
+
|
|
183
|
+
### 资源链接
|
|
184
|
+
<hr>
|
|
185
|
+
|
|
186
|
+
文档官网:<a href="https://www.vform666.com/" target="_blank">https://www.vform666.com/</a>
|
|
187
|
+
|
|
188
|
+
在线演示:<a href="http://120.92.142.115/" target="_blank">http://120.92.142.115/</a>
|
|
189
|
+
|
|
190
|
+
Gitee仓库:<a href="https://gitee.com/vdpadmin/variant-form" target="_blank">https://gitee.com/vdpadmin/variant-form</a>
|
|
191
|
+
|
|
192
|
+
Github仓库:<a href="https://github.com/vform666/variant-form" target="_blank">https://github.com/vform666/variant-form</a>
|
|
193
|
+
|
|
194
|
+
VS Code插件:<a href="https://www.vform666.com/plugin/" target="_blank">https://www.vform666.com/plugin/</a>
|
|
195
|
+
|
|
196
|
+
更新日志:<a href="https://www.vform666.com/changelog.html" target="_blank">https://www.vform666.com/changelog.html</a>
|
|
197
|
+
|
|
198
|
+
订阅Pro版:<a href="https://www.vform666.com/pro/" target="_blank">https://www.vform666.com/pro/</a>
|
|
199
|
+
|
|
200
|
+
技术交流群:扫如下二维码加群
|
|
201
|
+
|
|
202
|
+

|
package/babel.config.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
6
|
+
<meta name="renderer" content="webkit">
|
|
7
|
+
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
|
8
|
+
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
|
|
9
|
+
<title><%= htmlWebpackPlugin.options.title %></title>
|
|
10
|
+
</head>
|
|
11
|
+
<body>
|
|
12
|
+
<noscript>
|
|
13
|
+
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
|
|
14
|
+
</noscript>
|
|
15
|
+
|
|
16
|
+
<div id="app"></div>
|
|
17
|
+
<!-- built files will be auto injected -->
|
|
18
|
+
</body>
|
|
19
|
+
</html>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
6
|
+
<meta name="renderer" content="webkit">
|
|
7
|
+
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
|
8
|
+
<!-- 禁止浏览器缓存index.html begin -->
|
|
9
|
+
<meta http-equiv="Expires" content="0">
|
|
10
|
+
<meta http-equiv="Pragma" content="no-cache">
|
|
11
|
+
<meta http-equiv="Cache-control" content="no-cache">
|
|
12
|
+
<meta http-equiv="Cache" content="no-cache">
|
|
13
|
+
<!-- 禁止浏览器缓存index.html end -->
|
|
14
|
+
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
|
|
15
|
+
<title><%= htmlWebpackPlugin.options.title %></title>
|
|
16
|
+
<link rel="stylesheet" href="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/element-ui/2.15.7/theme-chalk/index.min.css">
|
|
17
|
+
</head>
|
|
18
|
+
<body>
|
|
19
|
+
<noscript>
|
|
20
|
+
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
|
|
21
|
+
</noscript>
|
|
22
|
+
<div id="app"></div>
|
|
23
|
+
<!-- built files will be auto injected -->
|
|
24
|
+
|
|
25
|
+
<script src="https://lf26-cdn-tos.bytecdntp.com/cdn/expire-1-M/vue/2.6.14/vue.min.js"></script>
|
|
26
|
+
<script src="https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/element-ui/2.15.7/index.min.js"></script>
|
|
27
|
+
</body>
|
|
28
|
+
</html>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import VFormRender from '@/components/form-render/index.vue'
|
|
2
|
+
import {loadExtension} from "@/extension/extension-loader"
|
|
3
|
+
import axios from "axios"
|
|
4
|
+
|
|
5
|
+
loadExtension()
|
|
6
|
+
|
|
7
|
+
VFormRender.install = function (Vue) {
|
|
8
|
+
Vue.component(VFormRender.name, VFormRender)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const components = [
|
|
12
|
+
VFormRender
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
const install = (Vue) => {
|
|
16
|
+
window.axios = axios
|
|
17
|
+
components.forEach(component => {
|
|
18
|
+
Vue.component(component.name, component)
|
|
19
|
+
})
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (typeof window !== 'undefined' && window.Vue) { /* script方式引入时主动调用install方法!! */
|
|
23
|
+
install(window.Vue);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default {
|
|
27
|
+
install,
|
|
28
|
+
VFormRender
|
|
29
|
+
}
|
package/install.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import axios from 'axios'
|
|
2
|
+
|
|
3
|
+
import VFormDesigner from '@/components/form-designer/index.vue'
|
|
4
|
+
import VFormRender from '@/components/form-render/index.vue'
|
|
5
|
+
import {loadExtension} from "@/extension/extension-loader"
|
|
6
|
+
|
|
7
|
+
import '@/utils/directive'
|
|
8
|
+
import '@/icons'
|
|
9
|
+
import '@/iconfont/iconfont.css'
|
|
10
|
+
|
|
11
|
+
loadExtension()
|
|
12
|
+
|
|
13
|
+
VFormDesigner.install = function (Vue) {
|
|
14
|
+
Vue.component(VFormDesigner.name, VFormDesigner)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
VFormRender.install = function (Vue) {
|
|
18
|
+
Vue.component(VFormRender.name, VFormRender)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const components = [
|
|
22
|
+
VFormDesigner,
|
|
23
|
+
VFormRender
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
const install = (Vue) => {
|
|
27
|
+
window.axios = axios
|
|
28
|
+
components.forEach(component => {
|
|
29
|
+
Vue.component(component.name, component)
|
|
30
|
+
})
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (typeof window !== 'undefined' && window.Vue) { /* script方式引入时主动调用install方法!! */
|
|
34
|
+
install(window.Vue);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export default {
|
|
38
|
+
install,
|
|
39
|
+
VFormDesigner,
|
|
40
|
+
VFormRender
|
|
41
|
+
}
|
package/jsconfig.json
ADDED
package/license.txt
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Variant Form 许可条款 1.0
|
|
2
|
+
|
|
3
|
+
1. 免责声明:任何情况下根据任何法律,本作者不对用户因使用VariantForm产生的侵权、数据损坏丢失、软硬件故障和违法犯罪等问题承担任何责任;
|
|
4
|
+
2. 禁止任何用户对VariantForm进行简单包装后,即声称为自己的产品、销售源码获利;
|
|
5
|
+
3. VariantForm为开源项目,获取到源代码的用户可自由修改源码供自身开发使用,可分发build构建后的库代码,也可分发VariantForm源代码(需保留文件头部的作者声明),本作者保留VariantForm的原始著作权;
|
|
6
|
+
4. 个人或公司用户均可将VariantForm项目应用于商业项目开发,为支持本项目持续开发,请尽量购买VariantForm Pro版源码订阅更新服务;
|
|
7
|
+
5. 如果你不同意本许可条款,请勿使用VariantForm;任何情况下,一旦实际使用VariantForm,则代表你已确定完全同意本许可条款;
|
|
8
|
+
6. 条款内容结束。
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "custom-variant-form",
|
|
3
|
+
"version": "2.2.9",
|
|
4
|
+
"private": false,
|
|
5
|
+
"scripts": {
|
|
6
|
+
"serve": "vue-cli-service serve --open src/main.js",
|
|
7
|
+
"build": "vue-cli-service build --report --dest dist/build",
|
|
8
|
+
"lib": "vue-cli-service build --report --target lib --dest dist/lib --name VFormDesigner install.js",
|
|
9
|
+
"lib-render": "vue-cli-service build --report --target lib --dest dist/lib-render --name VFormRender install-render.js",
|
|
10
|
+
"lint": "vue-cli-service lint"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"axios": "^0.21.1",
|
|
14
|
+
"clipboard": "^2.0.8",
|
|
15
|
+
"core-js": "^3.6.5",
|
|
16
|
+
"element-ui": "^2.15.1",
|
|
17
|
+
"file-saver": "^2.0.5",
|
|
18
|
+
"vue": "^2.6.11",
|
|
19
|
+
"vue2-editor": "^2.10.2",
|
|
20
|
+
"vuedraggable": "^2.24.3"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@vue/cli-plugin-babel": "~4.5.0",
|
|
24
|
+
"@vue/cli-plugin-eslint": "~4.5.0",
|
|
25
|
+
"@vue/cli-service": "~4.5.0",
|
|
26
|
+
"ace-builds": "^1.4.12",
|
|
27
|
+
"babel-eslint": "^10.1.0",
|
|
28
|
+
"babel-polyfill": "^6.26.0",
|
|
29
|
+
"eslint": "^6.7.2",
|
|
30
|
+
"eslint-plugin-vue": "^6.2.2",
|
|
31
|
+
"mvdir": "^1.0.21",
|
|
32
|
+
"sass": "^1.45.1",
|
|
33
|
+
"sass-loader": "^8.0.2",
|
|
34
|
+
"svg-sprite-loader": "^5.2.1",
|
|
35
|
+
"vue-template-compiler": "^2.6.11"
|
|
36
|
+
},
|
|
37
|
+
"eslintConfig": {
|
|
38
|
+
"root": true,
|
|
39
|
+
"env": {
|
|
40
|
+
"node": true
|
|
41
|
+
},
|
|
42
|
+
"extends": [
|
|
43
|
+
"plugin:vue/essential",
|
|
44
|
+
"eslint:recommended"
|
|
45
|
+
],
|
|
46
|
+
"parserOptions": {
|
|
47
|
+
"parser": "babel-eslint"
|
|
48
|
+
},
|
|
49
|
+
"rules": {}
|
|
50
|
+
},
|
|
51
|
+
"browserslist": [
|
|
52
|
+
"> 1%",
|
|
53
|
+
"last 2 versions",
|
|
54
|
+
"not dead"
|
|
55
|
+
]
|
|
56
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
6
|
+
<meta name="renderer" content="webkit">
|
|
7
|
+
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
|
8
|
+
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
|
|
9
|
+
<title><%= htmlWebpackPlugin.options.title %></title>
|
|
10
|
+
</head>
|
|
11
|
+
<body>
|
|
12
|
+
<noscript>
|
|
13
|
+
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
|
|
14
|
+
</noscript>
|
|
15
|
+
|
|
16
|
+
<div id="app"></div>
|
|
17
|
+
<!-- built files will be auto injected -->
|
|
18
|
+
</body>
|
|
19
|
+
</html>
|
package/src/App.vue
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div id="app">
|
|
3
|
+
<VFormDesigner ref="vfDesignerRef" :designer-config="designerConfig" :global-dsv="globalDsv">
|
|
4
|
+
<template #customToolButtons>
|
|
5
|
+
<el-button type="text" @click="printFormJson">测试按钮</el-button>
|
|
6
|
+
</template>
|
|
7
|
+
</VFormDesigner>
|
|
8
|
+
</div>
|
|
9
|
+
</template>
|
|
10
|
+
|
|
11
|
+
<script>
|
|
12
|
+
import VFormDesigner from './components/form-designer/index.vue'
|
|
13
|
+
|
|
14
|
+
export default {
|
|
15
|
+
name: 'App',
|
|
16
|
+
components: {
|
|
17
|
+
VFormDesigner,
|
|
18
|
+
},
|
|
19
|
+
data() {
|
|
20
|
+
return {
|
|
21
|
+
designerConfig: {
|
|
22
|
+
resetFormJson: false,
|
|
23
|
+
toolbarMaxWidth: 490,
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
//全局数据源变量
|
|
27
|
+
globalDsv: {
|
|
28
|
+
testApiHost: 'http://www.test.com/api',
|
|
29
|
+
testPort: 8080,
|
|
30
|
+
},
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
methods: {
|
|
34
|
+
printFormJson() {
|
|
35
|
+
console.log( this.$refs.vfDesignerRef.getFormJson() )
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
</script>
|
|
40
|
+
|
|
41
|
+
<style lang="scss">
|
|
42
|
+
#app {
|
|
43
|
+
height: 100%;
|
|
44
|
+
}
|
|
45
|
+
</style>
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="ace-container">
|
|
3
|
+
<!-- 官方文档中使用id,这里禁止使用,在后期打包后容易出现问题,使用 ref 或者 DOM 就行 -->
|
|
4
|
+
<div class="ace-editor" ref="ace"></div>
|
|
5
|
+
</div>
|
|
6
|
+
</template>
|
|
7
|
+
|
|
8
|
+
<script>
|
|
9
|
+
import ace from 'ace-builds'
|
|
10
|
+
/* 启用此行后webpack打包回生成很多动态加载的js文件,不便于部署,故禁用!!
|
|
11
|
+
特别提示:禁用此行后,需要调用ace.config.set('basePath', 'path...')指定动态js加载URL!!
|
|
12
|
+
*/
|
|
13
|
+
//import 'ace-builds/webpack-resolver'
|
|
14
|
+
|
|
15
|
+
//import 'ace-builds/src-min-noconflict/theme-monokai' // 默认设置的主题
|
|
16
|
+
import 'ace-builds/src-min-noconflict/theme-sqlserver' // 新设主题
|
|
17
|
+
import 'ace-builds/src-min-noconflict/mode-javascript' // 默认设置的语言模式
|
|
18
|
+
import 'ace-builds/src-min-noconflict/mode-json' //
|
|
19
|
+
import 'ace-builds/src-min-noconflict/mode-css' //
|
|
20
|
+
import 'ace-builds/src-min-noconflict/ext-language_tools'
|
|
21
|
+
import {ACE_BASE_PATH} from "@/utils/config";
|
|
22
|
+
|
|
23
|
+
export default {
|
|
24
|
+
name: 'CodeEditor',
|
|
25
|
+
props: {
|
|
26
|
+
value: {
|
|
27
|
+
type: String,
|
|
28
|
+
required: true
|
|
29
|
+
},
|
|
30
|
+
readonly: {
|
|
31
|
+
type: Boolean,
|
|
32
|
+
default: false
|
|
33
|
+
},
|
|
34
|
+
mode: {
|
|
35
|
+
type: String,
|
|
36
|
+
default: 'javascript'
|
|
37
|
+
},
|
|
38
|
+
userWorker: { //是否开启语法检查,默认开启
|
|
39
|
+
type: Boolean,
|
|
40
|
+
default: true
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
},
|
|
44
|
+
mounted() {
|
|
45
|
+
//ace.config.set('basePath', 'https://ks3-cn-beijing.ksyun.com/vform2021/ace')
|
|
46
|
+
ace.config.set('basePath', ACE_BASE_PATH)
|
|
47
|
+
|
|
48
|
+
this.addAutoCompletion(ace) //添加自定义代码提示!!
|
|
49
|
+
|
|
50
|
+
this.aceEditor = ace.edit(this.$refs.ace, {
|
|
51
|
+
maxLines: 20, // 最大行数,超过会自动出现滚动条
|
|
52
|
+
minLines: 5, // 最小行数,还未到最大行数时,编辑器会自动伸缩大小
|
|
53
|
+
fontSize: 12, // 编辑器内字体大小
|
|
54
|
+
theme: this.themePath, // 默认设置的主题
|
|
55
|
+
mode: this.modePath, // 默认设置的语言模式
|
|
56
|
+
tabSize: 2, // 制表符设置为2个空格大小
|
|
57
|
+
readOnly: this.readonly,
|
|
58
|
+
highlightActiveLine: true,
|
|
59
|
+
value: this.codeValue
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
this.aceEditor.setOptions({
|
|
63
|
+
enableBasicAutocompletion: true,
|
|
64
|
+
enableSnippets: true, // 设置代码片段提示
|
|
65
|
+
enableLiveAutocompletion: true, // 设置自动提示
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
if (this.mode === 'json') {
|
|
69
|
+
this.setJsonMode()
|
|
70
|
+
} else if (this.mode === 'css') {
|
|
71
|
+
this.setCssMode()
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (!this.userWorker) {
|
|
75
|
+
this.aceEditor.getSession().setUseWorker(false)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
//编辑时同步数据
|
|
79
|
+
this.aceEditor.getSession().on('change',(ev)=>{
|
|
80
|
+
//this.$emit('update:value', this.aceEditor.getValue()) // 触发更新事件, 实现.sync双向绑定!!
|
|
81
|
+
this.$emit('input', this.aceEditor.getValue())
|
|
82
|
+
})
|
|
83
|
+
},
|
|
84
|
+
data() {
|
|
85
|
+
return {
|
|
86
|
+
aceEditor: null,
|
|
87
|
+
themePath: 'ace/theme/sqlserver', // 不导入 webpack-resolver,该模块路径会报错
|
|
88
|
+
modePath: 'ace/mode/javascript', // 同上
|
|
89
|
+
codeValue: this.value
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
watch: {
|
|
93
|
+
//
|
|
94
|
+
},
|
|
95
|
+
methods: {
|
|
96
|
+
addAutoCompletion(ace) {
|
|
97
|
+
let acData = [
|
|
98
|
+
{meta: 'VForm API', caption: 'getWidgetRef', value: 'getWidgetRef()', score: 1},
|
|
99
|
+
{meta: 'VForm API', caption: 'getFormRef', value: 'getFormRef()', score: 1},
|
|
100
|
+
//TODO: 待补充!!
|
|
101
|
+
]
|
|
102
|
+
let langTools = ace.require('ace/ext/language_tools')
|
|
103
|
+
langTools.addCompleter({
|
|
104
|
+
getCompletions: function(editor, session, pos, prefix, callback) {
|
|
105
|
+
if (prefix.length === 0) {
|
|
106
|
+
return callback(null, []);
|
|
107
|
+
}else {
|
|
108
|
+
return callback(null, acData);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
})
|
|
112
|
+
},
|
|
113
|
+
|
|
114
|
+
setJsonMode() {
|
|
115
|
+
this.aceEditor.getSession().setMode('ace/mode/json')
|
|
116
|
+
},
|
|
117
|
+
|
|
118
|
+
setCssMode() {
|
|
119
|
+
this.aceEditor.getSession().setMode('ace/mode/css')
|
|
120
|
+
},
|
|
121
|
+
|
|
122
|
+
getEditorAnnotations() {
|
|
123
|
+
return this.aceEditor.getSession().getAnnotations()
|
|
124
|
+
},
|
|
125
|
+
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
</script>
|
|
129
|
+
|
|
130
|
+
<style lang="scss" scoped>
|
|
131
|
+
.ace-editor {
|
|
132
|
+
min-height: 300px;
|
|
133
|
+
}
|
|
134
|
+
</style>
|