Skip to content

Commit

Permalink
build mp runtime #411
Browse files Browse the repository at this point in the history
  • Loading branch information
fxy060608 committed Jun 6, 2019
1 parent 88418d3 commit 0d3256d
Show file tree
Hide file tree
Showing 10 changed files with 144 additions and 34 deletions.
34 changes: 28 additions & 6 deletions packages/uni-app-plus/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -433,13 +433,35 @@ function initMocks (vm, mocks) {
});
}

function initHooks (mpOptions, hooks) {
function hasHook (hook, vueOptions) {
if (!vueOptions) {
return true
}

vueOptions = vueOptions.default || vueOptions;

if (isFn(vueOptions)) {
vueOptions = vueOptions.extendOptions;
}

if (isFn(vueOptions[hook])) {
return true
}
const mixins = vueOptions.mixins;
if (Array.isArray(mixins)) {
return !!mixins.find(mixin => hasHook(hook, mixin))
}
}

function initHooks (mpOptions, hooks, vueOptions) {
hooks.forEach(hook => {
mpOptions[hook] = function (args) {
return this.$vm && this.$vm.__call_hook(hook, args)
};
if (hasHook(hook, vueOptions)) {
mpOptions[hook] = function (args) {
return this.$vm && this.$vm.__call_hook(hook, args)
};
}
});
}
}

