@dcloudio/uni-quickapp-webview 2.0.1-alpha-36320220919002 → 2.0.1-alpha-36720221017001
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 +38 -19
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1382,7 +1382,7 @@ function hasHook (hook, vueOptions) {
|
|
|
1382
1382
|
return false
|
|
1383
1383
|
}
|
|
1384
1384
|
|
|
1385
|
-
if (isFn(vueOptions[hook])) {
|
|
1385
|
+
if (isFn(vueOptions[hook]) || Array.isArray(vueOptions[hook])) {
|
|
1386
1386
|
return true
|
|
1387
1387
|
}
|
|
1388
1388
|
const mixins = vueOptions.mixins;
|
|
@@ -2046,21 +2046,40 @@ function initBehavior (options) {
|
|
|
2046
2046
|
}
|
|
2047
2047
|
|
|
2048
2048
|
function selectAllComponents (mpInstance, selector, $refs) {
|
|
2049
|
-
const components = mpInstance.selectAllComponents(selector);
|
|
2049
|
+
const components = mpInstance.selectAllComponents(selector) || [];
|
|
2050
2050
|
components.forEach(component => {
|
|
2051
2051
|
const ref = component.dataset.ref;
|
|
2052
2052
|
$refs[ref] = component.$vm || component;
|
|
2053
2053
|
});
|
|
2054
2054
|
}
|
|
2055
2055
|
|
|
2056
|
+
function syncRefs (refs, newRefs) {
|
|
2057
|
+
const oldKeys = new Set(...Object.keys(refs));
|
|
2058
|
+
const newKeys = Object.keys(newRefs);
|
|
2059
|
+
newKeys.forEach(key => {
|
|
2060
|
+
const oldValue = refs[key];
|
|
2061
|
+
const newValue = newRefs[key];
|
|
2062
|
+
if (Array.isArray(oldValue) && Array.isArray(newValue) && oldValue.length === newValue.length && newValue.every(value => oldValue.includes(value))) {
|
|
2063
|
+
return
|
|
2064
|
+
}
|
|
2065
|
+
refs[key] = newValue;
|
|
2066
|
+
oldKeys.delete(key);
|
|
2067
|
+
});
|
|
2068
|
+
oldKeys.forEach(key => {
|
|
2069
|
+
delete refs[key];
|
|
2070
|
+
});
|
|
2071
|
+
return refs
|
|
2072
|
+
}
|
|
2073
|
+
|
|
2056
2074
|
function initRefs (vm) {
|
|
2057
2075
|
const mpInstance = vm.$scope;
|
|
2076
|
+
const refs = {};
|
|
2058
2077
|
Object.defineProperty(vm, '$refs', {
|
|
2059
2078
|
get () {
|
|
2060
2079
|
const $refs = {};
|
|
2061
2080
|
selectAllComponents(mpInstance, '.vue-ref', $refs);
|
|
2062
2081
|
// TODO 暂不考虑 for 中的 scoped
|
|
2063
|
-
const forComponents = mpInstance.selectAllComponents('.vue-ref-in-for');
|
|
2082
|
+
const forComponents = mpInstance.selectAllComponents('.vue-ref-in-for') || [];
|
|
2064
2083
|
forComponents.forEach(component => {
|
|
2065
2084
|
const ref = component.dataset.ref;
|
|
2066
2085
|
if (!$refs[ref]) {
|
|
@@ -2068,7 +2087,7 @@ function initRefs (vm) {
|
|
|
2068
2087
|
}
|
|
2069
2088
|
$refs[ref].push(component.$vm || component);
|
|
2070
2089
|
});
|
|
2071
|
-
return $refs
|
|
2090
|
+
return syncRefs(refs, $refs)
|
|
2072
2091
|
}
|
|
2073
2092
|
});
|
|
2074
2093
|
}
|
|
@@ -2224,7 +2243,7 @@ function stringifyQuery (obj, encodeStr = encode) {
|
|
|
2224
2243
|
function parseBaseComponent (vueComponentOptions, {
|
|
2225
2244
|
isPage,
|
|
2226
2245
|
initRelation
|
|
2227
|
-
} = {}) {
|
|
2246
|
+
} = {}, needVueOptions) {
|
|
2228
2247
|
const [VueComponent, vueOptions] = initVueComponent(Vue, vueComponentOptions);
|
|
2229
2248
|
|
|
2230
2249
|
const options = {
|
|
@@ -2307,14 +2326,20 @@ function parseBaseComponent (vueComponentOptions, {
|
|
|
2307
2326
|
});
|
|
2308
2327
|
}
|
|
2309
2328
|
|
|
2329
|
+
if (needVueOptions) {
|
|
2330
|
+
return [componentOptions, vueOptions, VueComponent]
|
|
2331
|
+
}
|
|
2310
2332
|
if (isPage) {
|
|
2311
2333
|
return componentOptions
|
|
2312
2334
|
}
|
|
2313
2335
|
return [componentOptions, VueComponent]
|
|
2314
2336
|
}
|
|
2315
2337
|
|
|
2316
|
-
function parseComponent (
|
|
2317
|
-
const [componentOptions, VueComponent] = parseBaseComponent(
|
|
2338
|
+
function parseComponent (vueComponentOptions, needVueOptions) {
|
|
2339
|
+
const [componentOptions, vueOptions, VueComponent] = parseBaseComponent(vueComponentOptions, {
|
|
2340
|
+
isPage,
|
|
2341
|
+
initRelation
|
|
2342
|
+
}, true);
|
|
2318
2343
|
|
|
2319
2344
|
componentOptions.lifetimes.attached = function attached () {
|
|
2320
2345
|
const properties = this.properties;
|
|
@@ -2348,7 +2373,7 @@ function parseComponent (vueOptions) {
|
|
|
2348
2373
|
|
|
2349
2374
|
componentOptions.methods.__l = handleLink$1;
|
|
2350
2375
|
|
|
2351
|
-
return componentOptions
|
|
2376
|
+
return needVueOptions ? [componentOptions, vueOptions] : componentOptions
|
|
2352
2377
|
}
|
|
2353
2378
|
|
|
2354
2379
|
const hooks$1 = [
|
|
@@ -2359,13 +2384,10 @@ const hooks$1 = [
|
|
|
2359
2384
|
|
|
2360
2385
|
hooks$1.push(...PAGE_EVENT_HOOKS);
|
|
2361
2386
|
|
|
2362
|
-
function parseBasePage (vuePageOptions
|
|
2363
|
-
|
|
2364
|
-
initRelation
|
|
2365
|
-
}) {
|
|
2366
|
-
const pageOptions = parseComponent(vuePageOptions);
|
|
2387
|
+
function parseBasePage (vuePageOptions) {
|
|
2388
|
+
const [pageOptions, vueOptions] = parseComponent(vuePageOptions, true);
|
|
2367
2389
|
|
|
2368
|
-
initHooks(pageOptions.methods, hooks$1,
|
|
2390
|
+
initHooks(pageOptions.methods, hooks$1, vueOptions);
|
|
2369
2391
|
|
|
2370
2392
|
pageOptions.methods.onLoad = function (query) {
|
|
2371
2393
|
this.options = query;
|
|
@@ -2385,10 +2407,7 @@ function parseBasePage (vuePageOptions, {
|
|
|
2385
2407
|
}
|
|
2386
2408
|
|
|
2387
2409
|
function parsePage (vuePageOptions) {
|
|
2388
|
-
const pageOptions = parseBasePage(vuePageOptions
|
|
2389
|
-
isPage,
|
|
2390
|
-
initRelation
|
|
2391
|
-
});
|
|
2410
|
+
const pageOptions = parseBasePage(vuePageOptions);
|
|
2392
2411
|
// 页面需要在 ready 中触发,其他组件是在 handleLink 中触发
|
|
2393
2412
|
pageOptions.lifetimes.ready = function ready () {
|
|
2394
2413
|
if (this.$vm && this.$vm.mpType === 'page') {
|
|
@@ -2520,7 +2539,7 @@ if (typeof Proxy !== 'undefined' && "quickapp-webview" !== 'app-plus') {
|
|
|
2520
2539
|
if (eventApi[name]) {
|
|
2521
2540
|
return eventApi[name]
|
|
2522
2541
|
}
|
|
2523
|
-
if (
|
|
2542
|
+
if (typeof qa[name] !== 'function' && !hasOwn(protocols, name)) {
|
|
2524
2543
|
return
|
|
2525
2544
|
}
|
|
2526
2545
|
return promisify(name, wrapper(name, qa[name]))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dcloudio/uni-quickapp-webview",
|
|
3
|
-
"version": "2.0.1-alpha-
|
|
3
|
+
"version": "2.0.1-alpha-36720221017001",
|
|
4
4
|
"description": "uni-app quickapp-webview",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -17,5 +17,5 @@
|
|
|
17
17
|
"name": "quickapp-webview",
|
|
18
18
|
"title": "快应用(Webview)版"
|
|
19
19
|
},
|
|
20
|
-
"gitHead": "
|
|
20
|
+
"gitHead": "7d7030aaaffab530253dc4cf02f87a13023c0d1f"
|
|
21
21
|
}
|