@dolphinweex/weex-harmony 0.1.85 → 0.1.86

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.85",
3
+ "version": "0.1.86",
4
4
  "description": "weex harmony adapter",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -33,6 +33,7 @@ const weexModule = weex.requireModule("weexModule");
33
33
  export default {
34
34
  data() {
35
35
  return {
36
+ isDebug: false, // 调试开关
36
37
  url: "",
37
38
  pluginType: "weex",
38
39
  backgroundColor: "transparent",
@@ -45,8 +46,10 @@ export default {
45
46
  _resizeObserver: null,
46
47
  _heightCheckTimer: null,
47
48
  _weexRoot: null,
49
+ _scrollerInner: null,
48
50
  _useChildrenTotalHeight: false,
49
51
  _parentElement: null, // 符合条件的父级元素
52
+ _mutationObserver: null,
50
53
  };
51
54
  },
52
55
  components: {
@@ -74,6 +77,7 @@ export default {
74
77
  },
75
78
  },
76
79
  created() {
80
+ this.debugLog(`created: embedId=${this.embedId}, src=${this.src}`);
77
81
  weexModule.callNative(
78
82
  `webview.webHandle`,
79
83
  {
@@ -84,12 +88,15 @@ export default {
84
88
  pluginData: this.pluginData,
85
89
  },
86
90
  (args) => {
91
+ this.debugLog(`callNative 回调: args=`, args);
87
92
  if (args.progressText) {
88
93
  this.progressText = args.progressText;
94
+ this.debugLog(`设置progressText: ${args.progressText}`);
89
95
  } else if (args.url) {
90
96
  this.url = args.url;
91
97
  this.backgroundColor = args.pageBackgroundColor;
92
- this.pluginType = args.pluginType
98
+ this.pluginType = args.pluginType;
99
+ this.debugLog(`设置url: ${args.url}, backgroundColor: ${args.pageBackgroundColor}, pluginType: ${args.pluginType}`);
93
100
  }
94
101
  }
95
102
  );
@@ -110,9 +117,15 @@ export default {
110
117
  },
111
118
  },
112
119
  mounted() {
120
+ this.debugLog(`mounted: embedId=${this.embedId}, isPluginMenu=${this.isPluginMenu}, height=${this.height}`);
113
121
  // this.$refs["iframe"].addEventListener('load', this.onPageFinish);
114
122
  const iframeEl = this.$refs.iframe;
115
- if (iframeEl) iframeEl.addEventListener("load", this.onPageFinish);
123
+ if (iframeEl) {
124
+ this.debugLog(`找到iframe元素,添加load监听`);
125
+ iframeEl.addEventListener("load", this.onPageFinish);
126
+ } else {
127
+ this.debugWarn(`未找到iframe元素`);
128
+ }
116
129
  // 从父组件根节点内查找:既是 .midea-common-weex-view,又包含当前 iframe 的 embedId
117
130
  const findWrapperFromParent = () => {
118
131
  const parentEl = this.$parent && this.$parent.$el;
@@ -169,8 +182,20 @@ export default {
169
182
  window.addEventListener("message", this._onMessage, false);
170
183
  },
171
184
  methods: {
185
+ debugLog(...args) {
186
+ if (this.isDebug) {
187
+ console.log('cdj----plugin@midea-common-weex-view.vue', ...args);
188
+ }
189
+ },
190
+ debugWarn(...args) {
191
+ if (this.isDebug) {
192
+ console.warn('cdj----plugin@midea-common-weex-view.vue', ...args);
193
+ }
194
+ },
172
195
  onPageFinish() {
196
+ this.debugLog(`onPageFinish 触发: embedId=${this.embedId}`);
173
197
  if (this.$refs["iframe"]) {
198
+ this.debugLog(`iframe引用存在,准备注入全局变量`);
174
199
  this.$refs["iframe"].contentWindow.$midea_harmony_native =
175
200
  window.$midea_harmony_native;
176
201
  this.$refs["iframe"].contentWindow.isIframe = true;
@@ -179,210 +204,213 @@ export default {
179
204
  "*"
180
205
  );
181
206
  setTimeout(()=>{
207
+ this.debugLog(`延迟后开始监听高度: embedId=${this.embedId}`);
182
208
  this.startWeexRootHeightMonitoring();
183
209
  })
210
+ } else {
211
+ this.debugWarn(`onPageFinish: iframe引用不存在`);
184
212
  }
185
213
  },
186
214
 
187
- // 计算 weex-root 所有子元素的高度总和
188
- calculateWeexRootChildrenHeight(weexRoot) {
189
- if (!weexRoot || !weexRoot.children || weexRoot.children.length === 0) {
215
+ // 计算元素子级总高度
216
+ calculateWeexRootChildrenHeight(el) {
217
+ this.debugLog(`calculateWeexRootChildrenHeight 调用, element=${el ? (el.className || el.tagName) : 'null'}`);
218
+ if (!el || !el.children || el.children.length === 0) {
219
+ this.debugWarn(`calculateWeexRootChildrenHeight: 无子元素`);
190
220
  return 0;
191
221
  }
192
222
 
193
- let totalHeight = 0;
194
- const children = Array.from(weexRoot.children);
223
+ const children = Array.from(el.children);
224
+ let maxBottom = 0;
225
+ let minTop = Infinity;
226
+ let totalOffsetHeight = 0;
195
227
 
196
- // 方法1: 计算所有子元素的 bottom 位置的最大值,减去第一个子元素的 top 位置
197
- if (children.length > 0) {
198
- const firstChildRect = children[0].getBoundingClientRect();
199
- const rootRect = weexRoot.getBoundingClientRect();
200
- let maxBottom = firstChildRect.bottom;
201
-
202
- children.forEach((child) => {
203
- const rect = child.getBoundingClientRect();
228
+ const parentRect = el.getBoundingClientRect();
229
+
230
+ children.forEach((child, index) => {
231
+ const rect = child.getBoundingClientRect();
232
+ this.debugLog(`子级 ${index}: top=${rect.top}, bottom=${rect.bottom}, height=${rect.height}`);
233
+ if (rect.height > 0) {
204
234
  maxBottom = Math.max(maxBottom, rect.bottom);
205
- });
206
-
207
- totalHeight = maxBottom - rootRect.top;
208
- }
235
+ minTop = Math.min(minTop, rect.top);
236
+ }
237
+ totalOffsetHeight += (child.offsetHeight || 0);
238
+ });
239
+
240
+ // 优先使用 getBoundingClientRect 计算出的相对高度
241
+ let height = (maxBottom > minTop) ? (maxBottom - minTop) : 0;
209
242
 
210
- // 如果方法1计算出的高度为0或太小,则累加所有子元素的高度
211
- if (totalHeight <= 0) {
212
- children.forEach((child) => {
213
- const childHeight = child.offsetHeight || child.clientHeight || 0;
214
- totalHeight += childHeight;
215
- });
243
+ this.debugLog(`计算高度详情: rectHeight=${height}, totalOffsetHeight=${totalOffsetHeight}, parentRectTop=${parentRect.top}`);
244
+
245
+ // 如果 rect 计算结果不理想,使用 offsetHeight 累积作为参考
246
+ if (height <= 0) {
247
+ height = totalOffsetHeight;
216
248
  }
217
249
 
218
- return totalHeight;
250
+ return height;
219
251
  },
220
252
 
221
- // 监听 iframe 内 .weex-root 第一个子元素或 .weex-scroller-inner 的高度
253
+ // 监听 iframe 内容高度变化
222
254
  startWeexRootHeightMonitoring() {
223
- // 尝试多次查找元素(因为 iframe 内容可能还在加载)
255
+ this.debugLog(`startWeexRootHeightMonitoring 开始: embedId=${this.embedId}`);
224
256
  let attempts = 0;
225
- const maxAttempts = 10; // 最多尝试 20 次
257
+ const maxAttempts = 15;
226
258
 
227
259
  this._heightCheckTimer = setInterval(() => {
228
260
  attempts++;
261
+ this.debugLog(`查找元素尝试 ${attempts}/${maxAttempts}`);
229
262
 
230
263
  const iframe = document.getElementById(this.embedId);
231
- if (!iframe) {
232
- if (attempts >= maxAttempts) {
233
- clearInterval(this._heightCheckTimer);
234
- console.warn(`未找到 iframe: ${this.embedId}`);
235
- }
236
- return;
237
- }
238
-
264
+ if (!iframe) return;
265
+
239
266
  try {
240
- const iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
241
- let targetElement = null;
242
- let elementDesc = '';
243
- let useChildrenTotalHeight = false; // 标记是否使用子元素总高度
244
- // 查找 .weex-root
245
- const weexRoot = iframeDocument.querySelector('.weex-root');
246
- const weexRootFirstChild = (weexRoot && weexRoot.children.length > 0) ? weexRoot.children[0] : null;
247
-
248
- // 查找 .weex-scroller-inner
249
- const weexScrollerInner = iframeDocument.querySelector('.weex-scroller-inner');
250
-
251
- // 如果两个都找到了,比较高度,谁大用谁
252
- if (weexRootFirstChild && weexScrollerInner) {
253
- // 计算 weex-root 所有子元素的总高度
254
- const rootChildrenTotalHeight = this.calculateWeexRootChildrenHeight(weexRoot);
255
- const rootFirstChildHeight = weexRootFirstChild.offsetHeight || weexRootFirstChild.clientHeight || 0;
256
- // 使用子元素总高度和第一个子元素高度的较大值
257
- const rootHeight = Math.max(rootChildrenTotalHeight, rootFirstChildHeight);
258
- const scrollerHeight = weexScrollerInner.offsetHeight || weexScrollerInner.clientHeight || 0;
259
-
260
- if (rootHeight >= scrollerHeight) {
261
- targetElement = weexRootFirstChild;
262
- useChildrenTotalHeight = rootChildrenTotalHeight > rootFirstChildHeight;
263
- elementDesc = useChildrenTotalHeight
264
- ? `.weex-root 的所有子元素总高度 (${rootChildrenTotalHeight}px)`
265
- : `.weex-root 的第一个子元素 (高度: ${rootHeight}px)`;
266
- } else {
267
- targetElement = weexScrollerInner;
268
- elementDesc = `.weex-scroller-inner (高度: ${scrollerHeight}px)`;
267
+ const doc = iframe.contentDocument || iframe.contentWindow.document;
268
+ let target = null;
269
+
270
+ // 1. 优先找 weex-scroller-inner 及其内部的 weex-root
271
+ const scroller = doc.querySelector('.weex-scroller-inner');
272
+ if (scroller) {
273
+ this.debugLog(`找到 .weex-scroller-inner`);
274
+ target = scroller.querySelector('.weex-root') || scroller.children[0];
275
+ } else {
276
+ // 2. 备选找全局 weex-root
277
+ target = doc.querySelector('.weex-root');
278
+ }
279
+
280
+ if (!target) {
281
+ if (attempts >= maxAttempts) {
282
+ clearInterval(this._heightCheckTimer);
283
+ this.debugWarn(`达到最大尝试次数,未找到目标元素`);
269
284
  }
270
- } else if (weexRootFirstChild) {
271
- // 只找到 .weex-root 的第一个子元素,使用所有子元素的总高度
272
- targetElement = weexRootFirstChild;
273
- useChildrenTotalHeight = true;
274
- const rootChildrenTotalHeight = this.calculateWeexRootChildrenHeight(weexRoot);
275
- elementDesc = `.weex-root 的所有子元素总高度 (${rootChildrenTotalHeight}px)`;
276
- } else if (weexScrollerInner) {
277
- // 只找到 .weex-scroller-inner
278
- targetElement = weexScrollerInner;
279
- elementDesc = '.weex-scroller-inner';
285
+ return;
280
286
  }
281
-
282
- // 找到目标元素,开始监听
283
- if (targetElement) {
284
- console.log(`找到 ${elementDesc},开始监听高度变化`, targetElement);
285
-
286
- // 保存 weexRoot 引用和是否使用子元素总高度的标记
287
- this._weexRoot = weexRoot;
288
- this._useChildrenTotalHeight = useChildrenTotalHeight;
289
-
290
- // 清除定时器,找到了就不再尝试
287
+
288
+ const height = this.calculateWeexRootChildrenHeight(target);
289
+ this.debugLog(`尝试计算高度: ${height}px, 目标元素: ${target.className || target.tagName}`);
290
+
291
+ if (height > 0 || attempts >= maxAttempts) {
291
292
  clearInterval(this._heightCheckTimer);
292
-
293
- // 立即更新一次高度
294
- this.updateIframeHeightFromElement(targetElement);
295
-
296
- // 使用 ResizeObserver 监听元素高度变化
297
- // 如果使用子元素总高度,需要监听 weexRoot 的所有子元素
298
- if (useChildrenTotalHeight && weexRoot) {
299
- // 监听 weexRoot 本身的变化
300
- this._resizeObserver = new ResizeObserver(() => {
301
- this.updateIframeHeightFromElement(targetElement);
302
- });
303
- this._resizeObserver.observe(weexRoot);
304
-
305
- // 同时监听所有子元素的变化
306
- Array.from(weexRoot.children).forEach((child) => {
307
- this._resizeObserver.observe(child);
308
- });
293
+ if (height > 0) {
294
+ this._weexRoot = target;
295
+ this._useChildrenTotalHeight = true;
296
+ this.updateIframeHeightFromElement(target);
297
+ this.setupObservers(target);
309
298
  } else {
310
- this._resizeObserver = new ResizeObserver(() => {
311
- this.updateIframeHeightFromElement(targetElement);
312
- });
313
- this._resizeObserver.observe(targetElement);
299
+ this.debugWarn(`高度始终为0,停止尝试`);
314
300
  }
315
-
316
- } else if (attempts >= maxAttempts) {
317
- clearInterval(this._heightCheckTimer);
318
- console.warn('未找到 .weex-root 的第一个子元素 或 .weex-scroller-inner');
319
301
  }
320
302
  } catch (e) {
321
- if (attempts >= maxAttempts) {
322
- clearInterval(this._heightCheckTimer);
323
- console.warn('无法访问 iframe 内容(可能跨域):', e.message);
324
- }
303
+ this.debugWarn(`监控过程异常:`, e.message);
304
+ if (attempts >= maxAttempts) clearInterval(this._heightCheckTimer);
325
305
  }
326
- }, 200); // 每 200ms 尝试一次
306
+ }, 200);
307
+ },
308
+
309
+ setupObservers(target) {
310
+ this.debugLog(`设置 Observers: target=${target ? (target.className || target.tagName) : 'null'}`);
311
+
312
+ const onUpdate = () => {
313
+ this.debugLog(`变化触发更新`);
314
+ this.updateIframeHeightFromElement(target);
315
+ };
316
+
317
+ if (this._resizeObserver) this._resizeObserver.disconnect();
318
+ if (this._mutationObserver) this._mutationObserver.disconnect();
319
+
320
+ this._resizeObserver = new ResizeObserver(() => onUpdate());
321
+ this._mutationObserver = new MutationObserver(() => onUpdate());
322
+
323
+ if (target) {
324
+ this._resizeObserver.observe(target);
325
+ this._mutationObserver.observe(target, { childList: true, subtree: true, attributes: true });
326
+ // 监听直接子节点
327
+ Array.from(target.children).forEach(child => this._resizeObserver.observe(child));
328
+ }
327
329
  },
328
330
 
329
331
  // 根据元素高度更新 iframe 高度
330
332
  updateIframeHeightFromElement(element) {
331
- if (!element) return;
333
+ this.debugLog(`updateIframeHeightFromElement 调用: element=${!!element}, embedId=${this.embedId}`);
334
+ if (!element) {
335
+ this.debugWarn(`updateIframeHeightFromElement: element为空`);
336
+ return;
337
+ }
332
338
 
333
339
  let elementHeight = 0;
334
340
 
335
341
  // 如果标记了使用子元素总高度,且 weexRoot 存在,计算所有子元素的总高度
336
342
  if (this._useChildrenTotalHeight && this._weexRoot) {
337
343
  elementHeight = this.calculateWeexRootChildrenHeight(this._weexRoot);
344
+ this.debugLog(`使用子元素总高度: ${elementHeight}px`);
338
345
  }
339
346
 
340
347
  // 如果子元素总高度为0或未使用,则使用元素本身的高度
341
348
  if (elementHeight <= 0) {
342
- elementHeight = element.offsetHeight || element.clientHeight;
349
+ const offsetHeight = element.offsetHeight || 0;
350
+ const clientHeight = element.clientHeight || 0;
351
+ elementHeight = offsetHeight || clientHeight;
352
+ this.debugLog(`使用元素本身高度: offsetHeight=${offsetHeight}, clientHeight=${clientHeight}, 最终=${elementHeight}px`);
343
353
  }
344
354
 
355
+ this.debugLog(`计算得到elementHeight=${elementHeight}px`);
356
+
345
357
  if (elementHeight > 0) {
346
358
  // 限制最大高度,防止死循环
347
359
  // 策略:使用 window.innerHeight 减去 iframe 距离视口顶部的距离
348
360
  let maxHeight = window.innerHeight;
361
+ this.debugLog(`初始maxHeight(window.innerHeight)=${maxHeight}px`);
349
362
 
350
363
  if (this.$refs.iframe) {
351
364
  try {
352
365
  const rect = this.$refs.iframe.getBoundingClientRect();
366
+ this.debugLog(`iframe位置: top=${rect.top}, left=${rect.left}, width=${rect.width}, height=${rect.height}`);
353
367
  // 如果 top > 0,说明 iframe 顶部在视口下方或视口内,减去 top 得到剩余可用高度
354
368
  // 如果 top <= 0,说明 iframe 顶部已滚出视口上方,此时最大高度限制为 window.innerHeight (防止无限增高)
355
369
  if (rect.top > 0) {
356
370
  maxHeight = window.innerHeight - rect.top;
371
+ this.debugLog(`调整后maxHeight=${maxHeight}px (top=${rect.top})`);
357
372
  }
358
373
  } catch (e) {
359
- console.warn('获取 iframe 位置失败:', e);
374
+ this.debugWarn('获取 iframe 位置失败:', e);
360
375
  }
376
+ } else {
377
+ this.debugWarn(`this.$refs.iframe 不存在`);
361
378
  }
362
379
 
363
380
  // 确保 maxHeight 不为负数
364
381
  maxHeight = Math.max(maxHeight, 0);
382
+ this.debugLog(`最终maxHeight=${maxHeight}px`);
365
383
 
366
384
  // 如果计算出的高度超过了最大限制,则使用最大限制
367
385
  const finalHeight = !this.isPluginMenu ? elementHeight > maxHeight ? maxHeight : elementHeight : elementHeight
386
+ this.debugLog(`finalHeight=${finalHeight}px (isPluginMenu=${this.isPluginMenu}, elementHeight=${elementHeight}, maxHeight=${maxHeight})`);
368
387
 
369
388
  // 更新包装器高度
370
389
  if (this._wrapperEl) {
371
390
  this._wrapperEl.style.height = `${finalHeight}px`;
391
+ this.debugLog(`更新包装器高度: ${finalHeight}px`);
392
+ } else {
393
+ this.debugLog(`包装器元素不存在`);
372
394
  }
373
395
 
374
396
  // 更新 iframe 高度(考虑 weex scale)
375
- const newHeight = `${finalHeight / weex.config.env.scale}px`;
397
+ const scale = weex.config.env.scale || 1;
398
+ const newHeight = `${finalHeight / scale}px`;
399
+ this.debugLog(`计算newHeight=${newHeight} (finalHeight=${finalHeight}, scale=${scale}), 当前height=${this.height}`);
376
400
  if (this.height !== newHeight) {
377
401
  this.height = newHeight;
378
- console.log(`iframe 高度已更新: ${finalHeight}px -> ${newHeight} (embedId: ${this.embedId}, max: ${maxHeight}px)`);
402
+ this.debugLog(`✅ iframe 高度已更新: ${finalHeight}px -> ${newHeight} (embedId: ${this.embedId}, max: ${maxHeight}px)`);
379
403
  // 如果父级元素存在且符合条件,也给父级元素设置高度
380
404
  if (this._parentElement) {
381
405
  this._parentElement.style.height = `${finalHeight}px`;
406
+ this.debugLog(`更新父级元素高度: ${finalHeight}px`);
382
407
  }
408
+ } else {
409
+ this.debugLog(`⚠️ 高度未变化,不更新 (当前=${this.height}, 新值=${newHeight})`);
383
410
  }
384
411
 
385
-
412
+ } else {
413
+ this.debugWarn(`⚠️ elementHeight <= 0,不更新高度 (elementHeight=${elementHeight})`);
386
414
  }
387
415
  },
388
416
  handleGestureBubble(gestureData) {
@@ -425,37 +453,51 @@ export default {
425
453
  metaKey: gestureData.metaKey
426
454
  }));
427
455
  } catch (e) {
428
- console.warn('手势事件冒泡失败:', e);
456
+ this.debugWarn('手势事件冒泡失败:', e);
429
457
  }
430
458
  },
431
459
  },
432
460
  beforeDestroy() {
461
+ this.debugLog(`beforeDestroy: embedId=${this.embedId}`);
433
462
  // 清理 ResizeObserver
434
463
  if (this._resizeObserver) {
464
+ this.debugLog(`清理 ResizeObserver`);
435
465
  this._resizeObserver.disconnect();
436
466
  this._resizeObserver = null;
437
467
  }
468
+
469
+ // 清理 MutationObserver
470
+ if (this._mutationObserver) {
471
+ this.debugLog(`清理 MutationObserver`);
472
+ this._mutationObserver.disconnect();
473
+ this._mutationObserver = null;
474
+ }
438
475
 
439
476
  // 清理定时器
440
477
  if (this._heightCheckTimer) {
478
+ this.debugLog(`清理定时器`);
441
479
  clearInterval(this._heightCheckTimer);
442
480
  this._heightCheckTimer = null;
443
481
  }
444
482
 
445
483
  // 清理引用
446
484
  this._weexRoot = null;
485
+ this._scrollerInner = null;
447
486
  this._useChildrenTotalHeight = false;
448
487
 
449
488
  // 清理RAF避免内存泄漏
450
489
  if (this._rafId) {
490
+ this.debugLog(`清理RAF`);
451
491
  cancelAnimationFrame(this._rafId);
452
492
  this._rafId = null;
453
493
  }
454
494
 
455
495
  // 清理消息监听
456
496
  if (this._onMessage) {
497
+ this.debugLog(`清理消息监听`);
457
498
  window.removeEventListener("message", this._onMessage, false);
458
499
  }
500
+ this.debugLog(`beforeDestroy 完成`);
459
501
  },
460
502
  };
461
503
  </script>
@@ -184,6 +184,27 @@ export default {
184
184
  });
185
185
  },
186
186
  methods: {
187
+ captureImage(params,callback) {
188
+ delete params.refId
189
+ weexModule.callNative(
190
+ 'ijkLinkApi',
191
+ {
192
+ method: 'captureImage',
193
+ name: this.embedId,
194
+ params
195
+ },
196
+ callback
197
+ );
198
+ },
199
+ finishFullScreen(){
200
+ try{
201
+ this.$bridge.setPageOrientation({ orientation: 0 })
202
+ }catch(e){
203
+ }
204
+ this.embedPosition = this.defaultPosition;
205
+ this.embedHeight = this.windowHeight;
206
+ this.embedWidth = this.windowWidth;
207
+ },
187
208
  onFullscreenChange(isFullScreeen) {
188
209
  if (isFullScreeen.flag) {
189
210
  this.embedPosition = 'fixed';
@@ -201,11 +222,11 @@ export default {
201
222
  },
202
223
 
203
224
  onStart(res) {
204
- this.$emit('onStart', res);
225
+ this.$emit('start', res);
205
226
  },
206
227
 
207
228
  onPause(res) {
208
- this.$emit('onPause', res);
229
+ this.$emit('Pause', res);
209
230
  },
210
231
 
211
232
  finish(res) {
@@ -213,11 +234,11 @@ export default {
213
234
  },
214
235
 
215
236
  onFail(res) {
216
- this.$emit('onFail', res);
237
+ this.$emit('fail', res);
217
238
  },
218
239
 
219
240
  onReadyToPlay(res) {
220
- this.$emit('onReadyToPlay', res);
241
+ this.$emit('readyToPlay', res);
221
242
  },
222
243
 
223
244
  deleteVideo(res) {
@@ -228,7 +249,7 @@ export default {
228
249
  this.$emit('onDownloadSuccess', res);
229
250
  },
230
251
 
231
- onStartDownload(res) {
252
+ onStartDownload(res) {
232
253
  this.$emit('onStartDownload', res);
233
254
  },
234
255
 
@@ -236,5 +257,10 @@ export default {
236
257
  this.$emit('onPreviewImageClick', res);
237
258
  },
238
259
  },
260
+ destroy(){
261
+ this.embedPosition = this.defaultPosition;
262
+ this.embedHeight = this.defaultHeight;
263
+ this.embedWidth = this.defaultWidth;
264
+ }
239
265
  };
240
266
  </script>
@@ -110,9 +110,21 @@ export default {
110
110
  }
111
111
  },
112
112
  methods: {
113
+ captureImage(params,callback) {
114
+ delete params.refId
115
+ weexModule.callNative(
116
+ 'ipcLinkApi',
117
+ {
118
+ method: 'captureImage',
119
+ name: this.embedId,
120
+ params
121
+ },
122
+ callback
123
+ );
124
+ },
113
125
  switchVideoQuality(params,callback) {
114
126
  weexModule.callNative(
115
- 'iotLinkApi',
127
+ 'ipcLinkApi',
116
128
  {
117
129
  method: 'switchVideoQuality',
118
130
  name: this.embedId,
@@ -123,7 +135,7 @@ export default {
123
135
  },
124
136
  getVideoNetworkSpeed(params,callback) {
125
137
  weexModule.callNative(
126
- 'iotLinkApi',
138
+ 'ipcLinkApi',
127
139
  {
128
140
  method: 'getVideoNetworkSpeed',
129
141
  name: this.embedId,
@@ -134,7 +146,7 @@ export default {
134
146
  },
135
147
  startRecord(params,callback) {
136
148
  weexModule.callNative(
137
- 'iotLinkApi',
149
+ 'ipcLinkApi',
138
150
  {
139
151
  method: 'startRecord',
140
152
  name: this.embedId,
@@ -145,7 +157,7 @@ export default {
145
157
  },
146
158
  stopRecord(params,callback) {
147
159
  weexModule.callNative(
148
- 'iotLinkApi',
160
+ 'ipcLinkApi',
149
161
  {
150
162
  method: 'stopRecord',
151
163
  name: this.embedId,
@@ -156,7 +168,7 @@ export default {
156
168
  },
157
169
  changeAudioStatus(params,callback){
158
170
  weexModule.callNative(
159
- 'iotLinkApi',
171
+ 'ipcLinkApi',
160
172
  {
161
173
  method: 'changeAudioStatus',
162
174
  name: this.embedId,
@@ -24,6 +24,7 @@
24
24
 
25
25
  <script>
26
26
  import BaseSameLayer from './baseSameLayer.vue';
27
+ const weexModule = weex.requireModule('weexModule');
27
28
 
28
29
  export default {
29
30
  data() {
@@ -184,14 +185,26 @@ export default {
184
185
  });
185
186
  },
186
187
  methods: {
188
+ captureImage(params,callback) {
189
+ delete params.refId
190
+ weexModule.callNative(
191
+ 'ijkLinkApi',
192
+ {
193
+ method: 'captureImage',
194
+ name: this.embedId,
195
+ params
196
+ },
197
+ callback
198
+ );
199
+ },
187
200
  finishFullScreen(){
188
201
  try{
189
202
  this.$bridge.setPageOrientation({ orientation: 0 })
190
203
  }catch(e){
191
204
  }
192
205
  this.embedPosition = this.defaultPosition;
193
- this.embedHeight = this.defaultHeight;
194
- this.embedWidth = this.defaultWidth;
206
+ this.embedHeight = this.windowHeight;
207
+ this.embedWidth = this.windowWidth;
195
208
  },
196
209
  onFullscreenChange(isFullScreeen) {
197
210
  if (isFullScreeen.flag) {
@@ -237,7 +250,7 @@ export default {
237
250
  this.$emit('onDownloadSuccess', res);
238
251
  },
239
252
 
240
- onStartDownload(res) {
253
+ onStartDownload(res) {
241
254
  this.$emit('onStartDownload', res);
242
255
  },
243
256
 
@@ -110,6 +110,18 @@ export default {
110
110
  }
111
111
  },
112
112
  methods: {
113
+ captureImage(params,callback) {
114
+ delete params.refId
115
+ weexModule.callNative(
116
+ 'ipcLinkApi',
117
+ {
118
+ method: 'captureImage',
119
+ name: this.embedId,
120
+ params
121
+ },
122
+ callback
123
+ );
124
+ },
113
125
  switchVideoQuality(params,callback) {
114
126
  weexModule.callNative(
115
127
  'ipcLinkApi',
@@ -53,10 +53,14 @@ export default {
53
53
  // 深度监听 data 对象的变化
54
54
  data: {
55
55
  handler(newVal, oldVal) {
56
- const newStr = JSON.stringify(newVal);
57
- const oldStr = JSON.stringify(oldVal);
58
- if (newStr !== oldStr) {
59
- this.dataVersion++;
56
+ try{
57
+ const newStr = JSON.stringify(newVal);
58
+ const oldStr = JSON.stringify(oldVal);
59
+ if (newStr !== oldStr) {
60
+ this.dataVersion++;
61
+ }
62
+ }catch(e){
63
+
60
64
  }
61
65
  },
62
66
  deep: true,