function initVueComponent (Vue$$1, vueOptions) {
vueOptions = vueOptions.default || vueOptions;
Expand Down Expand Up @@ -1115,7 +1137,7 @@ function parseBasePage (vuePageOptions, {
initRelation
});

initHooks(pageOptions.methods, hooks$2);
initHooks(pageOptions.methods, hooks$2, vuePageOptions);

pageOptions.methods.onLoad = function (args) {
this.$vm.$mp.query = args; // 兼容 mpvue
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.241",
"version": "0.0.242",
"description": "uni-app app-plus",
"main": "dist/index.js",
"scripts": {
Expand Down
32 changes: 27 additions & 5 deletions packages/uni-mp-alipay/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -752,13 +752,35 @@ function initMocks (vm, mocks) {
});
}

function initHooks (mpOptions, hooks) {
function hasHook (hook, vueOptions) {
if (!vueOptions) {
return true
}

vueOptions = vueOptions.default || vueOptions;

if (isFn(vueOptions)) {
vueOptions = vueOptions.extendOptions;
}

if (isFn(vueOptions[hook])) {
return true
}
const mixins = vueOptions.mixins;
if (Array.isArray(mixins)) {
return !!mixins.find(mixin => hasHook(hook, mixin))
}
}

function initHooks (mpOptions, hooks, vueOptions) {
hooks.forEach(hook => {
mpOptions[hook] = function (args) {
return this.$vm && this.$vm.__call_hook(hook, args)
};
if (hasHook(hook, vueOptions)) {
mpOptions[hook] = function (args) {
return this.$vm && this.$vm.__call_hook(hook, args)
};
}
});
}
}

function initVueComponent (Vue$$1, vueOptions) {
vueOptions = vueOptions.default || vueOptions;
Expand Down
2 changes: 1 addition & 1 deletion packages/uni-mp-alipay/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dcloudio/uni-mp-alipay",
"version": "0.0.814",
"version": "0.0.815",
"description": "uni-app mp-alipay",
"main": "dist/index.js",
"scripts": {
Expand Down
34 changes: 28 additions & 6 deletions packages/uni-mp-baidu/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -533,13 +533,35 @@ function initMocks (vm, mocks) {
});
}

function initHooks (mpOptions, hooks) {
function hasHook (hook, vueOptions) {
if (!vueOptions) {
return true
}

vueOptions = vueOptions.default || vueOptions;

if (isFn(vueOptions)) {
vueOptions = vueOptions.extendOptions;
}

if (isFn(vueOptions[hook])) {
return true
}
const mixins = vueOptions.mixins;
if (Array.isArray(mixins)) {
return !!mixins.find(mixin => hasHook(hook, mixin))
}
}

function initHooks (mpOptions, hooks, vueOptions) {
hooks.forEach(hook => {
mpOptions[hook] = function (args) {
return this.$vm && this.$vm.__call_hook(hook, args)
};
if (hasHook(hook, vueOptions)) {
mpOptions[hook] = function (args) {
return this.$vm && this.$vm.__call_hook(hook, args)
};
}
});
}
}

function initVueComponent (Vue$$1, vueOptions) {
vueOptions = vueOptions.default || vueOptions;
Expand Down Expand Up @@ -1245,7 +1267,7 @@ function parseBasePage (vuePageOptions, {
initRelation
});

initHooks(pageOptions.methods, hooks$1);
initHooks(pageOptions.methods, hooks$1, vuePageOptions);

pageOptions.methods.onLoad = function (args) {
this.$vm.$mp.query = args; // 兼容 mpvue
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.841",
"version": "0.0.842",
"description": "uni-app mp-baidu",
"main": "dist/index.js",
"scripts": {
Expand Down
34 changes: 28 additions & 6 deletions packages/uni-mp-toutiao/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -578,13 +578,35 @@ function initMocks (vm, mocks) {
});
}

function initHooks (mpOptions, hooks) {
function hasHook (hook, vueOptions) {
if (!vueOptions) {
return true
}

vueOptions = vueOptions.default || vueOptions;

if (isFn(vueOptions)) {
vueOptions = vueOptions.extendOptions;
}

if (isFn(vueOptions[hook])) {
return true
}
const mixins = vueOptions.mixins;
if (Array.isArray(mixins)) {
return !!mixins.find(mixin => hasHook(hook, mixin))
}
}

function initHooks (mpOptions, hooks, vueOptions) {
hooks.forEach(hook => {
mpOptions[hook] = function (args) {
return this.$vm && this.$vm.__call_hook(hook, args)
};
if (hasHook(hook, vueOptions)) {
mpOptions[hook] = function (args) {
return this.$vm && this.$vm.__call_hook(hook, args)
};
}
});
}
}

function initVueComponent (Vue$$1, vueOptions) {
vueOptions = vueOptions.default || vueOptions;
Expand Down Expand Up @@ -1327,7 +1349,7 @@ function parseBasePage (vuePageOptions, {
initRelation
});

initHooks(pageOptions.methods, hooks$1);
initHooks(pageOptions.methods, hooks$1, vuePageOptions);

pageOptions.methods.onLoad = function (args) {
this.$vm.$mp.query = args; // 兼容 mpvue
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.338",
"version": "0.0.339",
"description": "uni-app mp-toutiao",
"main": "dist/index.js",
"scripts": {
Expand Down
34 changes: 28 additions & 6 deletions packages/uni-mp-weixin/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -435,13 +435,35 @@ function initMocks (vm, mocks) {
});
}

function initHooks (mpOptions, hooks) {
function hasHook (hook, vueOptions) {
if (!vueOptions) {
return true
}

vueOptions = vueOptions.default || vueOptions;

if (isFn(vueOptions)) {
vueOptions = vueOptions.extendOptions;
}

if (isFn(vueOptions[hook])) {
return true
}
const mixins = vueOptions.mixins;
if (Array.isArray(mixins)) {
return !!mixins.find(mixin => hasHook(hook, mixin))
}
}

function initHooks (mpOptions, hooks, vueOptions) {
hooks.forEach(hook => {
mpOptions[hook] = function (args) {
return this.$vm && this.$vm.__call_hook(hook, args)
};
if (hasHook(hook, vueOptions)) {
mpOptions[hook] = function (args) {
return this.$vm && this.$vm.__call_hook(hook, args)
};
}
});
}
}

function initVueComponent (Vue$$1, vueOptions) {
vueOptions = vueOptions.default || vueOptions;
Expand Down Expand Up @@ -1101,7 +1123,7 @@ function parseBasePage (vuePageOptions, {
initRelation
});

initHooks(pageOptions.methods, hooks$1);
initHooks(pageOptions.methods, hooks$1, vuePageOptions);

pageOptions.methods.onLoad = function (args) {
this.$vm.$mp.query = args; // 兼容 mpvue
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.960",
"version": "0.0.961",
"description": "uni-app mp-weixin",
"main": "dist/index.js",
"scripts": {
Expand Down

0 comments on commit 0d3256d

Please sign in to comment.