@dolphinweex/weex-harmony 0.1.88 → 0.1.89
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/package.json
CHANGED
|
@@ -77,11 +77,11 @@ export default {
|
|
|
77
77
|
}
|
|
78
78
|
},
|
|
79
79
|
created() {
|
|
80
|
-
|
|
81
|
-
this.embedId = `embedId_${this._uid}_${this.generateNaiveId()}_${componentType}`
|
|
80
|
+
this.embedId = `embedId_${this._uid}_${this.generateNaiveId()}`
|
|
82
81
|
console.log("[sameLayerRendering] web component created.");
|
|
83
82
|
weexModule.callNative("transferSameLayerArgs", {
|
|
84
83
|
componentId: this.embedId,
|
|
84
|
+
embedType: this.embedType,
|
|
85
85
|
...this.hosSameLayerArgs,
|
|
86
86
|
});
|
|
87
87
|
},
|
|
@@ -157,6 +157,7 @@ export default {
|
|
|
157
157
|
this.$nextTick(() => {
|
|
158
158
|
weexModule.callNative("transferSameLayerArgs", {
|
|
159
159
|
componentId: this.embedId,
|
|
160
|
+
embedType: this.embedType,
|
|
160
161
|
...newVal,
|
|
161
162
|
});
|
|
162
163
|
});
|
|
@@ -151,8 +151,16 @@ export default {
|
|
|
151
151
|
const hmComponentIndex = parentEl.getAttribute('hmcomponentindex');
|
|
152
152
|
if (hmComponentIndex === 'midea-common-weex-view') {
|
|
153
153
|
this._parentElement = parentEl;
|
|
154
|
+
} else {
|
|
155
|
+
// 兜底:多数场景 this.$el 就是可控容器,避免因属性缺失导致无法同步高度
|
|
156
|
+
this._parentElement = parentEl;
|
|
154
157
|
}
|
|
155
158
|
}
|
|
159
|
+
// 包装器找不到时兜底到当前组件根节点
|
|
160
|
+
if (!this._wrapperEl && this.$el) {
|
|
161
|
+
this._wrapperEl = this.$el;
|
|
162
|
+
this.debugLog(`包装器兜底为当前组件根节点`);
|
|
163
|
+
}
|
|
156
164
|
|
|
157
165
|
// 优化手势处理性能
|
|
158
166
|
this._rafId = null;
|
|
@@ -246,6 +254,13 @@ export default {
|
|
|
246
254
|
if (height <= 0) {
|
|
247
255
|
height = totalOffsetHeight;
|
|
248
256
|
}
|
|
257
|
+
|
|
258
|
+
// 结合元素本身尺寸指标,减少某些内核下 getBoundingClientRect 低估问题
|
|
259
|
+
const selfRect = parentRect.height || 0;
|
|
260
|
+
const selfScroll = el.scrollHeight || 0;
|
|
261
|
+
const selfOffset = el.offsetHeight || 0;
|
|
262
|
+
const selfClient = el.clientHeight || 0;
|
|
263
|
+
height = Math.max(height, selfRect, selfScroll, selfOffset, selfClient);
|
|
249
264
|
|
|
250
265
|
return height;
|
|
251
266
|
},
|
|
@@ -355,55 +370,56 @@ export default {
|
|
|
355
370
|
this.debugLog(`计算得到elementHeight=${elementHeight}px`);
|
|
356
371
|
|
|
357
372
|
if (elementHeight > 0) {
|
|
358
|
-
//
|
|
359
|
-
//
|
|
360
|
-
let maxHeight =
|
|
361
|
-
this.debugLog(`初始maxHeight
|
|
373
|
+
// 默认不按当前视口剩余高度裁剪,避免可滚动页面中 iframe 被错误截断。
|
|
374
|
+
// plugin-menu 页面保持原有“限制在可视区”策略。
|
|
375
|
+
let maxHeight = Number.POSITIVE_INFINITY;
|
|
376
|
+
this.debugLog(`初始maxHeight=${maxHeight}px (isPluginMenu=${this.isPluginMenu})`);
|
|
362
377
|
|
|
363
|
-
if (this
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
378
|
+
if (this.isPluginMenu) {
|
|
379
|
+
maxHeight = window.innerHeight;
|
|
380
|
+
if (this.$refs.iframe) {
|
|
381
|
+
try {
|
|
382
|
+
const rect = this.$refs.iframe.getBoundingClientRect();
|
|
383
|
+
this.debugLog(`iframe位置: top=${rect.top}, left=${rect.left}, width=${rect.width}, height=${rect.height}`);
|
|
384
|
+
if (rect.top > 0) {
|
|
385
|
+
maxHeight = window.innerHeight - rect.top;
|
|
386
|
+
this.debugLog(`plugin-menu 调整后maxHeight=${maxHeight}px (top=${rect.top})`);
|
|
387
|
+
}
|
|
388
|
+
} catch (e) {
|
|
389
|
+
this.debugWarn('获取 iframe 位置失败:', e);
|
|
372
390
|
}
|
|
373
|
-
}
|
|
374
|
-
this.debugWarn(
|
|
391
|
+
} else {
|
|
392
|
+
this.debugWarn(`this.$refs.iframe 不存在`);
|
|
375
393
|
}
|
|
376
|
-
|
|
377
|
-
this.debugWarn(`this.$refs.iframe 不存在`);
|
|
394
|
+
maxHeight = Math.max(maxHeight, 0);
|
|
378
395
|
}
|
|
379
396
|
|
|
380
|
-
// 确保 maxHeight 不为负数
|
|
381
|
-
maxHeight = Math.max(maxHeight, 0);
|
|
382
397
|
this.debugLog(`最终maxHeight=${maxHeight}px`);
|
|
383
398
|
|
|
384
|
-
//
|
|
385
|
-
const finalHeight =
|
|
399
|
+
// 非 plugin-menu 不裁剪;plugin-menu 才按 maxHeight 限制
|
|
400
|
+
const finalHeight = elementHeight > maxHeight ? maxHeight : elementHeight;
|
|
386
401
|
this.debugLog(`finalHeight=${finalHeight}px (isPluginMenu=${this.isPluginMenu}, elementHeight=${elementHeight}, maxHeight=${maxHeight})`);
|
|
387
402
|
|
|
388
|
-
//
|
|
403
|
+
// 更新 iframe 高度(考虑 weex scale)
|
|
404
|
+
const scale = weex.config.env.scale || 1;
|
|
405
|
+
const newHeight = `${finalHeight / scale}px`;
|
|
406
|
+
|
|
407
|
+
// 更新包装器高度(与 iframe 显示高度保持一致,避免父容器裁剪)
|
|
389
408
|
if (this._wrapperEl) {
|
|
390
|
-
this._wrapperEl.style.height =
|
|
391
|
-
this.debugLog(`更新包装器高度: ${
|
|
409
|
+
this._wrapperEl.style.height = newHeight;
|
|
410
|
+
this.debugLog(`更新包装器高度: ${newHeight}`);
|
|
392
411
|
} else {
|
|
393
412
|
this.debugLog(`包装器元素不存在`);
|
|
394
413
|
}
|
|
395
|
-
|
|
396
|
-
// 更新 iframe 高度(考虑 weex scale)
|
|
397
|
-
const scale = weex.config.env.scale || 1;
|
|
398
|
-
const newHeight = `${finalHeight / scale}px`;
|
|
414
|
+
|
|
399
415
|
this.debugLog(`计算newHeight=${newHeight} (finalHeight=${finalHeight}, scale=${scale}), 当前height=${this.height}`);
|
|
400
416
|
if (this.height !== newHeight) {
|
|
401
417
|
this.height = newHeight;
|
|
402
418
|
this.debugLog(`✅ iframe 高度已更新: ${finalHeight}px -> ${newHeight} (embedId: ${this.embedId}, max: ${maxHeight}px)`);
|
|
403
|
-
//
|
|
419
|
+
// 如果父级元素存在且符合条件,也给父级元素设置同样显示高度,防止内容被截断
|
|
404
420
|
if (this._parentElement) {
|
|
405
|
-
this._parentElement.style.height =
|
|
406
|
-
this.debugLog(`更新父级元素高度: ${
|
|
421
|
+
this._parentElement.style.height = newHeight;
|
|
422
|
+
this.debugLog(`更新父级元素高度: ${newHeight}`);
|
|
407
423
|
}
|
|
408
424
|
} else {
|
|
409
425
|
this.debugLog(`⚠️ 高度未变化,不更新 (当前=${this.height}, 新值=${newHeight})`);
|