@dolphinweex/weex-harmony 0.1.73 → 0.1.75

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.73",
3
+ "version": "0.1.75",
4
4
  "description": "weex harmony adapter",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -38,6 +38,8 @@ export default {
38
38
  Date.now().toString(36) + Math.random().toString(36).substring(2)
39
39
  }`,
40
40
  height: '0px',
41
+ _resizeObserver: null,
42
+ _heightCheckTimer: null,
41
43
  };
42
44
  },
43
45
  components: {
@@ -126,20 +128,6 @@ export default {
126
128
  this._rafId = null;
127
129
  this._pendingGesture = null;
128
130
  this._onMessage = (event) => {
129
- if(event.data.type==='IFRAME_CONTENT_HEIGHT'){
130
- const h = Number(event.data.height) || 0;
131
- if (!h) {
132
- this.height = '100%'
133
- return;
134
- }
135
- if (this._wrapperEl) {
136
- this._wrapperEl.style.height = `${h}px`;
137
- }
138
- this.height = `${h / weex.config.env.scale}px`;
139
- return
140
- }else{
141
- document.getElementsByTagName('iframe')[0].height = event.data.height
142
- }
143
131
  // 处理iframe手势跨窗口传递冒泡
144
132
  if (event.data.type === 'IFRAME_GESTURE') {
145
133
  const gestureData = event.data;
@@ -173,6 +161,112 @@ export default {
173
161
  JSON.stringify(window.$midea_harmony_native),
174
162
  "*"
175
163
  );
164
+
165
+ // 启动 weex-root 第一个子元素的高度监听
166
+ this.startWeexRootHeightMonitoring();
167
+ }
168
+ },
169
+
170
+ // 监听 iframe 内 .weex-root 第一个子元素或 .weex-scroller-inner 的高度
171
+ startWeexRootHeightMonitoring() {
172
+ // 尝试多次查找元素(因为 iframe 内容可能还在加载)
173
+ let attempts = 0;
174
+ const maxAttempts = 20; // 最多尝试 20 次
175
+
176
+ this._heightCheckTimer = setInterval(() => {
177
+ attempts++;
178
+
179
+ const iframe = document.getElementById(this.embedId);
180
+ if (!iframe) {
181
+ if (attempts >= maxAttempts) {
182
+ clearInterval(this._heightCheckTimer);
183
+ console.warn(`未找到 iframe: ${this.embedId}`);
184
+ }
185
+ return;
186
+ }
187
+
188
+ try {
189
+ const iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
190
+ let targetElement = null;
191
+ let elementDesc = '';
192
+
193
+ // 查找 .weex-root 的第一个子元素
194
+ const weexRoot = iframeDocument.querySelector('.weex-root');
195
+ const weexRootFirstChild = (weexRoot && weexRoot.children.length > 0) ? weexRoot.children[0] : null;
196
+
197
+ // 查找 .weex-scroller-inner
198
+ const weexScrollerInner = iframeDocument.querySelector('.weex-scroller-inner');
199
+
200
+ // 如果两个都找到了,比较高度,谁大用谁
201
+ if (weexRootFirstChild && weexScrollerInner) {
202
+ const rootHeight = weexRootFirstChild.offsetHeight || weexRootFirstChild.clientHeight || 0;
203
+ const scrollerHeight = weexScrollerInner.offsetHeight || weexScrollerInner.clientHeight || 0;
204
+
205
+ if (rootHeight >= scrollerHeight) {
206
+ targetElement = weexRootFirstChild;
207
+ elementDesc = `.weex-root 的第一个子元素 (高度: ${rootHeight}px)`;
208
+ } else {
209
+ targetElement = weexScrollerInner;
210
+ elementDesc = `.weex-scroller-inner (高度: ${scrollerHeight}px)`;
211
+ }
212
+ } else if (weexRootFirstChild) {
213
+ // 只找到 .weex-root 的第一个子元素
214
+ targetElement = weexRootFirstChild;
215
+ elementDesc = '.weex-root 的第一个子元素';
216
+ } else if (weexScrollerInner) {
217
+ // 只找到 .weex-scroller-inner
218
+ targetElement = weexScrollerInner;
219
+ elementDesc = '.weex-scroller-inner';
220
+ }
221
+
222
+ // 找到目标元素,开始监听
223
+ if (targetElement) {
224
+ console.log(`找到 ${elementDesc},开始监听高度变化`, targetElement);
225
+
226
+ // 清除定时器,找到了就不再尝试
227
+ clearInterval(this._heightCheckTimer);
228
+
229
+ // 立即更新一次高度
230
+ this.updateIframeHeightFromElement(targetElement);
231
+
232
+ // 使用 ResizeObserver 监听元素高度变化
233
+ this._resizeObserver = new ResizeObserver(() => {
234
+ this.updateIframeHeightFromElement(targetElement);
235
+ });
236
+ this._resizeObserver.observe(targetElement);
237
+
238
+ } else if (attempts >= maxAttempts) {
239
+ clearInterval(this._heightCheckTimer);
240
+ console.warn('未找到 .weex-root 的第一个子元素 或 .weex-scroller-inner');
241
+ }
242
+ } catch (e) {
243
+ if (attempts >= maxAttempts) {
244
+ clearInterval(this._heightCheckTimer);
245
+ console.warn('无法访问 iframe 内容(可能跨域):', e.message);
246
+ }
247
+ }
248
+ }, 200); // 每 200ms 尝试一次
249
+ },
250
+
251
+ // 根据元素高度更新 iframe 高度
252
+ updateIframeHeightFromElement(element) {
253
+ if (!element) return;
254
+
255
+ // 获取元素的实际高度
256
+ const elementHeight = element.offsetHeight || element.clientHeight || element.scrollHeight;
257
+
258
+ if (elementHeight > 0) {
259
+ // 更新包装器高度
260
+ if (this._wrapperEl) {
261
+ this._wrapperEl.style.height = `${elementHeight}px`;
262
+ }
263
+
264
+ // 更新 iframe 高度(考虑 weex scale)
265
+ const newHeight = `${elementHeight / weex.config.env.scale}px`;
266
+ if (this.height !== newHeight) {
267
+ this.height = newHeight;
268
+ console.log(`iframe 高度已更新: ${elementHeight}px -> ${newHeight} (embedId: ${this.embedId})`);
269
+ }
176
270
  }
177
271
  },
178
272
  handleGestureBubble(gestureData) {
@@ -220,11 +314,24 @@ export default {
220
314
  },
221
315
  },
222
316
  beforeDestroy() {
317
+ // 清理 ResizeObserver
318
+ if (this._resizeObserver) {
319
+ this._resizeObserver.disconnect();
320
+ this._resizeObserver = null;
321
+ }
322
+
323
+ // 清理定时器
324
+ if (this._heightCheckTimer) {
325
+ clearInterval(this._heightCheckTimer);
326
+ this._heightCheckTimer = null;
327
+ }
328
+
223
329
  // 清理RAF避免内存泄漏
224
330
  if (this._rafId) {
225
331
  cancelAnimationFrame(this._rafId);
226
332
  this._rafId = null;
227
333
  }
334
+
228
335
  // 清理消息监听
229
336
  if (this._onMessage) {
230
337
  window.removeEventListener("message", this._onMessage, false);
@@ -16,6 +16,7 @@
16
16
  left: 0,
17
17
  bottom: 0,
18
18
  right: 0,
19
+ zIndex: 1
19
20
  }
20
21
  "
21
22
  ></BaseSameLayer>
@@ -0,0 +1,240 @@
1
+ <template>
2
+ <BaseSameLayer
3
+ :hosSameLayerArgs="hosSameLayerArgs"
4
+ ref="sameLayer"
5
+ embedType="native/midea-ipc-ijkplayer-view"
6
+ :defaultWidth="'100%'"
7
+ :defaultHeight="'100%'"
8
+ :embedWidth="embedWidth"
9
+ :embedHeight="embedHeight"
10
+ :style="
11
+ embedPosition !== 'fixed'
12
+ ? { position: embedPosition }
13
+ : {
14
+ position: embedPosition,
15
+ top: 0,
16
+ left: 0,
17
+ bottom: 0,
18
+ right: 0,
19
+ zIndex: 1
20
+ }
21
+ "
22
+ ></BaseSameLayer>
23
+ </template>
24
+
25
+ <script>
26
+ import BaseSameLayer from './baseSameLayer.vue';
27
+
28
+ export default {
29
+ data() {
30
+ return {
31
+ width: 0,
32
+ height: 0,
33
+ embedWidth: '100%',
34
+ embedHeight: '100%',
35
+ embedPosition: 'static',
36
+ defaultWidth: '100%',
37
+ defaultHeight: '100%',
38
+ };
39
+ },
40
+ name: 'MideaIpcIjkplayerView',
41
+ components: {
42
+ BaseSameLayer,
43
+ },
44
+ props: {
45
+ hosUniqueProps: {
46
+ type: Object,
47
+ default() {
48
+ return {};
49
+ },
50
+ },
51
+ data: {
52
+ type: Object,
53
+ default() {
54
+ return {};
55
+ },
56
+ },
57
+ config: {
58
+ type: Object,
59
+ default() {
60
+ return {};
61
+ },
62
+ },
63
+ muted: {
64
+ type: Boolean,
65
+ default: false,
66
+ },
67
+ playStatus: {
68
+ type: String,
69
+ default: 'normal',
70
+ },
71
+ needDownload: {
72
+ type: Boolean,
73
+ default: false,
74
+ },
75
+ isSupportScale: {
76
+ type: Boolean,
77
+ default: false,
78
+ },
79
+ videoResize: {
80
+ type: Number,
81
+ default: 0,
82
+ },
83
+ autoplay: {
84
+ type: Boolean,
85
+ default: false,
86
+ },
87
+ videoCover: {
88
+ type: String,
89
+ default: '',
90
+ },
91
+ uiVisible: {
92
+ type: Object,
93
+ default() {
94
+ return {
95
+ voiceBtnVisible: true,
96
+ speedBtnVisible: true,
97
+ captureBtnVisible: true,
98
+ downloadBtnVisible: true,
99
+ batteryTimeLayoutVisible: false,
100
+ };
101
+ },
102
+ },
103
+ speedList: {
104
+ type: Array,
105
+ default() {
106
+ return ['0.5', '1', '1.5', '2'];
107
+ },
108
+ },
109
+ extraInfo: {
110
+ type: String,
111
+ default: '',
112
+ },
113
+ deleteBtnVisible: {
114
+ type: Number,
115
+ default: 0,
116
+ },
117
+ downloadDir: {
118
+ type: String,
119
+ default: '',
120
+ },
121
+ albumName: {
122
+ type: String,
123
+ default: '',
124
+ },
125
+ src: {
126
+ type: String,
127
+ default: '',
128
+ },
129
+ isShowTopRightViewOnPortrait: {
130
+ type: Boolean,
131
+ default: false,
132
+ },
133
+ },
134
+ computed: {
135
+ hosSameLayerArgs() {
136
+ return {
137
+ ...this.hosUniqueProps, // 鸿蒙原生组件独有属性
138
+ width: this.width,
139
+ height: this.height,
140
+ onFullscreenChange: this.onFullscreenChange,
141
+ // 视频播放器相关属性
142
+ config: this.config,
143
+ muted: this.muted,
144
+ playStatus: this.playStatus,
145
+ needDownload: this.needDownload,
146
+ isSupportScale: this.isSupportScale,
147
+ videoResize: this.videoResize,
148
+ autoplay: this.autoplay,
149
+ videoCover: this.videoCover,
150
+ uiVisible: this.uiVisible,
151
+ speedList: this.speedList,
152
+ extraInfo: this.extraInfo,
153
+ deleteBtnVisible: this.deleteBtnVisible,
154
+ downloadDir: this.downloadDir,
155
+ albumName: this.albumName,
156
+ data: this.data,
157
+ src: this.src,
158
+ isShowTopRightViewOnPortrait: this.isShowTopRightViewOnPortrait,
159
+
160
+ // 事件回调
161
+ onProgress: this.onProgress,
162
+ onStart: this.onStart,
163
+ onPause: this.onPause,
164
+ finish: this.finish,
165
+ onFail: this.onFail,
166
+ onReadyToPlay: this.onReadyToPlay,
167
+ deleteVideo: this.deleteVideo,
168
+ onDownloadSuccess: this.onDownloadSuccess,
169
+ onStartDownload: this.onStartDownload,
170
+ onPreviewImageClick: this.onPreviewImageClick,
171
+ };
172
+ },
173
+ },
174
+ mounted() {
175
+ this.width = this.$el.clientWidth;
176
+ this.height = this.$el.clientHeight;
177
+ this.windowWidth = window.innerWidth;
178
+ this.windowHeight = window.innerHeight;
179
+ this.$nextTick(() => {
180
+ this.defaultWidth = this.$refs.sameLayer.$el.clientWidth;
181
+ this.defaultHeight = this.$refs.sameLayer.$el.clientHeight;
182
+ this.defaultPosition =
183
+ this.$refs.sameLayer.$el.style.position || 'static';
184
+ });
185
+ },
186
+ methods: {
187
+ onFullscreenChange(isFullScreeen) {
188
+ if (isFullScreeen.flag) {
189
+ this.embedPosition = 'fixed';
190
+ this.embedHeight = this.windowWidth;
191
+ this.embedWidth = this.windowHeight;
192
+ } else {
193
+ this.embedPosition = this.defaultPosition;
194
+ this.embedHeight = this.defaultHeight;
195
+ this.embedWidth = this.defaultWidth;
196
+ }
197
+ },
198
+ // 自定义拓展其它逻辑
199
+ onProgress(res) {
200
+ this.$emit('onProgress', res);
201
+ },
202
+
203
+ onStart(res) {
204
+ this.$emit('onStart', res);
205
+ },
206
+
207
+ onPause(res) {
208
+ this.$emit('onPause', res);
209
+ },
210
+
211
+ finish(res) {
212
+ this.$emit('finish', res);
213
+ },
214
+
215
+ onFail(res) {
216
+ this.$emit('onFail', res);
217
+ },
218
+
219
+ onReadyToPlay(res) {
220
+ this.$emit('onReadyToPlay', res);
221
+ },
222
+
223
+ deleteVideo(res) {
224
+ this.$emit('deleteVideo', res);
225
+ },
226
+
227
+ onDownloadSuccess(res) {
228
+ this.$emit('onDownloadSuccess', res);
229
+ },
230
+
231
+ onStartDownload(res) {
232
+ this.$emit('onStartDownload', res);
233
+ },
234
+
235
+ onPreviewImageClick(res) {
236
+ this.$emit('onPreviewImageClick', res);
237
+ },
238
+ },
239
+ };
240
+ </script>
@@ -0,0 +1,195 @@
1
+ <template>
2
+ <BaseSameLayer
3
+ :hosSameLayerArgs="hosSameLayerArgs"
4
+ embedType="native/midea-ipc-live-view"
5
+ :defaultWidth="300"
6
+ :defaultHeight="300"
7
+ ></BaseSameLayer>
8
+ </template>
9
+
10
+ <script>
11
+ import BaseSameLayer from './baseSameLayer.vue';
12
+ const weexModule = weex.requireModule('weexModule');
13
+
14
+ export default {
15
+ data() {
16
+ return {
17
+ width: 0,
18
+ height: 0,
19
+ };
20
+ },
21
+ name: 'MideaIpcLiveView',
22
+ components: {
23
+ BaseSameLayer,
24
+ },
25
+ props: {
26
+ src: {
27
+ type: String,
28
+ default: '',
29
+ },
30
+ url: {
31
+ type: String,
32
+ default: '',
33
+ },
34
+ videoResize: {
35
+ // videoResize?: 0 | 1 | 2; // 0=Aspect,1=AspectFill,2=Resize(容器表现)
36
+ type: Number,
37
+ default: '',
38
+ },
39
+ autoplay: {
40
+ type: Boolean,
41
+ default: false,
42
+ },
43
+ videoCover: {
44
+ type: String,
45
+ default: '',
46
+ },
47
+ bottomShadow: {
48
+ type: Object,
49
+ default: () => {},
50
+ },
51
+ isSupportScale: {
52
+ type: Boolean,
53
+ default: false,
54
+ },
55
+ controls: {
56
+ type: Boolean,
57
+ default: false,
58
+ },
59
+ topShadow: {
60
+ type: Object,
61
+ default: () => {},
62
+ },
63
+ hosUniqueProps: {
64
+ type: Object,
65
+ default() {
66
+ return {};
67
+ },
68
+ },
69
+ data: {
70
+ type: Object,
71
+ default() {
72
+ return {};
73
+ },
74
+ },
75
+ },
76
+ computed: {
77
+ hosSameLayerArgs() {
78
+ return {
79
+ ...this.hosUniqueProps, // 鸿蒙原生组件独有属性
80
+ width: this.width,
81
+ height: this.height,
82
+ data: this.data,
83
+ src: this.src,
84
+ url: this.url,
85
+ videoResize: this.videoResize,
86
+ autoplay: this.autoplay,
87
+ videoCover: this.videoCover,
88
+ bottomShadow: this.bottomShadow,
89
+ isSupportScale: this.isSupportScale,
90
+ controls: this.controls,
91
+ topShadow: this.topShadow,
92
+ hosUniqueProps: this.hosUniqueProps,
93
+ onPlayerClick: this.onPlayerClick,
94
+ onMoveControl: this.onMoveControl,
95
+ onScaleControl: this.onScaleControl,
96
+ onMoveEnd: this.onMoveEnd,
97
+ onStatePrepared: this.onStatePrepared,
98
+ onAutoCompletion: this.onAutoCompletion,
99
+ onStateAutoComplete: this.onStateAutoComplete,
100
+ };
101
+ },
102
+ },
103
+ mounted() {
104
+ this.width = this.$el.clientWidth;
105
+ this.height = this.$el.clientHeight;
106
+ },
107
+ watch:{
108
+ url(newV){
109
+ console.log('cdj-------------url',newV)
110
+ }
111
+ },
112
+ methods: {
113
+ switchVideoQuality(params,callback) {
114
+ weexModule.callNative(
115
+ 'ipcLinkApi',
116
+ {
117
+ method: 'switchVideoQuality',
118
+ name: this.embedId,
119
+ params
120
+ },
121
+ callback
122
+ );
123
+ },
124
+ getVideoNetworkSpeed(params,callback) {
125
+ weexModule.callNative(
126
+ 'ipcLinkApi',
127
+ {
128
+ method: 'getVideoNetworkSpeed',
129
+ name: this.embedId,
130
+ params
131
+ },
132
+ callback
133
+ );
134
+ },
135
+ startRecord(params,callback) {
136
+ weexModule.callNative(
137
+ 'ipcLinkApi',
138
+ {
139
+ method: 'startRecord',
140
+ name: this.embedId,
141
+ params
142
+ },
143
+ callback
144
+ );
145
+ },
146
+ stopRecord(params,callback) {
147
+ weexModule.callNative(
148
+ 'ipcLinkApi',
149
+ {
150
+ method: 'stopRecord',
151
+ name: this.embedId,
152
+ params
153
+ },
154
+ callback
155
+ );
156
+ },
157
+ changeAudioStatus(params,callback){
158
+ weexModule.callNative(
159
+ 'ipcLinkApi',
160
+ {
161
+ method: 'changeAudioStatus',
162
+ name: this.embedId,
163
+ params
164
+ },
165
+ callback
166
+ );
167
+ },
168
+ // 自定义拓展其它逻辑
169
+ onPlayerClick(res) {
170
+ this.$emit('onPlayerClick', res);
171
+ },
172
+
173
+ onMoveControl(res) {
174
+ this.$emit('onMoveControl', res);
175
+ },
176
+
177
+ onScaleControl(res) {
178
+ this.$emit('onScaleControl', res);
179
+ },
180
+
181
+ onMoveEnd(res) {
182
+ this.$emit('onMoveEnd', res);
183
+ },
184
+ onStatePrepared() {
185
+ this.$emit('onStatePrepared');
186
+ },
187
+ onAutoCompletion() {
188
+ this.$emit('onAutoCompletion');
189
+ },
190
+ onStateAutoComplete() {
191
+ this.$emit('onStateAutoComplete');
192
+ },
193
+ },
194
+ };
195
+ </script>
package/src/index.js CHANGED
@@ -74,11 +74,21 @@ const componentMap = [
74
74
  componentAddress: 'midea-ijkplayer-view.vue',
75
75
  isInPlugin: false
76
76
  },
77
+ {
78
+ componentName: 'MideaIpcIjkplayerView',
79
+ componentAddress: 'midea-ipc-ijkplayer-view',
80
+ isInPlugin: false
81
+ },
77
82
  {
78
83
  componentName: 'MideaIotlinkvideoView',
79
84
  componentAddress: 'midea-iotlinkvideo-view.vue',
80
85
  isInPlugin: false
81
86
  },
87
+ {
88
+ componentName: 'MideaIpcLiveView',
89
+ componentAddress: 'midea-ipc-live-view.vue',
90
+ isInPlugin: false
91
+ },
82
92
  {
83
93
  componentName: 'MideaSeekBar',
84
94
  componentAddress: 'midea-seek-bar-base.vue',