From 446e62eecd6d8eb5e20b7809bffe879626afd5fd Mon Sep 17 00:00:00 2001 From: RichardMiao Date: Thu, 21 Feb 2019 10:31:49 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E9=87=8D=E6=9E=84=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .editorconfig | 2 +- .prettierrc | 12 +++++ build/webpack.build.config.js | 2 +- examples/post-form/main.js | 52 +++++++++--------- src/{ => components/form}/formGenerator.vue | 0 src/{ => components/form}/formGroup.vue | 59 +++++++++++++-------- src/{ => components/form}/formMixin.js | 0 src/fields/optional/fieldNoUiSlider.vue | 6 ++- src/index.js | 2 +- 9 files changed, 83 insertions(+), 52 deletions(-) create mode 100644 .prettierrc rename src/{ => components/form}/formGenerator.vue (100%) rename src/{ => components/form}/formGroup.vue (71%) rename src/{ => components/form}/formMixin.js (100%) diff --git a/.editorconfig b/.editorconfig index 4b8b3e12..d21d4f7b 100644 --- a/.editorconfig +++ b/.editorconfig @@ -5,5 +5,5 @@ end_of_line = lf insert_final_newline = true charset = utf-8 indent_style = tab -indent_size = 4 +indent_size = 2 trim_trailing_whitespace = true diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 00000000..60526ee6 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,12 @@ +{ + "printWidth": 120, + "semi": false, + "singleQuote": true, + "trailingComma": "none", + "bracketSpacing": true, + "jsxBracketSameLine": false, + "arrowParens": "avoid", + "requirePragma": false, + "proseWrap": "preserve", + "tabWidth": 2 +} diff --git a/build/webpack.build.config.js b/build/webpack.build.config.js index 8b975373..841864b2 100644 --- a/build/webpack.build.config.js +++ b/build/webpack.build.config.js @@ -75,7 +75,7 @@ module.exports = [ }), new LodashModuleReplacementPlugin({ collections: true, - paths: true, + paths: true }), new webpack.optimize.UglifyJsPlugin({ compress: { diff --git a/examples/post-form/main.js b/examples/post-form/main.js index fd5c4708..b7191f7b 100644 --- a/examples/post-form/main.js +++ b/examples/post-form/main.js @@ -7,25 +7,31 @@ var vm = new Vue({ }, methods: { - prettyJSON: function (json) { + prettyJSON: function(json) { if (json) { json = JSON.stringify(json, undefined, 4); - json = json.replace(/&/g, "&").replace(//g, ">"); - return json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function (match) { - var cls = "number"; - if (/^"/.test(match)) { - if (/:$/.test(match)) { - cls = "key"; - } else { - cls = "string"; + json = json + .replace(/&/g, "&") + .replace(//g, ">"); + return json.replace( + /("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, + function(match) { + var cls = "number"; + if (/^"/.test(match)) { + if (/:$/.test(match)) { + cls = "key"; + } else { + cls = "string"; + } + } else if (/true|false/.test(match)) { + cls = "boolean"; + } else if (/null/.test(match)) { + cls = "null"; } - } else if (/true|false/.test(match)) { - cls = "boolean"; - } else if (/null/.test(match)) { - cls = "null"; + return '' + match + ""; } - return "" + match + ""; - }); + ); } } }, @@ -90,17 +96,10 @@ var vm = new Vue({ model: "skills", inputName: "skills", required: true, - values: [ - "HTML5", - "Javascript", - "CSS3", - "CoffeeScript", - "AngularJS", - "ReactJS", - "VueJS" - ], + values: ["HTML5", "Javascript", "CSS3", "CoffeeScript", "AngularJS", "ReactJS", "VueJS"], validator: VueFormGenerator.validators.string - }, { + }, + { type: "upload", label: "Photo", model: "photo", @@ -126,7 +125,6 @@ var vm = new Vue({ buttonText: "Submit", validateBeforeSubmit: true } - ] }, @@ -135,4 +133,4 @@ var vm = new Vue({ validateAfterChanged: false } } -}); \ No newline at end of file +}); diff --git a/src/formGenerator.vue b/src/components/form/formGenerator.vue similarity index 100% rename from src/formGenerator.vue rename to src/components/form/formGenerator.vue diff --git a/src/formGroup.vue b/src/components/form/formGroup.vue similarity index 71% rename from src/formGroup.vue rename to src/components/form/formGroup.vue index 548fc526..4db603c4 100644 --- a/src/formGroup.vue +++ b/src/components/form/formGroup.vue @@ -1,32 +1,49 @@