提交 7c9072e5 编写于 作者: Q qiang

Merge branch 'dev' into alpha

......@@ -43,7 +43,7 @@ uni.onKeyboardHeightChange(res => {
|App|H5|微信小程序|支付宝小程序|百度小程序|字节跳动小程序|QQ小程序|
|:-:|:-:|:-:|:-:|:-:|:-:|:-:|
|HBuilderX 2.8.10+|HBuilderX 2.8.10+|基础库 2.7.0+|x|x|x|x|
|HBuilderX 2.8.12+|HBuilderX 2.8.12+|基础库 2.7.0+|x|x|x|x|
**OBJECT 参数说明:**
......
<template>
<view v-show="matches">
<slot />
</view>
<view v-show="matches">
<slot />
</view>
</template>
<script>
......@@ -41,26 +41,26 @@ export default {
data () {
return {
matches: true,
matches: true
}
},
mounted() {
mounted () {
mediaQueryObserver = uni.createMediaQueryObserver(this)
mediaQueryObserver.observe({
width: this.width,
maxWidth: this.maxWidth,
minWidth: this.minWidth,
height: this.height,
minHeight: this.minHeight,
maxHeight: this.maxHeight,
orientation: this.orientation
}, matches => {
this.matches = matches
})
width: this.width,
maxWidth: this.maxWidth,
minWidth: this.minWidth,
height: this.height,
minHeight: this.minHeight,
maxHeight: this.maxHeight,
orientation: this.orientation
}, matches => {
this.matches = matches
})
},
destroyed() {
destroyed () {
mediaQueryObserver.disconnect()
}
}
......
......@@ -40,5 +40,5 @@ module.exports = {
textarea: ['app-plus', 'mp-weixin', 'h5'],
video: ['app-plus', 'mp-weixin', 'h5'],
view: ['app-plus', 'mp-weixin', 'h5'],
'web-view': ['app-plus', 'mp-weixin'],
'web-view': ['app-plus', 'mp-weixin']
}
import { isArray, isPromise, isFunction, isPlainObject, hasOwn, isString } from '@vue/shared';
const API_TYPE_SYNC = 1;
function validateProtocol(_name, _args, _protocol) {
return true;
}
function formatApiArgs(args, options) {
if (!options) {
return args;
}
}
function createApi({ type, name, options }, fn, protocol) {
return function (...args) {
if (type === API_TYPE_SYNC) {
if (!((process.env.NODE_ENV !== 'production') && protocol && !validateProtocol())) {
return fn.apply(null, formatApiArgs(args, options));
}
}
};
}
const Upx2pxProtocol = [
{
name: 'upx',
type: [Number, String],
required: true
}
];
const EPS = 1e-4;
const BASE_DEVICE_WIDTH = 750;
let isIOS = false;
......@@ -11,7 +38,7 @@ function checkDeviceWidth() {
deviceDPR = pixelRatio;
isIOS = platform === 'ios';
}
function upx2px(number, newDeviceWidth) {
const upx2px = createApi({ type: API_TYPE_SYNC, name: 'upx2px' }, (number, newDeviceWidth) => {
if (deviceWidth === 0) {
checkDeviceWidth();
}
......@@ -33,7 +60,7 @@ function upx2px(number, newDeviceWidth) {
}
}
return number < 0 ? -result : result;
}
}, Upx2pxProtocol);
var HOOKS;
(function (HOOKS) {
......@@ -139,6 +166,15 @@ function invokeApi(method, api, options, ...params) {
return api(options, ...params);
}
const AddInterceptorProtocol = [
{
name: 'method',
type: [String, Object],
required: true
}
];
const RemoveInterceptorProtocol = AddInterceptorProtocol;
function mergeInterceptorHook(interceptors, interceptor) {
Object.keys(interceptor).forEach(hook => {
if (isFunction(interceptor[hook])) {
......@@ -184,15 +220,15 @@ function removeHook(hooks, hook) {
hooks.splice(index, 1);
}
}
function addInterceptor(method, interceptor) {
const addInterceptor = createApi({ type: API_TYPE_SYNC, name: 'addInterceptor' }, (method, interceptor) => {
if (typeof method === 'string' && isPlainObject(interceptor)) {
mergeInterceptorHook(scopedInterceptors[method] || (scopedInterceptors[method] = {}), interceptor);
}
else if (isPlainObject(method)) {
mergeInterceptorHook(globalInterceptors, method);
}
}
function removeInterceptor(method, interceptor) {
}, AddInterceptorProtocol);
const removeInterceptor = createApi({ type: API_TYPE_SYNC, name: 'removeInterceptor' }, (method, interceptor) => {
if (typeof method === 'string') {
if (isPlainObject(interceptor)) {
removeInterceptorHook(scopedInterceptors[method], interceptor);
......@@ -204,7 +240,7 @@ function removeInterceptor(method, interceptor) {
else if (isPlainObject(method)) {
removeInterceptorHook(globalInterceptors, method);
}
}
}, RemoveInterceptorProtocol);
const SYNC_API_RE = /^\$|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/;
const CONTEXT_API_RE = /^create|Manager$/;
......@@ -413,7 +449,20 @@ function addSafeAreaInsets(fromRes, toRes) {
bottom: fromRes.windowHeight - safeArea.bottom
};
}
}
}
const redirectTo = {};
const createCanvasContext = {
returnValue(fromRes, toRes) {
const measureText = fromRes.measureText;
toRes.measureText = function (text, callback) {
const textMetrics = measureText.call(this, text);
if (typeof callback === 'function') {
setTimeout(() => callback(textMetrics), 0);
}
return textMetrics;
};
}
};
const getProvider = initGetProvider({
oauth: ['alipay'],
......@@ -1000,7 +1049,9 @@ var protocols = /*#__PURE__*/Object.freeze({
hideHomeButton: hideHomeButton,
saveImageToPhotosAlbum: saveImageToPhotosAlbum,
saveVideoToPhotosAlbum: saveVideoToPhotosAlbum,
chooseAddress: chooseAddress
chooseAddress: chooseAddress,
redirectTo: redirectTo,
createCanvasContext: createCanvasContext
});
var index = initUni(shims, protocols);
......
......@@ -52,28 +52,6 @@ const MP_METHODS = [
'selectAllComponents',
'selectComponent'
];
function hasHook(name) {
const hooks = this.$[name];
if (hooks && hooks.length) {
return true;
}
return false;
}
function callHook(name, args) {
if (name === 'mounted') {
callHook.call(this, 'bm'); // beforeMount
this.$.isMounted = true;
name = 'm';
}
const hooks = this.$[name];
let ret;
if (hooks) {
for (let i = 0; i < hooks.length; i++) {
ret = hooks[i](args);
}
}
return ret;
}
function createEmitFn(oldEmit, ctx) {
return function emit(event, ...args) {
if (ctx.$scope && event) {
......@@ -89,9 +67,6 @@ function createEmitFn(oldEmit, ctx) {
return oldEmit.apply(this, [event, ...args]);
};
}
function set(target, key, val) {
return (target[key] = val);
}
function initBaseInstance(instance, options) {
const ctx = instance.ctx;
// mp
......@@ -100,7 +75,9 @@ function initBaseInstance(instance, options) {
ctx.$scope = options.mpInstance;
// TODO @deprecated
ctx.$mp = {};
ctx._self = {};
if (__VUE_OPTIONS_API__) {
ctx._self = {};
}
// $vm
ctx.$scope.$vm = instance.proxy;
// slots
......@@ -111,15 +88,8 @@ function initBaseInstance(instance, options) {
}
});
}
if (__VUE_OPTIONS_API__) {
// $set
ctx.$set = set;
}
// $emit
instance.emit = createEmitFn(instance.emit, ctx);
// $callHook
ctx.$hasHook = hasHook;
ctx.$callHook = callHook;
}
function initComponentInstance(instance, options) {
initBaseInstance(instance, options);
......@@ -216,7 +186,7 @@ function parseApp(instance, parseAppOptions) {
$vm: instance,
onLaunch(options) {
const ctx = internalInstance.ctx;
if (this.$vm && ctx.$callHook) {
if (this.$vm && ctx.$scope) {
// 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
return;
}
......@@ -247,6 +217,26 @@ function initCreateApp(parseAppOptions) {
};
}
const encode = encodeURIComponent;
function stringifyQuery(obj, encodeStr = encode) {
const res = obj
? Object.keys(obj)
.map(key => {
let val = obj[key];
if (typeof val === undefined || val === null) {
val = '';
}
else if (isPlainObject(val)) {
val = JSON.stringify(val);
}
return encodeStr(key) + '=' + encodeStr(val);
})
.filter(x => x.length > 0)
.join('&')
: null;
return res ? `?${res}` : '';
}
function initVueIds(vueIds, mpInstance) {
if (!vueIds) {
return;
......@@ -261,6 +251,16 @@ function initVueIds(vueIds, mpInstance) {
mpInstance._$vuePid = ids[1];
}
}
function initWxsCallMethods(methods, wxsCallMethods) {
if (!isArray(wxsCallMethods)) {
return;
}
wxsCallMethods.forEach((callMethod) => {
methods[callMethod] = function (args) {
return this.$vm[callMethod](args);
};
});
}
function findVmByVueId(instance, vuePid) {
// TODO vue3 中 没有 $children
const $children = instance.$children;
......@@ -971,11 +971,15 @@ function createVueComponent(mpType, mpInstance, vueOptions, parent) {
function createPage(vueOptions) {
vueOptions = vueOptions.default || vueOptions;
const pageOptions = {
onLoad(args) {
onLoad(query) {
this.options = query;
this.$page = {
fullPath: '/' + this.route + stringifyQuery(query)
};
// 初始化 vue 实例
this.$vm = createVueComponent('page', this, vueOptions);
initSpecialMethods(this);
this.$vm.$callHook('onLoad', args);
this.$vm.$callHook('onLoad', query);
},
onReady() {
initChildVues(this);
......@@ -1003,6 +1007,7 @@ function createPage(vueOptions) {
}
initHooks(pageOptions, PAGE_HOOKS);
initUnknownHooks(pageOptions, vueOptions);
initWxsCallMethods(pageOptions, vueOptions.wxsCallMethods);
return Page(pageOptions);
}
......@@ -1099,6 +1104,7 @@ function createComponent(vueOptions) {
else {
mpComponentOptions.didUpdate = createObserver(true);
}
initWxsCallMethods(mpComponentOptions.methods, vueOptions.wxsCallMethods);
return Component(mpComponentOptions);
}
......
......@@ -1990,6 +1990,11 @@ function parsePage (vuePageOptions) {
initRelation
});
const onInit = (vuePageOptions.default || vuePageOptions).onInit;
if (onInit) {
pageOptions.methods.onInit = onInit;
}
// 纠正百度小程序生命周期methods:onShow在methods:onLoad之前触发的问题
pageOptions.methods.onShow = function onShow () {
if (this.$vm && this.$vm.$mp.query) {
......
import { isArray, isPromise, isFunction, isPlainObject, hasOwn, isString } from '@vue/shared';
const API_TYPE_SYNC = 1;
function validateProtocol(_name, _args, _protocol) {
return true;
}
function formatApiArgs(args, options) {
if (!options) {
return args;
}
}
function createApi({ type, name, options }, fn, protocol) {
return function (...args) {
if (type === API_TYPE_SYNC) {
if (!((process.env.NODE_ENV !== 'production') && protocol && !validateProtocol())) {
return fn.apply(null, formatApiArgs(args, options));
}
}
};
}
const Upx2pxProtocol = [
{
name: 'upx',
type: [Number, String],
required: true
}
];
const EPS = 1e-4;
const BASE_DEVICE_WIDTH = 750;
let isIOS = false;
......@@ -11,7 +38,7 @@ function checkDeviceWidth() {
deviceDPR = pixelRatio;
isIOS = platform === 'ios';
}
function upx2px(number, newDeviceWidth) {
const upx2px = createApi({ type: API_TYPE_SYNC, name: 'upx2px' }, (number, newDeviceWidth) => {
if (deviceWidth === 0) {
checkDeviceWidth();
}
......@@ -33,7 +60,7 @@ function upx2px(number, newDeviceWidth) {
}
}
return number < 0 ? -result : result;
}
}, Upx2pxProtocol);
var HOOKS;
(function (HOOKS) {
......@@ -139,6 +166,15 @@ function invokeApi(method, api, options, ...params) {
return api(options, ...params);
}
const AddInterceptorProtocol = [
{
name: 'method',
type: [String, Object],
required: true
}
];
const RemoveInterceptorProtocol = AddInterceptorProtocol;
function mergeInterceptorHook(interceptors, interceptor) {
Object.keys(interceptor).forEach(hook => {
if (isFunction(interceptor[hook])) {
......@@ -184,15 +220,15 @@ function removeHook(hooks, hook) {
hooks.splice(index, 1);
}
}
function addInterceptor(method, interceptor) {
const addInterceptor = createApi({ type: API_TYPE_SYNC, name: 'addInterceptor' }, (method, interceptor) => {
if (typeof method === 'string' && isPlainObject(interceptor)) {
mergeInterceptorHook(scopedInterceptors[method] || (scopedInterceptors[method] = {}), interceptor);
}
else if (isPlainObject(method)) {
mergeInterceptorHook(globalInterceptors, method);
}
}
function removeInterceptor(method, interceptor) {
}, AddInterceptorProtocol);
const removeInterceptor = createApi({ type: API_TYPE_SYNC, name: 'removeInterceptor' }, (method, interceptor) => {
if (typeof method === 'string') {
if (isPlainObject(interceptor)) {
removeInterceptorHook(scopedInterceptors[method], interceptor);
......@@ -204,7 +240,7 @@ function removeInterceptor(method, interceptor) {
else if (isPlainObject(method)) {
removeInterceptorHook(globalInterceptors, method);
}
}
}, RemoveInterceptorProtocol);
const SYNC_API_RE = /^\$|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/;
const CONTEXT_API_RE = /^create|Manager$/;
......@@ -450,7 +486,20 @@ function addSafeAreaInsets(fromRes, toRes) {
const getSystemInfo = {
returnValue: addSafeAreaInsets
};
const getSystemInfoSync = getSystemInfo;
const getSystemInfoSync = getSystemInfo;
const redirectTo = {};
const createCanvasContext = {
returnValue(fromRes, toRes) {
const measureText = fromRes.measureText;
toRes.measureText = function (text, callback) {
const textMetrics = measureText.call(this, text);
if (typeof callback === 'function') {
setTimeout(() => callback(textMetrics), 0);
}
return textMetrics;
};
}
};
const getProvider = initGetProvider({
oauth: ['baidu'],
......@@ -565,9 +614,11 @@ var protocols = /*#__PURE__*/Object.freeze({
navigateBackMiniProgram: navigateBackMiniProgram,
showShareMenu: showShareMenu,
getAccountInfoSync: getAccountInfoSync,
redirectTo: redirectTo,
previewImage: previewImage,
getSystemInfo: getSystemInfo,
getSystemInfoSync: getSystemInfoSync
getSystemInfoSync: getSystemInfoSync,
createCanvasContext: createCanvasContext
});
var index = initUni(shims, protocols);
......
......@@ -52,28 +52,6 @@ const MP_METHODS = [
'selectAllComponents',
'selectComponent'
];
function hasHook(name) {
const hooks = this.$[name];
if (hooks && hooks.length) {
return true;
}
return false;
}
function callHook(name, args) {
if (name === 'mounted') {
callHook.call(this, 'bm'); // beforeMount
this.$.isMounted = true;
name = 'm';
}
const hooks = this.$[name];
let ret;
if (hooks) {
for (let i = 0; i < hooks.length; i++) {
ret = hooks[i](args);
}
}
return ret;
}
function createEmitFn(oldEmit, ctx) {
return function emit(event, ...args) {
if (ctx.$scope && event) {
......@@ -82,9 +60,6 @@ function createEmitFn(oldEmit, ctx) {
return oldEmit.apply(this, [event, ...args]);
};
}
function set(target, key, val) {
return (target[key] = val);
}
function initBaseInstance(instance, options) {
const ctx = instance.ctx;
// mp
......@@ -93,7 +68,9 @@ function initBaseInstance(instance, options) {
ctx.$scope = options.mpInstance;
// TODO @deprecated
ctx.$mp = {};
ctx._self = {};
if (__VUE_OPTIONS_API__) {
ctx._self = {};
}
// $vm
ctx.$scope.$vm = instance.proxy;
// slots
......@@ -105,15 +82,8 @@ function initBaseInstance(instance, options) {
});
}
}
if (__VUE_OPTIONS_API__) {
// $set
ctx.$set = set;
}
// $emit
instance.emit = createEmitFn(instance.emit, ctx);
// $callHook
ctx.$hasHook = hasHook;
ctx.$callHook = callHook;
}
function initComponentInstance(instance, options) {
initBaseInstance(instance, options);
......@@ -207,7 +177,7 @@ function parseApp(instance, parseAppOptions) {
$vm: instance,
onLaunch(options) {
const ctx = internalInstance.ctx;
if (this.$vm && ctx.$callHook) {
if (this.$vm && ctx.$scope) {
// 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
return;
}
......@@ -238,6 +208,26 @@ function initCreateApp(parseAppOptions) {
};
}
const encode = encodeURIComponent;
function stringifyQuery(obj, encodeStr = encode) {
const res = obj
? Object.keys(obj)
.map(key => {
let val = obj[key];
if (typeof val === undefined || val === null) {
val = '';
}
else if (isPlainObject(val)) {
val = JSON.stringify(val);
}
return encodeStr(key) + '=' + encodeStr(val);
})
.filter(x => x.length > 0)
.join('&')
: null;
return res ? `?${res}` : '';
}
function initBehavior(options) {
return Behavior(options);
}
......@@ -810,6 +800,13 @@ function parsePage(vueOptions, parseOptions) {
initLifetimes
});
const methods = miniProgramPageOptions.methods;
methods.onLoad = function (query) {
this.options = query;
this.$page = {
fullPath: '/' + this.route + stringifyQuery(query)
};
return this.$vm && this.$vm.$callHook('onLoad', query);
};
initHooks(methods, PAGE_HOOKS);
initUnknownHooks(methods, vueOptions);
parse && parse(miniProgramPageOptions, { handleLink });
......@@ -929,7 +926,7 @@ function handleLink(event) {
const mocks = ['nodeId', 'componentName', '_componentId', 'uniquePrefix'];
function isPage(mpInstance) {
return !mpInstance.ownerId;
return !hasOwn(mpInstance, 'ownerId');
}
function initRelation(mpInstance, detail) {
mpInstance.dispatch('__l', detail);
......
import { isArray, isPromise, isFunction, isPlainObject, hasOwn, isString } from '@vue/shared';
const API_TYPE_SYNC = 1;
function validateProtocol(_name, _args, _protocol) {
return true;
}
function formatApiArgs(args, options) {
if (!options) {
return args;
}
}
function createApi({ type, name, options }, fn, protocol) {
return function (...args) {
if (type === API_TYPE_SYNC) {
if (!((process.env.NODE_ENV !== 'production') && protocol && !validateProtocol())) {
return fn.apply(null, formatApiArgs(args, options));
}
}
};
}
const Upx2pxProtocol = [
{
name: 'upx',
type: [Number, String],
required: true
}
];
const EPS = 1e-4;
const BASE_DEVICE_WIDTH = 750;
let isIOS = false;
......@@ -11,7 +38,7 @@ function checkDeviceWidth() {
deviceDPR = pixelRatio;
isIOS = platform === 'ios';
}
function upx2px(number, newDeviceWidth) {
const upx2px = createApi({ type: API_TYPE_SYNC, name: 'upx2px' }, (number, newDeviceWidth) => {
if (deviceWidth === 0) {
checkDeviceWidth();
}
......@@ -33,7 +60,7 @@ function upx2px(number, newDeviceWidth) {
}
}
return number < 0 ? -result : result;
}
}, Upx2pxProtocol);
var HOOKS;
(function (HOOKS) {
......@@ -139,6 +166,15 @@ function invokeApi(method, api, options, ...params) {
return api(options, ...params);
}
const AddInterceptorProtocol = [
{
name: 'method',
type: [String, Object],
required: true
}
];
const RemoveInterceptorProtocol = AddInterceptorProtocol;
function mergeInterceptorHook(interceptors, interceptor) {
Object.keys(interceptor).forEach(hook => {
if (isFunction(interceptor[hook])) {
......@@ -184,15 +220,15 @@ function removeHook(hooks, hook) {
hooks.splice(index, 1);
}
}
function addInterceptor(method, interceptor) {
const addInterceptor = createApi({ type: API_TYPE_SYNC, name: 'addInterceptor' }, (method, interceptor) => {
if (typeof method === 'string' && isPlainObject(interceptor)) {
mergeInterceptorHook(scopedInterceptors[method] || (scopedInterceptors[method] = {}), interceptor);
}
else if (isPlainObject(method)) {
mergeInterceptorHook(globalInterceptors, method);
}
}
function removeInterceptor(method, interceptor) {
}, AddInterceptorProtocol);
const removeInterceptor = createApi({ type: API_TYPE_SYNC, name: 'removeInterceptor' }, (method, interceptor) => {
if (typeof method === 'string') {
if (isPlainObject(interceptor)) {
removeInterceptorHook(scopedInterceptors[method], interceptor);
......@@ -204,7 +240,7 @@ function removeInterceptor(method, interceptor) {
else if (isPlainObject(method)) {
removeInterceptorHook(globalInterceptors, method);
}
}
}, RemoveInterceptorProtocol);
const SYNC_API_RE = /^\$|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/;
const CONTEXT_API_RE = /^create|Manager$/;
......@@ -450,7 +486,20 @@ function addSafeAreaInsets(fromRes, toRes) {
const getSystemInfo = {
returnValue: addSafeAreaInsets
};
const getSystemInfoSync = getSystemInfo;
const getSystemInfoSync = getSystemInfo;
const redirectTo = {};
const createCanvasContext = {
returnValue(fromRes, toRes) {
const measureText = fromRes.measureText;
toRes.measureText = function (text, callback) {
const textMetrics = measureText.call(this, text);
if (typeof callback === 'function') {
setTimeout(() => callback(textMetrics), 0);
}
return textMetrics;
};
}
};
const getProvider = initGetProvider({
oauth: ['qq'],
......@@ -466,9 +515,11 @@ var shims = /*#__PURE__*/Object.freeze({
var protocols = /*#__PURE__*/Object.freeze({
__proto__: null,
redirectTo: redirectTo,
previewImage: previewImage,
getSystemInfo: getSystemInfo,
getSystemInfoSync: getSystemInfoSync
getSystemInfoSync: getSystemInfoSync,
createCanvasContext: createCanvasContext
});
var index = initUni(shims, protocols);
......
......@@ -52,28 +52,6 @@ const MP_METHODS = [
'selectAllComponents',
'selectComponent'
];
function hasHook(name) {
const hooks = this.$[name];
if (hooks && hooks.length) {
return true;
}
return false;
}
function callHook(name, args) {
if (name === 'mounted') {
callHook.call(this, 'bm'); // beforeMount
this.$.isMounted = true;
name = 'm';
}
const hooks = this.$[name];
let ret;
if (hooks) {
for (let i = 0; i < hooks.length; i++) {
ret = hooks[i](args);
}
}
return ret;
}
function createEmitFn(oldEmit, ctx) {
return function emit(event, ...args) {
if (ctx.$scope && event) {
......@@ -82,9 +60,6 @@ function createEmitFn(oldEmit, ctx) {
return oldEmit.apply(this, [event, ...args]);
};
}
function set(target, key, val) {
return (target[key] = val);
}
function initBaseInstance(instance, options) {
const ctx = instance.ctx;
// mp
......@@ -93,7 +68,9 @@ function initBaseInstance(instance, options) {
ctx.$scope = options.mpInstance;
// TODO @deprecated
ctx.$mp = {};
ctx._self = {};
if (__VUE_OPTIONS_API__) {
ctx._self = {};
}
// $vm
ctx.$scope.$vm = instance.proxy;
// slots
......@@ -105,15 +82,8 @@ function initBaseInstance(instance, options) {
});
}
}
if (__VUE_OPTIONS_API__) {
// $set
ctx.$set = set;
}
// $emit
instance.emit = createEmitFn(instance.emit, ctx);
// $callHook
ctx.$hasHook = hasHook;
ctx.$callHook = callHook;
}
function initComponentInstance(instance, options) {
initBaseInstance(instance, options);
......@@ -207,7 +177,7 @@ function parseApp(instance, parseAppOptions) {
$vm: instance,
onLaunch(options) {
const ctx = internalInstance.ctx;
if (this.$vm && ctx.$callHook) {
if (this.$vm && ctx.$scope) {
// 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
return;
}
......@@ -238,6 +208,26 @@ function initCreateApp(parseAppOptions) {
};
}
const encode = encodeURIComponent;
function stringifyQuery(obj, encodeStr = encode) {
const res = obj
? Object.keys(obj)
.map(key => {
let val = obj[key];
if (typeof val === undefined || val === null) {
val = '';
}
else if (isPlainObject(val)) {
val = JSON.stringify(val);
}
return encodeStr(key) + '=' + encodeStr(val);
})
.filter(x => x.length > 0)
.join('&')
: null;
return res ? `?${res}` : '';
}
function initBehavior(options) {
return Behavior(options);
}
......@@ -791,6 +781,13 @@ function parsePage(vueOptions, parseOptions) {
initLifetimes
});
const methods = miniProgramPageOptions.methods;
methods.onLoad = function (query) {
this.options = query;
this.$page = {
fullPath: '/' + this.route + stringifyQuery(query)
};
return this.$vm && this.$vm.$callHook('onLoad', query);
};
initHooks(methods, PAGE_HOOKS);
initUnknownHooks(methods, vueOptions);
parse && parse(miniProgramPageOptions, { handleLink });
......
import { isArray, isPromise, isFunction, isPlainObject, hasOwn, isString } from '@vue/shared';
const API_TYPE_SYNC = 1;
function validateProtocol(_name, _args, _protocol) {
return true;
}
function formatApiArgs(args, options) {
if (!options) {
return args;
}
}
function createApi({ type, name, options }, fn, protocol) {
return function (...args) {
if (type === API_TYPE_SYNC) {
if (!((process.env.NODE_ENV !== 'production') && protocol && !validateProtocol())) {
return fn.apply(null, formatApiArgs(args, options));
}
}
};
}
const Upx2pxProtocol = [
{
name: 'upx',
type: [Number, String],
required: true
}
];
const EPS = 1e-4;
const BASE_DEVICE_WIDTH = 750;
let isIOS = false;
......@@ -11,7 +38,7 @@ function checkDeviceWidth() {
deviceDPR = pixelRatio;
isIOS = platform === 'ios';
}
function upx2px(number, newDeviceWidth) {
const upx2px = createApi({ type: API_TYPE_SYNC, name: 'upx2px' }, (number, newDeviceWidth) => {
if (deviceWidth === 0) {
checkDeviceWidth();
}
......@@ -33,7 +60,7 @@ function upx2px(number, newDeviceWidth) {
}
}
return number < 0 ? -result : result;
}
}, Upx2pxProtocol);
var HOOKS;
(function (HOOKS) {
......@@ -139,6 +166,15 @@ function invokeApi(method, api, options, ...params) {
return api(options, ...params);
}
const AddInterceptorProtocol = [
{
name: 'method',
type: [String, Object],
required: true
}
];
const RemoveInterceptorProtocol = AddInterceptorProtocol;
function mergeInterceptorHook(interceptors, interceptor) {
Object.keys(interceptor).forEach(hook => {
if (isFunction(interceptor[hook])) {
......@@ -184,15 +220,15 @@ function removeHook(hooks, hook) {
hooks.splice(index, 1);
}
}
function addInterceptor(method, interceptor) {
const addInterceptor = createApi({ type: API_TYPE_SYNC, name: 'addInterceptor' }, (method, interceptor) => {
if (typeof method === 'string' && isPlainObject(interceptor)) {
mergeInterceptorHook(scopedInterceptors[method] || (scopedInterceptors[method] = {}), interceptor);
}
else if (isPlainObject(method)) {
mergeInterceptorHook(globalInterceptors, method);
}
}
function removeInterceptor(method, interceptor) {
}, AddInterceptorProtocol);
const removeInterceptor = createApi({ type: API_TYPE_SYNC, name: 'removeInterceptor' }, (method, interceptor) => {
if (typeof method === 'string') {
if (isPlainObject(interceptor)) {
removeInterceptorHook(scopedInterceptors[method], interceptor);
......@@ -204,7 +240,7 @@ function removeInterceptor(method, interceptor) {
else if (isPlainObject(method)) {
removeInterceptorHook(globalInterceptors, method);
}
}
}, RemoveInterceptorProtocol);
const SYNC_API_RE = /^\$|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/;
const CONTEXT_API_RE = /^create|Manager$/;
......@@ -435,6 +471,19 @@ const previewImage = {
loop: false
};
}
};
const redirectTo = {};
const createCanvasContext = {
returnValue(fromRes, toRes) {
const measureText = fromRes.measureText;
toRes.measureText = function (text, callback) {
const textMetrics = measureText.call(this, text);
if (typeof callback === 'function') {
setTimeout(() => callback(textMetrics), 0);
}
return textMetrics;
};
}
};
const getProvider = initGetProvider({
......@@ -536,7 +585,9 @@ var protocols = /*#__PURE__*/Object.freeze({
getUserInfo: getUserInfo,
requestPayment: requestPayment,
getFileInfo: getFileInfo,
previewImage: previewImage
redirectTo: redirectTo,
previewImage: previewImage,
createCanvasContext: createCanvasContext
});
var index = initUni(shims, protocols);
......
......@@ -52,28 +52,6 @@ const MP_METHODS = [
'selectAllComponents',
'selectComponent'
];
function hasHook(name) {
const hooks = this.$[name];
if (hooks && hooks.length) {
return true;
}
return false;
}
function callHook(name, args) {
if (name === 'mounted') {
callHook.call(this, 'bm'); // beforeMount
this.$.isMounted = true;
name = 'm';
}
const hooks = this.$[name];
let ret;
if (hooks) {
for (let i = 0; i < hooks.length; i++) {
ret = hooks[i](args);
}
}
return ret;
}
function createEmitFn(oldEmit, ctx) {
return function emit(event, ...args) {
if (ctx.$scope && event) {
......@@ -82,9 +60,6 @@ function createEmitFn(oldEmit, ctx) {
return oldEmit.apply(this, [event, ...args]);
};
}
function set(target, key, val) {
return (target[key] = val);
}
function initBaseInstance(instance, options) {
const ctx = instance.ctx;
// mp
......@@ -93,7 +68,9 @@ function initBaseInstance(instance, options) {
ctx.$scope = options.mpInstance;
// TODO @deprecated
ctx.$mp = {};
ctx._self = {};
if (__VUE_OPTIONS_API__) {
ctx._self = {};
}
// $vm
ctx.$scope.$vm = instance.proxy;
// slots
......@@ -105,15 +82,8 @@ function initBaseInstance(instance, options) {
});
}
}
if (__VUE_OPTIONS_API__) {
// $set
ctx.$set = set;
}
// $emit
instance.emit = createEmitFn(instance.emit, ctx);
// $callHook
ctx.$hasHook = hasHook;
ctx.$callHook = callHook;
}
function initComponentInstance(instance, options) {
initBaseInstance(instance, options);
......@@ -210,7 +180,7 @@ function parseApp(instance, parseAppOptions) {
$vm: instance,
onLaunch(options) {
const ctx = internalInstance.ctx;
if (this.$vm && ctx.$callHook) {
if (this.$vm && ctx.$scope) {
// 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
return;
}
......@@ -241,6 +211,26 @@ function initCreateApp(parseAppOptions) {
};
}
const encode = encodeURIComponent;
function stringifyQuery(obj, encodeStr = encode) {
const res = obj
? Object.keys(obj)
.map(key => {
let val = obj[key];
if (typeof val === undefined || val === null) {
val = '';
}
else if (isPlainObject(val)) {
val = JSON.stringify(val);
}
return encodeStr(key) + '=' + encodeStr(val);
})
.filter(x => x.length > 0)
.join('&')
: null;
return res ? `?${res}` : '';
}
function initBehavior(options) {
return Behavior(options);
}
......@@ -800,6 +790,13 @@ function parsePage(vueOptions, parseOptions) {
initLifetimes
});
const methods = miniProgramPageOptions.methods;
methods.onLoad = function (query) {
this.options = query;
this.$page = {
fullPath: '/' + this.route + stringifyQuery(query)
};
return this.$vm && this.$vm.$callHook('onLoad', query);
};
initHooks(methods, PAGE_HOOKS);
initUnknownHooks(methods, vueOptions);
parse && parse(miniProgramPageOptions, { handleLink });
......
import { isArray, isPromise, isFunction, isPlainObject, hasOwn, isString } from '@vue/shared';
const API_TYPE_SYNC = 1;
function validateProtocol(_name, _args, _protocol) {
return true;
}
function formatApiArgs(args, options) {
if (!options) {
return args;
}
}
function createApi({ type, name, options }, fn, protocol) {
return function (...args) {
if (type === API_TYPE_SYNC) {
if (!((process.env.NODE_ENV !== 'production') && protocol && !validateProtocol())) {
return fn.apply(null, formatApiArgs(args, options));
}
}
};
}
const Upx2pxProtocol = [
{
name: 'upx',
type: [Number, String],
required: true
}
];
const EPS = 1e-4;
const BASE_DEVICE_WIDTH = 750;
let isIOS = false;
......@@ -11,7 +38,7 @@ function checkDeviceWidth() {
deviceDPR = pixelRatio;
isIOS = platform === 'ios';
}
function upx2px(number, newDeviceWidth) {
const upx2px = createApi({ type: API_TYPE_SYNC, name: 'upx2px' }, (number, newDeviceWidth) => {
if (deviceWidth === 0) {
checkDeviceWidth();
}
......@@ -33,7 +60,7 @@ function upx2px(number, newDeviceWidth) {
}
}
return number < 0 ? -result : result;
}
}, Upx2pxProtocol);
var HOOKS;
(function (HOOKS) {
......@@ -139,6 +166,15 @@ function invokeApi(method, api, options, ...params) {
return api(options, ...params);
}
const AddInterceptorProtocol = [
{
name: 'method',
type: [String, Object],
required: true
}
];
const RemoveInterceptorProtocol = AddInterceptorProtocol;
function mergeInterceptorHook(interceptors, interceptor) {
Object.keys(interceptor).forEach(hook => {
if (isFunction(interceptor[hook])) {
......@@ -184,15 +220,15 @@ function removeHook(hooks, hook) {
hooks.splice(index, 1);
}
}
function addInterceptor(method, interceptor) {
const addInterceptor = createApi({ type: API_TYPE_SYNC, name: 'addInterceptor' }, (method, interceptor) => {
if (typeof method === 'string' && isPlainObject(interceptor)) {
mergeInterceptorHook(scopedInterceptors[method] || (scopedInterceptors[method] = {}), interceptor);
}
else if (isPlainObject(method)) {
mergeInterceptorHook(globalInterceptors, method);
}
}
function removeInterceptor(method, interceptor) {
}, AddInterceptorProtocol);
const removeInterceptor = createApi({ type: API_TYPE_SYNC, name: 'removeInterceptor' }, (method, interceptor) => {
if (typeof method === 'string') {
if (isPlainObject(interceptor)) {
removeInterceptorHook(scopedInterceptors[method], interceptor);
......@@ -204,7 +240,7 @@ function removeInterceptor(method, interceptor) {
else if (isPlainObject(method)) {
removeInterceptorHook(globalInterceptors, method);
}
}
}, RemoveInterceptorProtocol);
const SYNC_API_RE = /^\$|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/;
const CONTEXT_API_RE = /^create|Manager$/;
......@@ -450,7 +486,20 @@ function addSafeAreaInsets(fromRes, toRes) {
const getSystemInfo = {
returnValue: addSafeAreaInsets
};
const getSystemInfoSync = getSystemInfo;
const getSystemInfoSync = getSystemInfo;
const redirectTo = {};
const createCanvasContext = {
returnValue(fromRes, toRes) {
const measureText = fromRes.measureText;
toRes.measureText = function (text, callback) {
const textMetrics = measureText.call(this, text);
if (typeof callback === 'function') {
setTimeout(() => callback(textMetrics), 0);
}
return textMetrics;
};
}
};
const getProvider = initGetProvider({
oauth: ['weixin'],
......@@ -466,9 +515,11 @@ var shims = /*#__PURE__*/Object.freeze({
var protocols = /*#__PURE__*/Object.freeze({
__proto__: null,
redirectTo: redirectTo,
previewImage: previewImage,
getSystemInfo: getSystemInfo,
getSystemInfoSync: getSystemInfoSync
getSystemInfoSync: getSystemInfoSync,
createCanvasContext: createCanvasContext
});
var index = initUni(shims, protocols);
......
......@@ -52,28 +52,6 @@ const MP_METHODS = [
'selectAllComponents',
'selectComponent'
];
function hasHook(name) {
const hooks = this.$[name];
if (hooks && hooks.length) {
return true;
}
return false;
}
function callHook(name, args) {
if (name === 'mounted') {
callHook.call(this, 'bm'); // beforeMount
this.$.isMounted = true;
name = 'm';
}
const hooks = this.$[name];
let ret;
if (hooks) {
for (let i = 0; i < hooks.length; i++) {
ret = hooks[i](args);
}
}
return ret;
}
function createEmitFn(oldEmit, ctx) {
return function emit(event, ...args) {
if (ctx.$scope && event) {
......@@ -82,9 +60,6 @@ function createEmitFn(oldEmit, ctx) {
return oldEmit.apply(this, [event, ...args]);
};
}
function set(target, key, val) {
return (target[key] = val);
}
function initBaseInstance(instance, options) {
const ctx = instance.ctx;
// mp
......@@ -93,7 +68,9 @@ function initBaseInstance(instance, options) {
ctx.$scope = options.mpInstance;
// TODO @deprecated
ctx.$mp = {};
ctx._self = {};
if (__VUE_OPTIONS_API__) {
ctx._self = {};
}
// $vm
ctx.$scope.$vm = instance.proxy;
// slots
......@@ -105,15 +82,8 @@ function initBaseInstance(instance, options) {
});
}
}
if (__VUE_OPTIONS_API__) {
// $set
ctx.$set = set;
}
// $emit
instance.emit = createEmitFn(instance.emit, ctx);
// $callHook
ctx.$hasHook = hasHook;
ctx.$callHook = callHook;
}
function initComponentInstance(instance, options) {
initBaseInstance(instance, options);
......@@ -207,7 +177,7 @@ function parseApp(instance, parseAppOptions) {
$vm: instance,
onLaunch(options) {
const ctx = internalInstance.ctx;
if (this.$vm && ctx.$callHook) {
if (this.$vm && ctx.$scope) {
// 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
return;
}
......@@ -238,6 +208,26 @@ function initCreateApp(parseAppOptions) {
};
}
const encode = encodeURIComponent;
function stringifyQuery(obj, encodeStr = encode) {
const res = obj
? Object.keys(obj)
.map(key => {
let val = obj[key];
if (typeof val === undefined || val === null) {
val = '';
}
else if (isPlainObject(val)) {
val = JSON.stringify(val);
}
return encodeStr(key) + '=' + encodeStr(val);
})
.filter(x => x.length > 0)
.join('&')
: null;
return res ? `?${res}` : '';
}
function initBehavior(options) {
return Behavior(options);
}
......@@ -791,6 +781,13 @@ function parsePage(vueOptions, parseOptions) {
initLifetimes
});
const methods = miniProgramPageOptions.methods;
methods.onLoad = function (query) {
this.options = query;
this.$page = {
fullPath: '/' + this.route + stringifyQuery(query)
};
return this.$vm && this.$vm.$callHook('onLoad', query);
};
initHooks(methods, PAGE_HOOKS);
initUnknownHooks(methods, vueOptions);
parse && parse(miniProgramPageOptions, { handleLink });
......
import { isArray, isPromise, isFunction, isPlainObject, hasOwn, isString } from '@vue/shared';
const API_TYPE_SYNC = 1;
function validateProtocol(_name, _args, _protocol) {
return true;
}
function formatApiArgs(args, options) {
if (!options) {
return args;
}
}
function createApi({ type, name, options }, fn, protocol) {
return function (...args) {
if (type === API_TYPE_SYNC) {
if (!((process.env.NODE_ENV !== 'production') && protocol && !validateProtocol())) {
return fn.apply(null, formatApiArgs(args, options));
}
}
};
}
const Upx2pxProtocol = [
{
name: 'upx',
type: [Number, String],
required: true
}
];
const EPS = 1e-4;
const BASE_DEVICE_WIDTH = 750;
let isIOS = false;
......@@ -11,7 +38,7 @@ function checkDeviceWidth() {
deviceDPR = pixelRatio;
isIOS = platform === 'ios';
}
function upx2px(number, newDeviceWidth) {
const upx2px = createApi({ type: API_TYPE_SYNC, name: 'upx2px' }, (number, newDeviceWidth) => {
if (deviceWidth === 0) {
checkDeviceWidth();
}
......@@ -33,7 +60,7 @@ function upx2px(number, newDeviceWidth) {
}
}
return number < 0 ? -result : result;
}
}, Upx2pxProtocol);
var HOOKS;
(function (HOOKS) {
......@@ -139,6 +166,15 @@ function invokeApi(method, api, options, ...params) {
return api(options, ...params);
}
const AddInterceptorProtocol = [
{
name: 'method',
type: [String, Object],
required: true
}
];
const RemoveInterceptorProtocol = AddInterceptorProtocol;
function mergeInterceptorHook(interceptors, interceptor) {
Object.keys(interceptor).forEach(hook => {
if (isFunction(interceptor[hook])) {
......@@ -184,15 +220,15 @@ function removeHook(hooks, hook) {
hooks.splice(index, 1);
}
}
function addInterceptor(method, interceptor) {
const addInterceptor = createApi({ type: API_TYPE_SYNC, name: 'addInterceptor' }, (method, interceptor) => {
if (typeof method === 'string' && isPlainObject(interceptor)) {
mergeInterceptorHook(scopedInterceptors[method] || (scopedInterceptors[method] = {}), interceptor);
}
else if (isPlainObject(method)) {
mergeInterceptorHook(globalInterceptors, method);
}
}
function removeInterceptor(method, interceptor) {
}, AddInterceptorProtocol);
const removeInterceptor = createApi({ type: API_TYPE_SYNC, name: 'removeInterceptor' }, (method, interceptor) => {
if (typeof method === 'string') {
if (isPlainObject(interceptor)) {
removeInterceptorHook(scopedInterceptors[method], interceptor);
......@@ -204,7 +240,7 @@ function removeInterceptor(method, interceptor) {
else if (isPlainObject(method)) {
removeInterceptorHook(globalInterceptors, method);
}
}
}, RemoveInterceptorProtocol);
const SYNC_API_RE = /^\$|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/;
const CONTEXT_API_RE = /^create|Manager$/;
......@@ -450,7 +486,20 @@ function addSafeAreaInsets(fromRes, toRes) {
const getSystemInfo = {
returnValue: addSafeAreaInsets
};
const getSystemInfoSync = getSystemInfo;
const getSystemInfoSync = getSystemInfo;
const redirectTo = {};
const createCanvasContext = {
returnValue(fromRes, toRes) {
const measureText = fromRes.measureText;
toRes.measureText = function (text, callback) {
const textMetrics = measureText.call(this, text);
if (typeof callback === 'function') {
setTimeout(() => callback(textMetrics), 0);
}
return textMetrics;
};
}
};
const providers = {
oauth: [],
......@@ -473,9 +522,11 @@ var shims = /*#__PURE__*/Object.freeze({
var protocols = /*#__PURE__*/Object.freeze({
__proto__: null,
redirectTo: redirectTo,
previewImage: previewImage,
getSystemInfo: getSystemInfo,
getSystemInfoSync: getSystemInfoSync
getSystemInfoSync: getSystemInfoSync,
createCanvasContext: createCanvasContext
});
var index = initUni(shims, protocols);
......
......@@ -52,28 +52,6 @@ const MP_METHODS = [
'selectAllComponents',
'selectComponent'
];
function hasHook(name) {
const hooks = this.$[name];
if (hooks && hooks.length) {
return true;
}
return false;
}
function callHook(name, args) {
if (name === 'mounted') {
callHook.call(this, 'bm'); // beforeMount
this.$.isMounted = true;
name = 'm';
}
const hooks = this.$[name];
let ret;
if (hooks) {
for (let i = 0; i < hooks.length; i++) {
ret = hooks[i](args);
}
}
return ret;
}
function createEmitFn(oldEmit, ctx) {
return function emit(event, ...args) {
if (ctx.$scope && event) {
......@@ -82,9 +60,6 @@ function createEmitFn(oldEmit, ctx) {
return oldEmit.apply(this, [event, ...args]);
};
}
function set(target, key, val) {
return (target[key] = val);
}
function initBaseInstance(instance, options) {
const ctx = instance.ctx;
// mp
......@@ -93,7 +68,9 @@ function initBaseInstance(instance, options) {
ctx.$scope = options.mpInstance;
// TODO @deprecated
ctx.$mp = {};
ctx._self = {};
if (__VUE_OPTIONS_API__) {
ctx._self = {};
}
// $vm
ctx.$scope.$vm = instance.proxy;
// slots
......@@ -105,15 +82,8 @@ function initBaseInstance(instance, options) {
});
}
}
if (__VUE_OPTIONS_API__) {
// $set
ctx.$set = set;
}
// $emit
instance.emit = createEmitFn(instance.emit, ctx);
// $callHook
ctx.$hasHook = hasHook;
ctx.$callHook = callHook;
}
function initComponentInstance(instance, options) {
initBaseInstance(instance, options);
......@@ -207,7 +177,7 @@ function parseApp(instance, parseAppOptions) {
$vm: instance,
onLaunch(options) {
const ctx = internalInstance.ctx;
if (this.$vm && ctx.$callHook) {
if (this.$vm && ctx.$scope) {
// 已经初始化过了,主要是为了百度,百度 onShow 在 onLaunch 之前
return;
}
......@@ -238,6 +208,26 @@ function initCreateApp(parseAppOptions) {
};
}
const encode = encodeURIComponent;
function stringifyQuery(obj, encodeStr = encode) {
const res = obj
? Object.keys(obj)
.map(key => {
let val = obj[key];
if (typeof val === undefined || val === null) {
val = '';
}
else if (isPlainObject(val)) {
val = JSON.stringify(val);
}
return encodeStr(key) + '=' + encodeStr(val);
})
.filter(x => x.length > 0)
.join('&')
: null;
return res ? `?${res}` : '';
}
function initBehavior(options) {
return Behavior(options);
}
......@@ -772,6 +762,13 @@ function parsePage(vueOptions, parseOptions) {
initLifetimes
});
const methods = miniProgramPageOptions.methods;
methods.onLoad = function (query) {
this.options = query;
this.$page = {
fullPath: '/' + this.route + stringifyQuery(query)
};
return this.$vm && this.$vm.$callHook('onLoad', query);
};
initHooks(methods, PAGE_HOOKS);
initUnknownHooks(methods, vueOptions);
parse && parse(miniProgramPageOptions, { handleLink });
......@@ -969,7 +966,7 @@ function initLifetimes$1(lifetimesOptions) {
const mocks = ['nodeId', 'componentName', '_componentId', 'uniquePrefix'];
function isPage(mpInstance) {
return !mpInstance.ownerId;
return !hasOwn(mpInstance, 'ownerId');
}
function initRelation(mpInstance) {
......
......@@ -47,7 +47,7 @@ const tags = [
'video',
'view',
'web-view',
'editor',
'editor'
]
const baseCompiler = {
......
......@@ -58,7 +58,7 @@ module.exports = (api, options, rootOptions) => {
'@dcloudio/uni-quickapp-native': version,
'@dcloudio/uni-quickapp-webview': version,
'@dcloudio/uni-stat': version,
'@vue/shared': '^3.0.0-rc.4', // TODO
'@vue/shared': '^3.0.0',
flyio: '^0.6.2',
vuex: '^3.2.0'
},
......
......@@ -29,6 +29,11 @@ export default function parsePage (vuePageOptions) {
initRelation
})
const onInit = (vuePageOptions.default || vuePageOptions).onInit
if (onInit) {
pageOptions.methods.onInit = onInit
}
// 纠正百度小程序生命周期methods:onShow在methods:onLoad之前触发的问题
pageOptions.methods.onShow = function onShow () {
if (this.$vm && this.$vm.$mp.query) {
......
......@@ -8,7 +8,7 @@ export default function createMediaQueryObserver () {
const orientation = windowWidth < windowHeight ? 'portrait' : 'landscape'
mediaQueryObserver.observe = (options, callback) => {
let matches = false
let matches = true
for (const item in options) {
const itemValue = item === 'orientation' ? options[item] : Number(options[item])
if (options[item] !== '') {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册