From f475974757285970b5b05f791b0fe7ab12e5305e Mon Sep 17 00:00:00 2001 From: fxy060608 Date: Sat, 20 Apr 2019 15:59:49 +0800 Subject: [PATCH] build uni runtime(mp-baidu:[String,Number],default:false=>Boolean) --- packages/uni-app-plus/dist/index.js | 6 +++--- packages/uni-app-plus/package.json | 2 +- packages/uni-mp-baidu/dist/index.js | 31 +++++++++++---------------- packages/uni-mp-baidu/package.json | 2 +- packages/uni-mp-toutiao/dist/index.js | 6 +++--- packages/uni-mp-toutiao/package.json | 2 +- packages/uni-mp-weixin/dist/index.js | 6 +++--- packages/uni-mp-weixin/package.json | 2 +- src/core/runtime/wrapper/util.js | 31 +++++++++++---------------- 9 files changed, 37 insertions(+), 51 deletions(-) diff --git a/packages/uni-app-plus/dist/index.js b/packages/uni-app-plus/dist/index.js index 9b1a0b12e..c660fa6f5 100644 --- a/packages/uni-app-plus/dist/index.js +++ b/packages/uni-app-plus/dist/index.js @@ -393,7 +393,7 @@ function getBehaviors (vueExtends, vueMixins) { return behaviors } -function parsePropType (key, type, file) { +function parsePropType (key, type, defaultValue, file) { // [String]=>String if (Array.isArray(type) && type.length === 1) { return type[0] @@ -434,7 +434,7 @@ function getProperties (props, isBehavior = false, file = '') { value = value(); } - opts.type = parsePropType(key, opts.type, file); + opts.type = parsePropType(key, opts.type, value, file); properties[key] = { type: PROP_TYPES.indexOf(opts.type) !== -1 ? opts.type : null, @@ -442,7 +442,7 @@ function getProperties (props, isBehavior = false, file = '') { observer: createObserver(key) }; } else { // content:String - const type = parsePropType(key, opts, file); + const type = parsePropType(key, opts, null, file); properties[key] = { type: PROP_TYPES.indexOf(type) !== -1 ? type : null, observer: createObserver(key) diff --git a/packages/uni-app-plus/package.json b/packages/uni-app-plus/package.json index edcb3831a..53170bb47 100644 --- a/packages/uni-app-plus/package.json +++ b/packages/uni-app-plus/package.json @@ -1,6 +1,6 @@ { "name": "@dcloudio/uni-app-plus", - "version": "0.0.224", + "version": "0.0.225", "description": "uni-app app-plus", "main": "dist/index.js", "scripts": { diff --git a/packages/uni-mp-baidu/dist/index.js b/packages/uni-mp-baidu/dist/index.js index 6d9cf553a..935896fe8 100644 --- a/packages/uni-mp-baidu/dist/index.js +++ b/packages/uni-mp-baidu/dist/index.js @@ -528,32 +528,25 @@ function getBehaviors (vueExtends, vueMixins) { return behaviors } -function parsePropType (key, type, file) { +function parsePropType (key, type, defaultValue, file) { // [String]=>String if (Array.isArray(type) && type.length === 1) { return type[0] } { if ( - Array.isArray(type) && + defaultValue === false && + Array.isArray(type) && type.length === 2 && - type.indexOf(String) !== -1 + type.indexOf(String) !== -1 && + type.indexOf(Boolean) !== -1 ) { // [String,Boolean]=>Boolean - if (type.indexOf(Boolean) !== -1) { - if (file) { - console.warn( - `props.${key}.type should use Boolean instead of [String,Boolean] . at ${file}` - ); - } - return Boolean - } else if (type.indexOf(Number) !== -1) { - if (file) { - console.warn( - `props.${key}.type should use String or Number instead of [String,Number]. at ${file}` - ); - } - return String + if (file) { + console.warn( + `props.${key}.type should use Boolean instead of [String,Boolean] at ${file}` + ); } + return Boolean } } return type @@ -592,7 +585,7 @@ function getProperties (props, isBehavior = false, file = '') { value = value(); } - opts.type = parsePropType(key, opts.type, file); + opts.type = parsePropType(key, opts.type, value, file); properties[key] = { type: PROP_TYPES.indexOf(opts.type) !== -1 ? opts.type : null, @@ -600,7 +593,7 @@ function getProperties (props, isBehavior = false, file = '') { observer: createObserver(key) }; } else { // content:String - const type = parsePropType(key, opts, file); + const type = parsePropType(key, opts, null, file); properties[key] = { type: PROP_TYPES.indexOf(type) !== -1 ? type : null, observer: createObserver(key) diff --git a/packages/uni-mp-baidu/package.json b/packages/uni-mp-baidu/package.json index 83b86e5d0..7d1bb584d 100644 --- a/packages/uni-mp-baidu/package.json +++ b/packages/uni-mp-baidu/package.json @@ -1,6 +1,6 @@ { "name": "@dcloudio/uni-mp-baidu", - "version": "0.0.820", + "version": "0.0.822", "description": "uni-app mp-baidu", "main": "dist/index.js", "scripts": { diff --git a/packages/uni-mp-toutiao/dist/index.js b/packages/uni-mp-toutiao/dist/index.js index 4f4f9b1c0..f565d3b0c 100644 --- a/packages/uni-mp-toutiao/dist/index.js +++ b/packages/uni-mp-toutiao/dist/index.js @@ -573,7 +573,7 @@ function getBehaviors (vueExtends, vueMixins) { return behaviors } -function parsePropType (key, type, file) { +function parsePropType (key, type, defaultValue, file) { // [String]=>String if (Array.isArray(type) && type.length === 1) { return type[0] @@ -614,7 +614,7 @@ function getProperties (props, isBehavior = false, file = '') { value = value(); } - opts.type = parsePropType(key, opts.type, file); + opts.type = parsePropType(key, opts.type, value, file); properties[key] = { type: PROP_TYPES.indexOf(opts.type) !== -1 ? opts.type : null, @@ -622,7 +622,7 @@ function getProperties (props, isBehavior = false, file = '') { observer: createObserver(key) }; } else { // content:String - const type = parsePropType(key, opts, file); + const type = parsePropType(key, opts, null, file); properties[key] = { type: PROP_TYPES.indexOf(type) !== -1 ? type : null, observer: createObserver(key) diff --git a/packages/uni-mp-toutiao/package.json b/packages/uni-mp-toutiao/package.json index 3178fd0be..15186f349 100644 --- a/packages/uni-mp-toutiao/package.json +++ b/packages/uni-mp-toutiao/package.json @@ -1,6 +1,6 @@ { "name": "@dcloudio/uni-mp-toutiao", - "version": "0.0.319", + "version": "0.0.320", "description": "uni-app mp-toutiao", "main": "dist/index.js", "scripts": { diff --git a/packages/uni-mp-weixin/dist/index.js b/packages/uni-mp-weixin/dist/index.js index ffb45f28f..aec304b75 100644 --- a/packages/uni-mp-weixin/dist/index.js +++ b/packages/uni-mp-weixin/dist/index.js @@ -420,7 +420,7 @@ function getBehaviors (vueExtends, vueMixins) { return behaviors } -function parsePropType (key, type, file) { +function parsePropType (key, type, defaultValue, file) { // [String]=>String if (Array.isArray(type) && type.length === 1) { return type[0] @@ -461,7 +461,7 @@ function getProperties (props, isBehavior = false, file = '') { value = value(); } - opts.type = parsePropType(key, opts.type, file); + opts.type = parsePropType(key, opts.type, value, file); properties[key] = { type: PROP_TYPES.indexOf(opts.type) !== -1 ? opts.type : null, @@ -469,7 +469,7 @@ function getProperties (props, isBehavior = false, file = '') { observer: createObserver(key) }; } else { // content:String - const type = parsePropType(key, opts, file); + const type = parsePropType(key, opts, null, file); properties[key] = { type: PROP_TYPES.indexOf(type) !== -1 ? type : null, observer: createObserver(key) diff --git a/packages/uni-mp-weixin/package.json b/packages/uni-mp-weixin/package.json index e1a5b1d7f..e947b4d81 100644 --- a/packages/uni-mp-weixin/package.json +++ b/packages/uni-mp-weixin/package.json @@ -1,6 +1,6 @@ { "name": "@dcloudio/uni-mp-weixin", - "version": "0.0.943", + "version": "0.0.944", "description": "uni-app mp-weixin", "main": "dist/index.js", "scripts": { diff --git a/src/core/runtime/wrapper/util.js b/src/core/runtime/wrapper/util.js index 6d3f25c4d..02396f980 100644 --- a/src/core/runtime/wrapper/util.js +++ b/src/core/runtime/wrapper/util.js @@ -89,32 +89,25 @@ export function getBehaviors (vueExtends, vueMixins) { return behaviors } -function parsePropType (key, type, file) { +function parsePropType (key, type, defaultValue, file) { // [String]=>String if (Array.isArray(type) && type.length === 1) { return type[0] } if (__PLATFORM__ === 'mp-baidu') { if ( - Array.isArray(type) && + defaultValue === false && + Array.isArray(type) && type.length === 2 && - type.indexOf(String) !== -1 + type.indexOf(String) !== -1 && + type.indexOf(Boolean) !== -1 ) { // [String,Boolean]=>Boolean - if (type.indexOf(Boolean) !== -1) { - if (file) { - console.warn( - `props.${key}.type should use Boolean instead of [String,Boolean] . at ${file}` - ) - } - return Boolean - } else if (type.indexOf(Number) !== -1) { - if (file) { - console.warn( - `props.${key}.type should use String or Number instead of [String,Number]. at ${file}` - ) - } - return String + if (file) { + console.warn( + `props.${key}.type should use Boolean instead of [String,Boolean] at ${file}` + ) } + return Boolean } } return type @@ -153,7 +146,7 @@ export function getProperties (props, isBehavior = false, file = '') { value = value() } - opts.type = parsePropType(key, opts.type, file) + opts.type = parsePropType(key, opts.type, value, file) properties[key] = { type: PROP_TYPES.indexOf(opts.type) !== -1 ? opts.type : null, @@ -161,7 +154,7 @@ export function getProperties (props, isBehavior = false, file = '') { observer: createObserver(key) } } else { // content:String - const type = parsePropType(key, opts, file) + const type = parsePropType(key, opts, null, file) properties[key] = { type: PROP_TYPES.indexOf(type) !== -1 ? type : null, observer: createObserver(key) -- GitLab