@dolphinweex/weex-harmony 0.1.83 → 0.1.84

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.83",
3
+ "version": "0.1.84",
4
4
  "description": "weex harmony adapter",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -178,9 +178,9 @@ export default {
178
178
  JSON.stringify(window.$midea_harmony_native),
179
179
  "*"
180
180
  );
181
-
182
- // 启动 weex-root 第一个子元素的高度监听
183
- this.startWeexRootHeightMonitoring();
181
+ setTimeout(()=>{
182
+ this.startWeexRootHeightMonitoring();
183
+ })
184
184
  }
185
185
  },
186
186
 
@@ -210,7 +210,7 @@ export default {
210
210
  // 如果方法1计算出的高度为0或太小,则累加所有子元素的高度
211
211
  if (totalHeight <= 0) {
212
212
  children.forEach((child) => {
213
- const childHeight = child.offsetHeight || child.clientHeight || child.scrollHeight || 0;
213
+ const childHeight = child.offsetHeight || child.clientHeight || 0;
214
214
  totalHeight += childHeight;
215
215
  });
216
216
  }
@@ -222,7 +222,7 @@ export default {
222
222
  startWeexRootHeightMonitoring() {
223
223
  // 尝试多次查找元素(因为 iframe 内容可能还在加载)
224
224
  let attempts = 0;
225
- const maxAttempts = 20; // 最多尝试 20 次
225
+ const maxAttempts = 10; // 最多尝试 20 次
226
226
 
227
227
  this._heightCheckTimer = setInterval(() => {
228
228
  attempts++;
@@ -241,7 +241,6 @@ export default {
241
241
  let targetElement = null;
242
242
  let elementDesc = '';
243
243
  let useChildrenTotalHeight = false; // 标记是否使用子元素总高度
244
-
245
244
  // 查找 .weex-root
246
245
  const weexRoot = iframeDocument.querySelector('.weex-root');
247
246
  const weexRootFirstChild = (weexRoot && weexRoot.children.length > 0) ? weexRoot.children[0] : null;
@@ -340,7 +339,7 @@ export default {
340
339
 
341
340
  // 如果子元素总高度为0或未使用,则使用元素本身的高度
342
341
  if (elementHeight <= 0) {
343
- elementHeight = element.offsetHeight || element.clientHeight || element.scrollHeight;
342
+ elementHeight = element.offsetHeight || element.clientHeight;
344
343
  }
345
344
 
346
345
  if (elementHeight > 0) {
@@ -184,6 +184,11 @@ export default {
184
184
  });
185
185
  },
186
186
  methods: {
187
+ finishFullScreen(){
188
+ this.embedPosition = this.defaultPosition;
189
+ this.embedHeight = this.defaultHeight;
190
+ this.embedWidth = this.defaultWidth;
191
+ },
187
192
  onFullscreenChange(isFullScreeen) {
188
193
  if (isFullScreeen.flag) {
189
194
  this.embedPosition = 'fixed';
@@ -236,5 +241,10 @@ export default {
236
241
  this.$emit('onPreviewImageClick', res);
237
242
  },
238
243
  },
244
+ destroy(){
245
+ this.embedPosition = this.defaultPosition;
246
+ this.embedHeight = this.defaultHeight;
247
+ this.embedWidth = this.defaultWidth;
248
+ }
239
249
  };
240
250
  </script>
@@ -285,33 +285,38 @@ function createVBindMethod(methodName, paramName) {
285
285
  t.returnStatement(t.objectExpression([]))
286
286
  ])
287
287
  ),
288
+ // 先创建一个新对象(深拷贝),避免修改原始响应式数据
289
+ t.variableDeclaration('const', [
290
+ t.variableDeclarator(
291
+ t.identifier('newObj'),
292
+ t.callExpression(
293
+ t.memberExpression(t.identifier('Object'), t.identifier('assign')),
294
+ [t.objectExpression([]), t.identifier(paramName)]
295
+ )
296
+ )
297
+ ]),
298
+ // 如果新对象有 style 属性,则对其进行 px → rem 转换
288
299
  t.ifStatement(
289
300
  t.logicalExpression(
290
301
  '&&',
291
- t.identifier(paramName),
292
- t.memberExpression(t.identifier(paramName), t.identifier('style'))
302
+ t.identifier('newObj'),
303
+ t.memberExpression(t.identifier('newObj'), t.identifier('style'))
293
304
  ),
294
- // 1) 如果入参存在且包含 style,先做 px → rem 转换
295
305
  t.blockStatement([
296
306
  t.expressionStatement(
297
307
  t.assignmentExpression(
298
308
  '=',
299
- t.memberExpression(t.identifier(paramName), t.identifier('style')),
309
+ t.memberExpression(t.identifier('newObj'), t.identifier('style')),
300
310
  t.callExpression(
301
311
  t.memberExpression(t.thisExpression(), t.identifier('_px2rem')),
302
- [t.memberExpression(t.identifier(paramName), t.identifier('style'))]
312
+ [t.memberExpression(t.identifier('newObj'), t.identifier('style'))]
303
313
  )
304
314
  )
305
315
  )
306
316
  ])
307
317
  ),
308
- // 2) 返回一个新对象(浅拷贝)以改变引用地址,便于触发依赖更新
309
- t.returnStatement(
310
- t.callExpression(
311
- t.memberExpression(t.identifier('Object'), t.identifier('assign')),
312
- [t.objectExpression([]), t.identifier(paramName)]
313
- )
314
- )
318
+ // 返回处理后的新对象
319
+ t.returnStatement(t.identifier('newObj'))
315
320
  ])
316
321
  )
317
322
  }