@dcloudio/uni-mp-qq 2.0.0 → 2.0.1-32920211122002
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +367 -123
- package/dist/uni.api.esm.js +500 -132
- package/dist/uni.mp.esm.js +518 -187
- package/package.json +2 -2
package/dist/uni.mp.esm.js
CHANGED
|
@@ -1,4 +1,329 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isPlainObject, hasOwn, isArray, extend, hyphenate, isObject, toNumber, isFunction, NOOP, camelize } from '@vue/shared';
|
|
2
|
+
import { onUnmounted, injectHook, ref } from 'vue';
|
|
3
|
+
|
|
4
|
+
const encode = encodeURIComponent;
|
|
5
|
+
function stringifyQuery(obj, encodeStr = encode) {
|
|
6
|
+
const res = obj
|
|
7
|
+
? Object.keys(obj)
|
|
8
|
+
.map((key) => {
|
|
9
|
+
let val = obj[key];
|
|
10
|
+
if (typeof val === undefined || val === null) {
|
|
11
|
+
val = '';
|
|
12
|
+
}
|
|
13
|
+
else if (isPlainObject(val)) {
|
|
14
|
+
val = JSON.stringify(val);
|
|
15
|
+
}
|
|
16
|
+
return encodeStr(key) + '=' + encodeStr(val);
|
|
17
|
+
})
|
|
18
|
+
.filter((x) => x.length > 0)
|
|
19
|
+
.join('&')
|
|
20
|
+
: null;
|
|
21
|
+
return res ? `?${res}` : '';
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function cache(fn) {
|
|
25
|
+
const cache = Object.create(null);
|
|
26
|
+
return (str) => {
|
|
27
|
+
const hit = cache[str];
|
|
28
|
+
return hit || (cache[str] = fn(str));
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
const invokeArrayFns = (fns, arg) => {
|
|
32
|
+
let ret;
|
|
33
|
+
for (let i = 0; i < fns.length; i++) {
|
|
34
|
+
ret = fns[i](arg);
|
|
35
|
+
}
|
|
36
|
+
return ret;
|
|
37
|
+
};
|
|
38
|
+
// lifecycle
|
|
39
|
+
// App and Page
|
|
40
|
+
const ON_SHOW = 'onShow';
|
|
41
|
+
const ON_HIDE = 'onHide';
|
|
42
|
+
//App
|
|
43
|
+
const ON_LAUNCH = 'onLaunch';
|
|
44
|
+
const ON_ERROR = 'onError';
|
|
45
|
+
const ON_THEME_CHANGE = 'onThemeChange';
|
|
46
|
+
const ON_PAGE_NOT_FOUND = 'onPageNotFound';
|
|
47
|
+
const ON_UNHANDLE_REJECTION = 'onUnhandledRejection';
|
|
48
|
+
//Page
|
|
49
|
+
const ON_LOAD = 'onLoad';
|
|
50
|
+
const ON_READY = 'onReady';
|
|
51
|
+
const ON_UNLOAD = 'onUnload';
|
|
52
|
+
const ON_RESIZE = 'onResize';
|
|
53
|
+
const ON_TAB_ITEM_TAP = 'onTabItemTap';
|
|
54
|
+
const ON_REACH_BOTTOM = 'onReachBottom';
|
|
55
|
+
const ON_PULL_DOWN_REFRESH = 'onPullDownRefresh';
|
|
56
|
+
const ON_ADD_TO_FAVORITES = 'onAddToFavorites';
|
|
57
|
+
|
|
58
|
+
class EventChannel {
|
|
59
|
+
constructor(id, events) {
|
|
60
|
+
this.id = id;
|
|
61
|
+
this.listener = {};
|
|
62
|
+
this.emitCache = {};
|
|
63
|
+
if (events) {
|
|
64
|
+
Object.keys(events).forEach((name) => {
|
|
65
|
+
this.on(name, events[name]);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
emit(eventName, ...args) {
|
|
70
|
+
const fns = this.listener[eventName];
|
|
71
|
+
if (!fns) {
|
|
72
|
+
return (this.emitCache[eventName] || (this.emitCache[eventName] = [])).push(args);
|
|
73
|
+
}
|
|
74
|
+
fns.forEach((opt) => {
|
|
75
|
+
opt.fn.apply(opt.fn, args);
|
|
76
|
+
});
|
|
77
|
+
this.listener[eventName] = fns.filter((opt) => opt.type !== 'once');
|
|
78
|
+
}
|
|
79
|
+
on(eventName, fn) {
|
|
80
|
+
this._addListener(eventName, 'on', fn);
|
|
81
|
+
this._clearCache(eventName);
|
|
82
|
+
}
|
|
83
|
+
once(eventName, fn) {
|
|
84
|
+
this._addListener(eventName, 'once', fn);
|
|
85
|
+
this._clearCache(eventName);
|
|
86
|
+
}
|
|
87
|
+
off(eventName, fn) {
|
|
88
|
+
const fns = this.listener[eventName];
|
|
89
|
+
if (!fns) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
if (fn) {
|
|
93
|
+
for (let i = 0; i < fns.length;) {
|
|
94
|
+
if (fns[i].fn === fn) {
|
|
95
|
+
fns.splice(i, 1);
|
|
96
|
+
i--;
|
|
97
|
+
}
|
|
98
|
+
i++;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
delete this.listener[eventName];
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
_clearCache(eventName) {
|
|
106
|
+
const cacheArgs = this.emitCache[eventName];
|
|
107
|
+
if (cacheArgs) {
|
|
108
|
+
for (; cacheArgs.length > 0;) {
|
|
109
|
+
this.emit.apply(this, [eventName, ...cacheArgs.shift()]);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
_addListener(eventName, type, fn) {
|
|
114
|
+
(this.listener[eventName] || (this.listener[eventName] = [])).push({
|
|
115
|
+
fn,
|
|
116
|
+
type,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const eventChannels = {};
|
|
122
|
+
const eventChannelStack = [];
|
|
123
|
+
function getEventChannel(id) {
|
|
124
|
+
if (id) {
|
|
125
|
+
const eventChannel = eventChannels[id];
|
|
126
|
+
delete eventChannels[id];
|
|
127
|
+
return eventChannel;
|
|
128
|
+
}
|
|
129
|
+
return eventChannelStack.shift();
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function initBehavior(options) {
|
|
133
|
+
return Behavior(options);
|
|
134
|
+
}
|
|
135
|
+
function initVueIds(vueIds, mpInstance) {
|
|
136
|
+
if (!vueIds) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
const ids = vueIds.split(',');
|
|
140
|
+
const len = ids.length;
|
|
141
|
+
if (len === 1) {
|
|
142
|
+
mpInstance._$vueId = ids[0];
|
|
143
|
+
}
|
|
144
|
+
else if (len === 2) {
|
|
145
|
+
mpInstance._$vueId = ids[0];
|
|
146
|
+
mpInstance._$vuePid = ids[1];
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
const EXTRAS = ['externalClasses'];
|
|
150
|
+
function initExtraOptions(miniProgramComponentOptions, vueOptions) {
|
|
151
|
+
EXTRAS.forEach((name) => {
|
|
152
|
+
if (hasOwn(vueOptions, name)) {
|
|
153
|
+
miniProgramComponentOptions[name] = vueOptions[name];
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
function initWxsCallMethods(methods, wxsCallMethods) {
|
|
158
|
+
if (!isArray(wxsCallMethods)) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
wxsCallMethods.forEach((callMethod) => {
|
|
162
|
+
methods[callMethod] = function (args) {
|
|
163
|
+
return this.$vm[callMethod](args);
|
|
164
|
+
};
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
function selectAllComponents(mpInstance, selector, $refs) {
|
|
168
|
+
const components = mpInstance.selectAllComponents(selector);
|
|
169
|
+
components.forEach((component) => {
|
|
170
|
+
const ref = component.dataset.ref;
|
|
171
|
+
$refs[ref] = component.$vm || component;
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
function initRefs(instance, mpInstance) {
|
|
175
|
+
Object.defineProperty(instance, 'refs', {
|
|
176
|
+
get() {
|
|
177
|
+
const $refs = {};
|
|
178
|
+
selectAllComponents(mpInstance, '.vue-ref', $refs);
|
|
179
|
+
const forComponents = mpInstance.selectAllComponents('.vue-ref-in-for');
|
|
180
|
+
forComponents.forEach((component) => {
|
|
181
|
+
const ref = component.dataset.ref;
|
|
182
|
+
if (!$refs[ref]) {
|
|
183
|
+
$refs[ref] = [];
|
|
184
|
+
}
|
|
185
|
+
$refs[ref].push(component.$vm || component);
|
|
186
|
+
});
|
|
187
|
+
return $refs;
|
|
188
|
+
},
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
function findVmByVueId(instance, vuePid) {
|
|
192
|
+
// 标准 vue3 中 没有 $children,定制了内核
|
|
193
|
+
const $children = instance.$children;
|
|
194
|
+
// 优先查找直属(反向查找:https://github.com/dcloudio/uni-app/issues/1200)
|
|
195
|
+
for (let i = $children.length - 1; i >= 0; i--) {
|
|
196
|
+
const childVm = $children[i];
|
|
197
|
+
if (childVm.$scope._$vueId === vuePid) {
|
|
198
|
+
return childVm;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
// 反向递归查找
|
|
202
|
+
let parentVm;
|
|
203
|
+
for (let i = $children.length - 1; i >= 0; i--) {
|
|
204
|
+
parentVm = findVmByVueId($children[i], vuePid);
|
|
205
|
+
if (parentVm) {
|
|
206
|
+
return parentVm;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
function getTarget(obj, path) {
|
|
211
|
+
const parts = path.split('.');
|
|
212
|
+
let key = parts[0];
|
|
213
|
+
if (key.indexOf('__$n') === 0) {
|
|
214
|
+
//number index
|
|
215
|
+
key = parseInt(key.replace('__$n', ''));
|
|
216
|
+
}
|
|
217
|
+
if (!obj) {
|
|
218
|
+
obj = {};
|
|
219
|
+
}
|
|
220
|
+
if (parts.length === 1) {
|
|
221
|
+
return obj[key];
|
|
222
|
+
}
|
|
223
|
+
return getTarget(obj[key], parts.slice(1).join('.'));
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
function getValue(dataPath, target) {
|
|
227
|
+
return getTarget(target || this, dataPath);
|
|
228
|
+
}
|
|
229
|
+
function getClass(dynamicClass, staticClass) {
|
|
230
|
+
return renderClass(staticClass, dynamicClass);
|
|
231
|
+
}
|
|
232
|
+
function getStyle(dynamicStyle, staticStyle) {
|
|
233
|
+
if (!dynamicStyle && !staticStyle) {
|
|
234
|
+
return '';
|
|
235
|
+
}
|
|
236
|
+
var dynamicStyleObj = normalizeStyleBinding(dynamicStyle);
|
|
237
|
+
var styleObj = staticStyle
|
|
238
|
+
? extend(staticStyle, dynamicStyleObj)
|
|
239
|
+
: dynamicStyleObj;
|
|
240
|
+
return Object.keys(styleObj)
|
|
241
|
+
.map(function (name) {
|
|
242
|
+
return hyphenate(name) + ':' + styleObj[name];
|
|
243
|
+
})
|
|
244
|
+
.join(';');
|
|
245
|
+
}
|
|
246
|
+
function toObject(arr) {
|
|
247
|
+
var res = {};
|
|
248
|
+
for (var i = 0; i < arr.length; i++) {
|
|
249
|
+
if (arr[i]) {
|
|
250
|
+
extend(res, arr[i]);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
return res;
|
|
254
|
+
}
|
|
255
|
+
function normalizeStyleBinding(bindingStyle) {
|
|
256
|
+
if (Array.isArray(bindingStyle)) {
|
|
257
|
+
return toObject(bindingStyle);
|
|
258
|
+
}
|
|
259
|
+
if (typeof bindingStyle === 'string') {
|
|
260
|
+
return parseStyleText(bindingStyle);
|
|
261
|
+
}
|
|
262
|
+
return bindingStyle;
|
|
263
|
+
}
|
|
264
|
+
var parseStyleText = cache(function parseStyleText(cssText) {
|
|
265
|
+
var res = {};
|
|
266
|
+
var listDelimiter = /;(?![^(]*\))/g;
|
|
267
|
+
var propertyDelimiter = /:(.+)/;
|
|
268
|
+
cssText.split(listDelimiter).forEach(function (item) {
|
|
269
|
+
if (item) {
|
|
270
|
+
var tmp = item.split(propertyDelimiter);
|
|
271
|
+
tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim());
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
return res;
|
|
275
|
+
});
|
|
276
|
+
function isDef(v) {
|
|
277
|
+
return v !== undefined && v !== null;
|
|
278
|
+
}
|
|
279
|
+
function renderClass(staticClass, dynamicClass) {
|
|
280
|
+
if (isDef(staticClass) || isDef(dynamicClass)) {
|
|
281
|
+
return concat(staticClass, stringifyClass(dynamicClass));
|
|
282
|
+
}
|
|
283
|
+
/* istanbul ignore next */
|
|
284
|
+
return '';
|
|
285
|
+
}
|
|
286
|
+
function concat(a, b) {
|
|
287
|
+
return a ? (b ? a + ' ' + b : a) : b || '';
|
|
288
|
+
}
|
|
289
|
+
function stringifyClass(value) {
|
|
290
|
+
if (Array.isArray(value)) {
|
|
291
|
+
return stringifyArray(value);
|
|
292
|
+
}
|
|
293
|
+
if (isObject(value)) {
|
|
294
|
+
return stringifyObject(value);
|
|
295
|
+
}
|
|
296
|
+
if (typeof value === 'string') {
|
|
297
|
+
return value;
|
|
298
|
+
}
|
|
299
|
+
/* istanbul ignore next */
|
|
300
|
+
return '';
|
|
301
|
+
}
|
|
302
|
+
function stringifyArray(value) {
|
|
303
|
+
var res = '';
|
|
304
|
+
var stringified;
|
|
305
|
+
for (var i = 0, l = value.length; i < l; i++) {
|
|
306
|
+
if (isDef((stringified = stringifyClass(value[i]))) && stringified !== '') {
|
|
307
|
+
if (res) {
|
|
308
|
+
res += ' ';
|
|
309
|
+
}
|
|
310
|
+
res += stringified;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
return res;
|
|
314
|
+
}
|
|
315
|
+
function stringifyObject(value) {
|
|
316
|
+
var res = '';
|
|
317
|
+
for (var key in value) {
|
|
318
|
+
if (value[key]) {
|
|
319
|
+
if (res) {
|
|
320
|
+
res += ' ';
|
|
321
|
+
}
|
|
322
|
+
res += key;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
return res;
|
|
326
|
+
}
|
|
2
327
|
|
|
3
328
|
function setModel(target, key, value, modifiers) {
|
|
4
329
|
if (isArray(modifiers)) {
|
|
@@ -50,7 +375,7 @@ const MP_METHODS = [
|
|
|
50
375
|
'createSelectorQuery',
|
|
51
376
|
'createIntersectionObserver',
|
|
52
377
|
'selectAllComponents',
|
|
53
|
-
'selectComponent'
|
|
378
|
+
'selectComponent',
|
|
54
379
|
];
|
|
55
380
|
function createEmitFn(oldEmit, ctx) {
|
|
56
381
|
return function emit(event, ...args) {
|
|
@@ -77,18 +402,29 @@ function initBaseInstance(instance, options) {
|
|
|
77
402
|
{
|
|
78
403
|
instance.slots = {};
|
|
79
404
|
if (isArray(options.slots) && options.slots.length) {
|
|
80
|
-
options.slots.forEach(name => {
|
|
405
|
+
options.slots.forEach((name) => {
|
|
81
406
|
instance.slots[name] = true;
|
|
82
407
|
});
|
|
83
408
|
}
|
|
84
409
|
}
|
|
410
|
+
ctx.getOpenerEventChannel = function () {
|
|
411
|
+
if (!this.__eventChannel__) {
|
|
412
|
+
this.__eventChannel__ = new EventChannel();
|
|
413
|
+
}
|
|
414
|
+
return this.__eventChannel__;
|
|
415
|
+
};
|
|
416
|
+
ctx.$hasHook = hasHook;
|
|
417
|
+
ctx.$callHook = callHook;
|
|
85
418
|
// $emit
|
|
86
419
|
instance.emit = createEmitFn(instance.emit, ctx);
|
|
87
420
|
}
|
|
88
421
|
function initComponentInstance(instance, options) {
|
|
89
422
|
initBaseInstance(instance, options);
|
|
423
|
+
{
|
|
424
|
+
initScopedSlotsParams(instance);
|
|
425
|
+
}
|
|
90
426
|
const ctx = instance.ctx;
|
|
91
|
-
MP_METHODS.forEach(method => {
|
|
427
|
+
MP_METHODS.forEach((method) => {
|
|
92
428
|
ctx[method] = function (...args) {
|
|
93
429
|
const mpInstance = ctx.$scope;
|
|
94
430
|
if (mpInstance && mpInstance[method]) {
|
|
@@ -101,36 +437,105 @@ function initComponentInstance(instance, options) {
|
|
|
101
437
|
ctx.__set_sync = setSync;
|
|
102
438
|
ctx.__get_orig = getOrig;
|
|
103
439
|
// TODO
|
|
104
|
-
|
|
440
|
+
ctx.__get_value = getValue;
|
|
441
|
+
ctx.__get_class = getClass;
|
|
442
|
+
ctx.__get_style = getStyle;
|
|
105
443
|
ctx.__map = map;
|
|
106
444
|
}
|
|
107
445
|
function initMocks(instance, mpInstance, mocks) {
|
|
108
446
|
const ctx = instance.ctx;
|
|
109
|
-
mocks.forEach(mock => {
|
|
447
|
+
mocks.forEach((mock) => {
|
|
110
448
|
if (hasOwn(mpInstance, mock)) {
|
|
111
449
|
ctx[mock] = mpInstance[mock];
|
|
112
450
|
}
|
|
113
451
|
});
|
|
452
|
+
}
|
|
453
|
+
function hasHook(name) {
|
|
454
|
+
const hooks = this.$[name];
|
|
455
|
+
if (hooks && hooks.length) {
|
|
456
|
+
return true;
|
|
457
|
+
}
|
|
458
|
+
return false;
|
|
459
|
+
}
|
|
460
|
+
function callHook(name, args) {
|
|
461
|
+
if (name === 'mounted') {
|
|
462
|
+
callHook.call(this, 'bm'); // beforeMount
|
|
463
|
+
this.$.isMounted = true;
|
|
464
|
+
name = 'm';
|
|
465
|
+
}
|
|
466
|
+
else if (name === 'onLoad' && args && args.__id__) {
|
|
467
|
+
this.__eventChannel__ = getEventChannel(args.__id__);
|
|
468
|
+
delete args.__id__;
|
|
469
|
+
}
|
|
470
|
+
const hooks = this.$[name];
|
|
471
|
+
return hooks && invokeArrayFns(hooks, args);
|
|
472
|
+
}
|
|
473
|
+
const center = {};
|
|
474
|
+
const parents = {};
|
|
475
|
+
function initScopedSlotsParams(instance) {
|
|
476
|
+
const ctx = instance.ctx;
|
|
477
|
+
ctx.$hasScopedSlotsParams = function (vueId) {
|
|
478
|
+
const has = center[vueId];
|
|
479
|
+
if (!has) {
|
|
480
|
+
parents[vueId] = this;
|
|
481
|
+
onUnmounted(() => {
|
|
482
|
+
delete parents[vueId];
|
|
483
|
+
}, instance);
|
|
484
|
+
}
|
|
485
|
+
return has;
|
|
486
|
+
};
|
|
487
|
+
ctx.$getScopedSlotsParams = function (vueId, name, key) {
|
|
488
|
+
const data = center[vueId];
|
|
489
|
+
if (data) {
|
|
490
|
+
const object = data[name] || {};
|
|
491
|
+
return key ? object[key] : object;
|
|
492
|
+
}
|
|
493
|
+
else {
|
|
494
|
+
parents[vueId] = this;
|
|
495
|
+
onUnmounted(() => {
|
|
496
|
+
delete parents[vueId];
|
|
497
|
+
}, instance);
|
|
498
|
+
}
|
|
499
|
+
};
|
|
500
|
+
ctx.$setScopedSlotsParams = function (name, value) {
|
|
501
|
+
const vueIds = instance.attrs.vueId;
|
|
502
|
+
if (vueIds) {
|
|
503
|
+
const vueId = vueIds.split(',')[0];
|
|
504
|
+
const object = (center[vueId] = center[vueId] || {});
|
|
505
|
+
object[name] = value;
|
|
506
|
+
if (parents[vueId]) {
|
|
507
|
+
parents[vueId].$forceUpdate();
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
};
|
|
511
|
+
onUnmounted(function () {
|
|
512
|
+
const propsData = instance.attrs;
|
|
513
|
+
const vueId = propsData && propsData.vueId;
|
|
514
|
+
if (vueId) {
|
|
515
|
+
delete center[vueId];
|
|
516
|
+
delete parents[vueId];
|
|
517
|
+
}
|
|
518
|
+
}, instance);
|
|
114
519
|
}
|
|
115
520
|
|
|
116
521
|
const PAGE_HOOKS = [
|
|
117
|
-
|
|
118
|
-
|
|
522
|
+
ON_LOAD,
|
|
523
|
+
ON_SHOW,
|
|
524
|
+
ON_HIDE,
|
|
525
|
+
ON_UNLOAD,
|
|
526
|
+
ON_RESIZE,
|
|
527
|
+
ON_TAB_ITEM_TAP,
|
|
528
|
+
ON_REACH_BOTTOM,
|
|
529
|
+
ON_PULL_DOWN_REFRESH,
|
|
530
|
+
ON_ADD_TO_FAVORITES,
|
|
119
531
|
// 'onReady', // lifetimes.ready
|
|
120
|
-
'onHide',
|
|
121
|
-
'onUnload',
|
|
122
|
-
'onResize',
|
|
123
532
|
// 'onPageScroll', // 影响性能,开发者手动注册
|
|
124
|
-
'onTabItemTap',
|
|
125
|
-
'onReachBottom',
|
|
126
|
-
'onPullDownRefresh',
|
|
127
533
|
// 'onShareTimeline', // 右上角菜单,开发者手动注册
|
|
128
|
-
'onAddToFavorites'
|
|
129
534
|
// 'onShareAppMessage' // 右上角菜单,开发者手动注册
|
|
130
535
|
];
|
|
131
536
|
function findHooks(vueOptions, hooks = new Set()) {
|
|
132
537
|
if (vueOptions) {
|
|
133
|
-
Object.keys(vueOptions).forEach(name => {
|
|
538
|
+
Object.keys(vueOptions).forEach((name) => {
|
|
134
539
|
if (name.indexOf('on') === 0 && isFunction(vueOptions[name])) {
|
|
135
540
|
hooks.add(name);
|
|
136
541
|
}
|
|
@@ -138,7 +543,7 @@ function findHooks(vueOptions, hooks = new Set()) {
|
|
|
138
543
|
if (__VUE_OPTIONS_API__) {
|
|
139
544
|
const { extends: extendsOptions, mixins } = vueOptions;
|
|
140
545
|
if (mixins) {
|
|
141
|
-
mixins.forEach(mixin => findHooks(mixin, hooks));
|
|
546
|
+
mixins.forEach((mixin) => findHooks(mixin, hooks));
|
|
142
547
|
}
|
|
143
548
|
if (extendsOptions) {
|
|
144
549
|
findHooks(extendsOptions, hooks);
|
|
@@ -147,28 +552,35 @@ function findHooks(vueOptions, hooks = new Set()) {
|
|
|
147
552
|
}
|
|
148
553
|
return hooks;
|
|
149
554
|
}
|
|
150
|
-
function initHook(mpOptions, hook, excludes) {
|
|
555
|
+
function initHook$1(mpOptions, hook, excludes) {
|
|
151
556
|
if (excludes.indexOf(hook) === -1 && !hasOwn(mpOptions, hook)) {
|
|
152
557
|
mpOptions[hook] = function (args) {
|
|
153
558
|
return this.$vm && this.$vm.$callHook(hook, args);
|
|
154
559
|
};
|
|
155
560
|
}
|
|
156
561
|
}
|
|
157
|
-
const EXCLUDE_HOOKS = [
|
|
562
|
+
const EXCLUDE_HOOKS = [ON_READY];
|
|
158
563
|
function initHooks(mpOptions, hooks, excludes = EXCLUDE_HOOKS) {
|
|
159
|
-
hooks.forEach(hook => initHook(mpOptions, hook, excludes));
|
|
564
|
+
hooks.forEach((hook) => initHook$1(mpOptions, hook, excludes));
|
|
160
565
|
}
|
|
161
566
|
function initUnknownHooks(mpOptions, vueOptions, excludes = EXCLUDE_HOOKS) {
|
|
162
|
-
findHooks(vueOptions).forEach(hook => initHook(mpOptions, hook, excludes));
|
|
567
|
+
findHooks(vueOptions).forEach((hook) => initHook$1(mpOptions, hook, excludes));
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
qq.appLaunchHooks = [];
|
|
571
|
+
function injectAppLaunchHooks(appInstance) {
|
|
572
|
+
qq.appLaunchHooks.forEach((hook) => {
|
|
573
|
+
injectHook(ON_LAUNCH, hook, appInstance);
|
|
574
|
+
});
|
|
163
575
|
}
|
|
164
576
|
|
|
165
577
|
const HOOKS = [
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
578
|
+
ON_SHOW,
|
|
579
|
+
ON_HIDE,
|
|
580
|
+
ON_ERROR,
|
|
581
|
+
ON_THEME_CHANGE,
|
|
582
|
+
ON_PAGE_NOT_FOUND,
|
|
583
|
+
ON_UNHANDLE_REJECTION,
|
|
172
584
|
];
|
|
173
585
|
function parseApp(instance, parseAppOptions) {
|
|
174
586
|
const internalInstance = instance.$;
|
|
@@ -184,12 +596,14 @@ function parseApp(instance, parseAppOptions) {
|
|
|
184
596
|
initBaseInstance(internalInstance, {
|
|
185
597
|
mpType: 'app',
|
|
186
598
|
mpInstance: this,
|
|
187
|
-
slots: []
|
|
599
|
+
slots: [],
|
|
188
600
|
});
|
|
601
|
+
injectAppLaunchHooks(internalInstance);
|
|
189
602
|
ctx.globalData = this.globalData;
|
|
190
|
-
instance.$callHook(
|
|
191
|
-
}
|
|
603
|
+
instance.$callHook(ON_LAUNCH, extend({ app: this }, options));
|
|
604
|
+
},
|
|
192
605
|
};
|
|
606
|
+
initLocale(instance);
|
|
193
607
|
const vueOptions = instance.$.type;
|
|
194
608
|
initHooks(appOptions, HOOKS);
|
|
195
609
|
initUnknownHooks(appOptions, vueOptions);
|
|
@@ -206,102 +620,17 @@ function initCreateApp(parseAppOptions) {
|
|
|
206
620
|
return function createApp(vm) {
|
|
207
621
|
return App(parseApp(vm, parseAppOptions));
|
|
208
622
|
};
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
const encode = encodeURIComponent;
|
|
212
|
-
function stringifyQuery(obj, encodeStr = encode) {
|
|
213
|
-
const res = obj
|
|
214
|
-
? Object.keys(obj)
|
|
215
|
-
.map(key => {
|
|
216
|
-
let val = obj[key];
|
|
217
|
-
if (typeof val === undefined || val === null) {
|
|
218
|
-
val = '';
|
|
219
|
-
}
|
|
220
|
-
else if (isPlainObject(val)) {
|
|
221
|
-
val = JSON.stringify(val);
|
|
222
|
-
}
|
|
223
|
-
return encodeStr(key) + '=' + encodeStr(val);
|
|
224
|
-
})
|
|
225
|
-
.filter(x => x.length > 0)
|
|
226
|
-
.join('&')
|
|
227
|
-
: null;
|
|
228
|
-
return res ? `?${res}` : '';
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
function initBehavior(options) {
|
|
232
|
-
return Behavior(options);
|
|
233
|
-
}
|
|
234
|
-
function initVueIds(vueIds, mpInstance) {
|
|
235
|
-
if (!vueIds) {
|
|
236
|
-
return;
|
|
237
|
-
}
|
|
238
|
-
const ids = vueIds.split(',');
|
|
239
|
-
const len = ids.length;
|
|
240
|
-
if (len === 1) {
|
|
241
|
-
mpInstance._$vueId = ids[0];
|
|
242
|
-
}
|
|
243
|
-
else if (len === 2) {
|
|
244
|
-
mpInstance._$vueId = ids[0];
|
|
245
|
-
mpInstance._$vuePid = ids[1];
|
|
246
|
-
}
|
|
247
623
|
}
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
if (hasOwn(vueOptions, name)) {
|
|
252
|
-
miniProgramComponentOptions[name] = vueOptions[name];
|
|
253
|
-
}
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
function initWxsCallMethods(methods, wxsCallMethods) {
|
|
257
|
-
if (!isArray(wxsCallMethods)) {
|
|
258
|
-
return;
|
|
259
|
-
}
|
|
260
|
-
wxsCallMethods.forEach((callMethod) => {
|
|
261
|
-
methods[callMethod] = function (args) {
|
|
262
|
-
return this.$vm[callMethod](args);
|
|
263
|
-
};
|
|
264
|
-
});
|
|
265
|
-
}
|
|
266
|
-
function initRefs(instance, mpInstance) {
|
|
267
|
-
Object.defineProperty(instance, 'refs', {
|
|
624
|
+
function initLocale(appVm) {
|
|
625
|
+
const locale = ref(qq.getSystemInfoSync().language || 'zh-Hans');
|
|
626
|
+
Object.defineProperty(appVm, '$locale', {
|
|
268
627
|
get() {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
});
|
|
275
|
-
const forComponents = mpInstance.selectAllComponents('.vue-ref-in-for');
|
|
276
|
-
forComponents.forEach(component => {
|
|
277
|
-
const ref = component.dataset.ref;
|
|
278
|
-
if (!$refs[ref]) {
|
|
279
|
-
$refs[ref] = [];
|
|
280
|
-
}
|
|
281
|
-
$refs[ref].push(component.$vm || component);
|
|
282
|
-
});
|
|
283
|
-
return $refs;
|
|
284
|
-
}
|
|
628
|
+
return locale.value;
|
|
629
|
+
},
|
|
630
|
+
set(v) {
|
|
631
|
+
locale.value = v;
|
|
632
|
+
},
|
|
285
633
|
});
|
|
286
|
-
}
|
|
287
|
-
function findVmByVueId(instance, vuePid) {
|
|
288
|
-
// TODO vue3 中 没有 $children
|
|
289
|
-
const $children = instance.$children;
|
|
290
|
-
// 优先查找直属(反向查找:https://github.com/dcloudio/uni-app/issues/1200)
|
|
291
|
-
for (let i = $children.length - 1; i >= 0; i--) {
|
|
292
|
-
const childVm = $children[i];
|
|
293
|
-
if (childVm.$scope._$vueId === vuePid) {
|
|
294
|
-
return childVm;
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
// 反向递归查找
|
|
298
|
-
let parentVm;
|
|
299
|
-
for (let i = $children.length - 1; i >= 0; i--) {
|
|
300
|
-
parentVm = findVmByVueId($children[i], vuePid);
|
|
301
|
-
if (parentVm) {
|
|
302
|
-
return parentVm;
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
634
|
}
|
|
306
635
|
|
|
307
636
|
const PROP_TYPES = [String, Number, Boolean, Object, Array, null];
|
|
@@ -324,7 +653,7 @@ function initDefaultProps(isBehavior = false) {
|
|
|
324
653
|
if (!isBehavior) {
|
|
325
654
|
properties.vueId = {
|
|
326
655
|
type: String,
|
|
327
|
-
value: ''
|
|
656
|
+
value: '',
|
|
328
657
|
};
|
|
329
658
|
// 小程序不能直接定义 $slots 的 props,所以通过 vueSlots 转换到 $slots
|
|
330
659
|
properties.vueSlots = {
|
|
@@ -336,9 +665,9 @@ function initDefaultProps(isBehavior = false) {
|
|
|
336
665
|
$slots[slotName] = true;
|
|
337
666
|
});
|
|
338
667
|
this.setData({
|
|
339
|
-
$slots
|
|
668
|
+
$slots,
|
|
340
669
|
});
|
|
341
|
-
}
|
|
670
|
+
},
|
|
342
671
|
};
|
|
343
672
|
}
|
|
344
673
|
return properties;
|
|
@@ -350,14 +679,14 @@ function createProperty(key, prop) {
|
|
|
350
679
|
function initProps(mpComponentOptions, rawProps, isBehavior = false) {
|
|
351
680
|
const properties = initDefaultProps(isBehavior);
|
|
352
681
|
if (isArray(rawProps)) {
|
|
353
|
-
rawProps.forEach(key => {
|
|
682
|
+
rawProps.forEach((key) => {
|
|
354
683
|
properties[key] = createProperty(key, {
|
|
355
|
-
type: null
|
|
684
|
+
type: null,
|
|
356
685
|
});
|
|
357
686
|
});
|
|
358
687
|
}
|
|
359
688
|
else if (isPlainObject(rawProps)) {
|
|
360
|
-
Object.keys(rawProps).forEach(key => {
|
|
689
|
+
Object.keys(rawProps).forEach((key) => {
|
|
361
690
|
const opts = rawProps[key];
|
|
362
691
|
if (isPlainObject(opts)) {
|
|
363
692
|
// title:{type:String,default:''}
|
|
@@ -369,14 +698,14 @@ function initProps(mpComponentOptions, rawProps, isBehavior = false) {
|
|
|
369
698
|
opts.type = parsePropType(key, type);
|
|
370
699
|
properties[key] = createProperty(key, {
|
|
371
700
|
type: PROP_TYPES.indexOf(type) !== -1 ? type : null,
|
|
372
|
-
value
|
|
701
|
+
value,
|
|
373
702
|
});
|
|
374
703
|
}
|
|
375
704
|
else {
|
|
376
705
|
// content:String
|
|
377
706
|
const type = parsePropType(key, opts);
|
|
378
707
|
properties[key] = createProperty(key, {
|
|
379
|
-
type: PROP_TYPES.indexOf(type) !== -1 ? type : null
|
|
708
|
+
type: PROP_TYPES.indexOf(type) !== -1 ? type : null,
|
|
380
709
|
});
|
|
381
710
|
}
|
|
382
711
|
});
|
|
@@ -388,8 +717,7 @@ function initData(vueOptions) {
|
|
|
388
717
|
let data = vueOptions.data || {};
|
|
389
718
|
if (typeof data === 'function') {
|
|
390
719
|
try {
|
|
391
|
-
const appConfig = getApp().$vm.$.appContext
|
|
392
|
-
.config;
|
|
720
|
+
const appConfig = getApp().$vm.$.appContext.config;
|
|
393
721
|
data = data.call(appConfig.globalProperties);
|
|
394
722
|
}
|
|
395
723
|
catch (e) {
|
|
@@ -420,7 +748,7 @@ function initBehaviors(vueOptions, initBehavior) {
|
|
|
420
748
|
}
|
|
421
749
|
const behaviors = [];
|
|
422
750
|
if (isArray(vueBehaviors)) {
|
|
423
|
-
vueBehaviors.forEach(behavior => {
|
|
751
|
+
vueBehaviors.forEach((behavior) => {
|
|
424
752
|
behaviors.push(behavior.replace('uni://', `${__PLATFORM_PREFIX__}://`));
|
|
425
753
|
if (behavior === 'uni://form-field') {
|
|
426
754
|
if (isArray(vueProps)) {
|
|
@@ -430,24 +758,24 @@ function initBehaviors(vueOptions, initBehavior) {
|
|
|
430
758
|
else {
|
|
431
759
|
vueProps.name = {
|
|
432
760
|
type: String,
|
|
433
|
-
default: ''
|
|
761
|
+
default: '',
|
|
434
762
|
};
|
|
435
763
|
vueProps.value = {
|
|
436
764
|
type: [String, Number, Boolean, Array, Object, Date],
|
|
437
|
-
default: ''
|
|
765
|
+
default: '',
|
|
438
766
|
};
|
|
439
767
|
}
|
|
440
768
|
}
|
|
441
769
|
});
|
|
442
770
|
}
|
|
443
|
-
if (
|
|
771
|
+
if (vueExtends && vueExtends.props) {
|
|
444
772
|
const behavior = {};
|
|
445
773
|
initProps(behavior, vueExtends.props, true);
|
|
446
774
|
behaviors.push(initBehavior(behavior));
|
|
447
775
|
}
|
|
448
776
|
if (isArray(vueMixins)) {
|
|
449
|
-
vueMixins.forEach(vueMixin => {
|
|
450
|
-
if (
|
|
777
|
+
vueMixins.forEach((vueMixin) => {
|
|
778
|
+
if (vueMixin.props) {
|
|
451
779
|
const behavior = {};
|
|
452
780
|
initProps(behavior, vueMixin.props, true);
|
|
453
781
|
behaviors.push(initBehavior(behavior));
|
|
@@ -461,21 +789,9 @@ function applyOptions(componentOptions, vueOptions, initBehavior) {
|
|
|
461
789
|
componentOptions.behaviors = initBehaviors(vueOptions, initBehavior);
|
|
462
790
|
}
|
|
463
791
|
|
|
464
|
-
function getValue(obj, path) {
|
|
465
|
-
const parts = path.split('.');
|
|
466
|
-
let key = parts[0];
|
|
467
|
-
if (key.indexOf('__$n') === 0) {
|
|
468
|
-
//number index
|
|
469
|
-
key = parseInt(key.replace('__$n', ''));
|
|
470
|
-
}
|
|
471
|
-
if (parts.length === 1) {
|
|
472
|
-
return obj[key];
|
|
473
|
-
}
|
|
474
|
-
return getValue(obj[key], parts.slice(1).join('.'));
|
|
475
|
-
}
|
|
476
792
|
function getExtraValue(instance, dataPathsArray) {
|
|
477
793
|
let context = instance;
|
|
478
|
-
dataPathsArray.forEach(dataPathArray => {
|
|
794
|
+
dataPathsArray.forEach((dataPathArray) => {
|
|
479
795
|
const dataPath = dataPathArray[0];
|
|
480
796
|
const value = dataPathArray[2];
|
|
481
797
|
if (dataPath || typeof value !== 'undefined') {
|
|
@@ -494,7 +810,7 @@ function getExtraValue(instance, dataPathsArray) {
|
|
|
494
810
|
vFor = dataPath.substr(3);
|
|
495
811
|
}
|
|
496
812
|
else {
|
|
497
|
-
vFor =
|
|
813
|
+
vFor = getTarget(context, dataPath);
|
|
498
814
|
}
|
|
499
815
|
}
|
|
500
816
|
if (Number.isInteger(vFor)) {
|
|
@@ -505,13 +821,13 @@ function getExtraValue(instance, dataPathsArray) {
|
|
|
505
821
|
}
|
|
506
822
|
else {
|
|
507
823
|
if (isArray(vFor)) {
|
|
508
|
-
context = vFor.find(vForItem => {
|
|
509
|
-
return
|
|
824
|
+
context = vFor.find((vForItem) => {
|
|
825
|
+
return getTarget(vForItem, propPath) === value;
|
|
510
826
|
});
|
|
511
827
|
}
|
|
512
828
|
else if (isPlainObject(vFor)) {
|
|
513
|
-
context = Object.keys(vFor).find(vForKey => {
|
|
514
|
-
return
|
|
829
|
+
context = Object.keys(vFor).find((vForKey) => {
|
|
830
|
+
return getTarget(vFor[vForKey], propPath) === value;
|
|
515
831
|
});
|
|
516
832
|
}
|
|
517
833
|
else {
|
|
@@ -519,7 +835,7 @@ function getExtraValue(instance, dataPathsArray) {
|
|
|
519
835
|
}
|
|
520
836
|
}
|
|
521
837
|
if (valuePath) {
|
|
522
|
-
context =
|
|
838
|
+
context = getTarget(context, valuePath);
|
|
523
839
|
}
|
|
524
840
|
}
|
|
525
841
|
});
|
|
@@ -560,10 +876,10 @@ function processEventExtra(instance, extra, event) {
|
|
|
560
876
|
}
|
|
561
877
|
else if (dataPath.indexOf('$event.') === 0) {
|
|
562
878
|
// $event.target.value
|
|
563
|
-
extraObj['$' + index] =
|
|
879
|
+
extraObj['$' + index] = getTarget(event, dataPath.replace('$event.', ''));
|
|
564
880
|
}
|
|
565
881
|
else {
|
|
566
|
-
extraObj['$' + index] =
|
|
882
|
+
extraObj['$' + index] = getTarget(instance, dataPath);
|
|
567
883
|
}
|
|
568
884
|
}
|
|
569
885
|
}
|
|
@@ -600,7 +916,7 @@ function processEventArgs(instance, event, args = [], extra = [], isCustom, meth
|
|
|
600
916
|
}
|
|
601
917
|
const extraObj = processEventExtra(instance, extra, event);
|
|
602
918
|
const ret = [];
|
|
603
|
-
args.forEach(arg => {
|
|
919
|
+
args.forEach((arg) => {
|
|
604
920
|
if (arg === '$event') {
|
|
605
921
|
if (methodName === '__set_model' && !isCustom) {
|
|
606
922
|
// input v-model value
|
|
@@ -642,7 +958,7 @@ function wrapper(event) {
|
|
|
642
958
|
event.detail.markerId = event.markerId;
|
|
643
959
|
}
|
|
644
960
|
if (isPlainObject(event.detail)) {
|
|
645
|
-
event.target =
|
|
961
|
+
event.target = extend({}, event.target, event.detail);
|
|
646
962
|
}
|
|
647
963
|
return event;
|
|
648
964
|
}
|
|
@@ -700,7 +1016,14 @@ function handleEvent(event) {
|
|
|
700
1016
|
}
|
|
701
1017
|
handler.once = true;
|
|
702
1018
|
}
|
|
703
|
-
|
|
1019
|
+
let params = processEventArgs(this.$vm, event, eventArray[1], eventArray[2], isCustom, methodName);
|
|
1020
|
+
params = Array.isArray(params) ? params : [];
|
|
1021
|
+
// 参数尾部增加原始事件对象用于复杂表达式内获取额外数据
|
|
1022
|
+
if (/=\s*\S+\.eventParams\s*\|\|\s*\S+\[['"]event-params['"]\]/.test(handler.toString())) {
|
|
1023
|
+
// eslint-disable-next-line no-sparse-arrays
|
|
1024
|
+
params = params.concat([, , , , , , , , , , event]);
|
|
1025
|
+
}
|
|
1026
|
+
ret.push(handler.apply(handlerCtx, params));
|
|
704
1027
|
}
|
|
705
1028
|
});
|
|
706
1029
|
}
|
|
@@ -712,11 +1035,11 @@ function handleEvent(event) {
|
|
|
712
1035
|
}
|
|
713
1036
|
}
|
|
714
1037
|
|
|
715
|
-
function parseComponent(vueOptions, { parse, mocks, isPage, initRelation, handleLink, initLifetimes }) {
|
|
1038
|
+
function parseComponent(vueOptions, { parse, mocks, isPage, initRelation, handleLink, initLifetimes, }) {
|
|
716
1039
|
vueOptions = vueOptions.default || vueOptions;
|
|
717
1040
|
const options = {
|
|
718
1041
|
multipleSlots: true,
|
|
719
|
-
addGlobalClass: true
|
|
1042
|
+
addGlobalClass: true,
|
|
720
1043
|
};
|
|
721
1044
|
if (vueOptions.options) {
|
|
722
1045
|
extend(options, vueOptions.options);
|
|
@@ -733,12 +1056,12 @@ function parseComponent(vueOptions, { parse, mocks, isPage, initRelation, handle
|
|
|
733
1056
|
},
|
|
734
1057
|
resize(size) {
|
|
735
1058
|
this.$vm && this.$vm.$callHook('onPageResize', size);
|
|
736
|
-
}
|
|
1059
|
+
},
|
|
737
1060
|
},
|
|
738
1061
|
methods: {
|
|
739
1062
|
__l: handleLink,
|
|
740
|
-
__e: handleEvent
|
|
741
|
-
}
|
|
1063
|
+
__e: handleEvent,
|
|
1064
|
+
},
|
|
742
1065
|
};
|
|
743
1066
|
if (__VUE_OPTIONS_API__) {
|
|
744
1067
|
applyOptions(mpComponentOptions, vueOptions, initBehavior);
|
|
@@ -778,15 +1101,15 @@ function parsePage(vueOptions, parseOptions) {
|
|
|
778
1101
|
isPage,
|
|
779
1102
|
initRelation,
|
|
780
1103
|
handleLink,
|
|
781
|
-
initLifetimes
|
|
1104
|
+
initLifetimes,
|
|
782
1105
|
});
|
|
783
1106
|
const methods = miniProgramPageOptions.methods;
|
|
784
1107
|
methods.onLoad = function (query) {
|
|
785
1108
|
this.options = query;
|
|
786
1109
|
this.$page = {
|
|
787
|
-
fullPath: '/' + this.route + stringifyQuery(query)
|
|
1110
|
+
fullPath: '/' + this.route + stringifyQuery(query),
|
|
788
1111
|
};
|
|
789
|
-
return this.$vm && this.$vm.$callHook(
|
|
1112
|
+
return this.$vm && this.$vm.$callHook(ON_LOAD, query);
|
|
790
1113
|
};
|
|
791
1114
|
initHooks(methods, PAGE_HOOKS);
|
|
792
1115
|
initUnknownHooks(methods, vueOptions);
|
|
@@ -811,7 +1134,7 @@ function initTriggerEvent(mpInstance) {
|
|
|
811
1134
|
return oldTriggerEvent.apply(mpInstance, [customize(event), ...args]);
|
|
812
1135
|
};
|
|
813
1136
|
}
|
|
814
|
-
function initHook
|
|
1137
|
+
function initHook(name, options) {
|
|
815
1138
|
const oldHook = options[name];
|
|
816
1139
|
if (!oldHook) {
|
|
817
1140
|
options[name] = function () {
|
|
@@ -826,21 +1149,21 @@ function initHook$1(name, options) {
|
|
|
826
1149
|
}
|
|
827
1150
|
}
|
|
828
1151
|
Page = function (options) {
|
|
829
|
-
initHook
|
|
1152
|
+
initHook(ON_LOAD, options);
|
|
830
1153
|
return MPPage(options);
|
|
831
1154
|
};
|
|
832
1155
|
Component = function (options) {
|
|
833
|
-
initHook
|
|
1156
|
+
initHook('created', options);
|
|
834
1157
|
return MPComponent(options);
|
|
835
1158
|
};
|
|
836
1159
|
|
|
837
|
-
function initLifetimes({ mocks, isPage, initRelation, vueOptions }) {
|
|
1160
|
+
function initLifetimes({ mocks, isPage, initRelation, vueOptions, }) {
|
|
838
1161
|
return {
|
|
839
1162
|
attached() {
|
|
840
1163
|
const properties = this.properties;
|
|
841
1164
|
initVueIds(properties.vueId, this);
|
|
842
1165
|
const relationOptions = {
|
|
843
|
-
vuePid: this._$vuePid
|
|
1166
|
+
vuePid: this._$vuePid,
|
|
844
1167
|
};
|
|
845
1168
|
// 处理父子关系
|
|
846
1169
|
initRelation(this, relationOptions);
|
|
@@ -848,7 +1171,7 @@ function initLifetimes({ mocks, isPage, initRelation, vueOptions }) {
|
|
|
848
1171
|
const mpInstance = this;
|
|
849
1172
|
this.$vm = $createComponent({
|
|
850
1173
|
type: vueOptions,
|
|
851
|
-
props: properties
|
|
1174
|
+
props: properties,
|
|
852
1175
|
}, {
|
|
853
1176
|
mpType: isPage(mpInstance) ? 'page' : 'component',
|
|
854
1177
|
mpInstance,
|
|
@@ -858,7 +1181,7 @@ function initLifetimes({ mocks, isPage, initRelation, vueOptions }) {
|
|
|
858
1181
|
initRefs(instance, mpInstance);
|
|
859
1182
|
initMocks(instance, mpInstance, mocks);
|
|
860
1183
|
initComponentInstance(instance, options);
|
|
861
|
-
}
|
|
1184
|
+
},
|
|
862
1185
|
});
|
|
863
1186
|
},
|
|
864
1187
|
ready() {
|
|
@@ -866,12 +1189,12 @@ function initLifetimes({ mocks, isPage, initRelation, vueOptions }) {
|
|
|
866
1189
|
// https://developers.weixin.qq.com/community/develop/doc/00066ae2844cc0f8eb883e2a557800
|
|
867
1190
|
if (this.$vm) {
|
|
868
1191
|
this.$vm.$callHook('mounted');
|
|
869
|
-
this.$vm.$callHook(
|
|
1192
|
+
this.$vm.$callHook(ON_READY);
|
|
870
1193
|
}
|
|
871
1194
|
},
|
|
872
1195
|
detached() {
|
|
873
1196
|
this.$vm && $destroyComponent(this.$vm);
|
|
874
|
-
}
|
|
1197
|
+
},
|
|
875
1198
|
};
|
|
876
1199
|
}
|
|
877
1200
|
|
|
@@ -898,16 +1221,24 @@ function handleLink(event) {
|
|
|
898
1221
|
}
|
|
899
1222
|
|
|
900
1223
|
var parseOptions = /*#__PURE__*/Object.freeze({
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
1224
|
+
__proto__: null,
|
|
1225
|
+
mocks: mocks,
|
|
1226
|
+
isPage: isPage,
|
|
1227
|
+
initRelation: initRelation,
|
|
1228
|
+
handleLink: handleLink,
|
|
1229
|
+
initLifetimes: initLifetimes
|
|
907
1230
|
});
|
|
908
1231
|
|
|
909
1232
|
const createApp = initCreateApp();
|
|
910
1233
|
const createPage = initCreatePage(parseOptions);
|
|
911
|
-
const createComponent = initCreateComponent(parseOptions);
|
|
1234
|
+
const createComponent = initCreateComponent(parseOptions);
|
|
1235
|
+
wx.createApp = createApp;
|
|
1236
|
+
wx.createPage = createPage;
|
|
1237
|
+
wx.createComponent = createComponent;
|
|
1238
|
+
|
|
1239
|
+
qq.EventChannel = EventChannel;
|
|
1240
|
+
qq.createApp = createApp;
|
|
1241
|
+
qq.createPage = createPage;
|
|
1242
|
+
qq.createComponent = createComponent;
|
|
912
1243
|
|
|
913
1244
|
export { createApp, createComponent, createPage };
|