Skip to content

Commit

Permalink
build uni runtime(mp-baidu:[String,Number],default:false=>Boolean)
Browse files Browse the repository at this point in the history
  • Loading branch information
fxy060608 committed Apr 20, 2019
1 parent 28abd0a commit f475974
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 51 deletions.
6 changes: 3 additions & 3 deletions packages/uni-app-plus/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -434,15 +434,15 @@ 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,
value,
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)
Expand Down
2 changes: 1 addition & 1 deletion packages/uni-app-plus/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
31 changes: 12 additions & 19 deletions packages/uni-mp-baidu/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -592,15 +585,15 @@ 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,
value,
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)
Expand Down
2 changes: 1 addition & 1 deletion packages/uni-mp-baidu/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
6 changes: 3 additions & 3 deletions packages/uni-mp-toutiao/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -614,15 +614,15 @@ 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,
value,
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)
Expand Down
2 changes: 1 addition & 1 deletion packages/uni-mp-toutiao/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
6 changes: 3 additions & 3 deletions packages/uni-mp-weixin/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -461,15 +461,15 @@ 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,
value,
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)
Expand Down
2 changes: 1 addition & 1 deletion packages/uni-mp-weixin/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
31 changes: 12 additions & 19 deletions src/core/runtime/wrapper/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -153,15 +146,15 @@ 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,
value,
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)
Expand Down

0 comments on commit f475974

Please sign in to comment.