@dolphinweex/weex-harmony 0.1.87 → 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dolphinweex/weex-harmony",
3
- "version": "0.1.87",
3
+ "version": "0.1.89",
4
4
  "description": "weex harmony adapter",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -81,6 +81,7 @@ export default {
81
81
  console.log("[sameLayerRendering] web component created.");
82
82
  weexModule.callNative("transferSameLayerArgs", {
83
83
  componentId: this.embedId,
84
+ embedType: this.embedType,
84
85
  ...this.hosSameLayerArgs,
85
86
  });
86
87
  },
@@ -156,6 +157,7 @@ export default {
156
157
  this.$nextTick(() => {
157
158
  weexModule.callNative("transferSameLayerArgs", {
158
159
  componentId: this.embedId,
160
+ embedType: this.embedType,
159
161
  ...newVal,
160
162
  });
161
163
  });
@@ -7,7 +7,6 @@
7
7
  :defaultHeight="300"
8
8
  v-on="$listeners"
9
9
  :listenEvents="['click']"
10
- :key="dataVersion"
11
10
  ></BaseSameLayer>
12
11
  </template>
13
12
 
@@ -19,8 +18,7 @@ export default {
19
18
  data() {
20
19
  return {
21
20
  width: 0,
22
- height: 0,
23
- dataVersion: 1,
21
+ height: 0
24
22
  }
25
23
  },
26
24
  name: "MideaApngView",
@@ -49,21 +47,6 @@ export default {
49
47
  default: true,
50
48
  },
51
49
  },
52
- watch:{
53
- src: {
54
- handler(newVal, oldVal) {
55
- try{
56
- if (newVal !== oldVal) {
57
- this.dataVersion++;
58
- }
59
- }catch(e){
60
-
61
- }
62
- },
63
- deep: true,
64
- immediate: false
65
- },
66
- },
67
50
  computed: {
68
51
  hosSameLayerArgs() {
69
52
  return {
@@ -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
- // 策略:使用 window.innerHeight 减去 iframe 距离视口顶部的距离
360
- let maxHeight = window.innerHeight;
361
- this.debugLog(`初始maxHeight(window.innerHeight)=${maxHeight}px`);
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.$refs.iframe) {
364
- try {
365
- const rect = this.$refs.iframe.getBoundingClientRect();
366
- this.debugLog(`iframe位置: top=${rect.top}, left=${rect.left}, width=${rect.width}, height=${rect.height}`);
367
- // 如果 top > 0,说明 iframe 顶部在视口下方或视口内,减去 top 得到剩余可用高度
368
- // 如果 top <= 0,说明 iframe 顶部已滚出视口上方,此时最大高度限制为 window.innerHeight (防止无限增高)
369
- if (rect.top > 0) {
370
- maxHeight = window.innerHeight - rect.top;
371
- this.debugLog(`调整后maxHeight=${maxHeight}px (top=${rect.top})`);
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
- } catch (e) {
374
- this.debugWarn('获取 iframe 位置失败:', e);
391
+ } else {
392
+ this.debugWarn(`this.$refs.iframe 不存在`);
375
393
  }
376
- } else {
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 = !this.isPluginMenu ? elementHeight > maxHeight ? maxHeight : elementHeight : elementHeight
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 = `${finalHeight}px`;
391
- this.debugLog(`更新包装器高度: ${finalHeight}px`);
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 = `${finalHeight}px`;
406
- this.debugLog(`更新父级元素高度: ${finalHeight}px`);
421
+ this._parentElement.style.height = newHeight;
422
+ this.debugLog(`更新父级元素高度: ${newHeight}`);
407
423
  }
408
424
  } else {
409
425
  this.debugLog(`⚠️ 高度未变化,不更新 (当前=${this.height}, 新值=${newHeight})`);
@@ -257,7 +257,7 @@ export default {
257
257
  onPreviewImageClick(res) {
258
258
  this.$emit('onPreviewImageClick', res);
259
259
  },
260
- onCaptureCompletion(){
260
+ onCaptureCompletion(res){
261
261
  this.$emit('onCaptureCompletion', res);
262
262
  }
263
263
  },