@dolphinweex/weex-harmony 0.1.58 → 0.1.59

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.58",
3
+ "version": "0.1.59",
4
4
  "description": "weex harmony adapter",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -1,20 +1,32 @@
1
1
  <template>
2
2
  <div>
3
3
  <!-- <text v-if="progressText.length > 0">{{progressText}}</text> -->
4
- <iframe class="common-view-iframe" v-if="url.length > 0" :src="url" :style="{backgroundColor: backgroundColor}" ref="iframe" @load="onPageFinish"></iframe>
4
+ <iframe
5
+ class="common-view-iframe"
6
+ :id="embedId"
7
+ v-if="url.length > 0"
8
+ :src="url"
9
+ :style="{ backgroundColor: backgroundColor, height: height }"
10
+ ref="iframe"
11
+ @load="onPageFinish"
12
+ ></iframe>
5
13
  <!-- <image v-if="progressText.length > 0" /> -->
6
14
  </div>
7
15
  </template>
8
16
 
9
17
  <script>
10
- const weexModule = weex.requireModule('weexModule')
18
+ const weexModule = weex.requireModule("weexModule");
11
19
 
12
20
  export default {
13
21
  data() {
14
22
  return {
15
23
  url: "",
16
24
  backgroundColor: "transparent",
17
- progressText: ""
25
+ progressText: "",
26
+ embedId: `embedId_iframe_${
27
+ Date.now().toString(36) + Math.random().toString(36).substring(2)
28
+ }`,
29
+ height: "100%",
18
30
  };
19
31
  },
20
32
  name: "MideaCommonWeexView",
@@ -54,9 +66,9 @@ export default {
54
66
  pluginData: this.pluginData,
55
67
  },
56
68
  (args) => {
57
- if (args.progressText){
69
+ if (args.progressText) {
58
70
  this.progressText = args.progressText;
59
- } else if (args.url) {
71
+ } else if (args.url) {
60
72
  this.url = args.url;
61
73
  this.backgroundColor = args.pageBackgroundColor;
62
74
  }
@@ -64,25 +76,57 @@ export default {
64
76
  );
65
77
  },
66
78
  mounted() {
67
- this.$refs["iframe"].addEventListener('load', this.onPageFinish);
68
- window.addEventListener('message', function (event) {
69
- document.getElementsByTagName('iframe')[0].height = event.data.height
70
- });
79
+ // this.$refs["iframe"].addEventListener('load', this.onPageFinish);
80
+ const iframeEl = this.$refs.iframe;
81
+ if (iframeEl) iframeEl.addEventListener("load", this.onPageFinish);
82
+ // 从父组件根节点内查找:既是 .midea-common-weex-view,又包含当前 iframe 的 embedId
83
+ const findWrapperFromParent = () => {
84
+ const parentEl = this.$parent && this.$parent.$el;
85
+ if (!parentEl) return null;
86
+
87
+ const candidates = parentEl.querySelectorAll(".midea-common-weex-view");
88
+ // 用 CSS.escape 规避特殊字符(低端内核可用兜底)
89
+ const idSelector =
90
+ window.CSS && CSS.escape
91
+ ? `#${CSS.escape(this.embedId)}`
92
+ : `[id="${this.embedId}"]`;
93
+
94
+ for (const el of candidates) {
95
+ if (el.querySelector(idSelector)) return el;
96
+ }
97
+ return null;
98
+ };
99
+ this._wrapperEl = findWrapperFromParent(); // 保存容器引用
100
+ this._onMessage = (event) => {
101
+ const h = Number(event.data.height) || 0;
102
+ if (!h) {
103
+ return;
104
+ }
105
+ if (this._wrapperEl) {
106
+ this._wrapperEl.style.height = `${h}px`;
107
+ }
108
+ this.height = `${h / weex.config.env.scale}px`;
109
+ };
110
+ window.addEventListener("message", this._onMessage, false);
71
111
  },
72
- methods: {
112
+ methods: {
73
113
  onPageFinish() {
74
114
  if (this.$refs["iframe"]) {
75
- this.$refs["iframe"].contentWindow.$midea_harmony_native = window.$midea_harmony_native;
115
+ this.$refs["iframe"].contentWindow.$midea_harmony_native =
116
+ window.$midea_harmony_native;
76
117
  this.$refs["iframe"].contentWindow.isIframe = true;
77
- this.$refs["iframe"].contentWindow.postMessage(JSON.stringify(window.$midea_harmony_native), '*');
118
+ this.$refs["iframe"].contentWindow.postMessage(
119
+ JSON.stringify(window.$midea_harmony_native),
120
+ "*"
121
+ );
78
122
  }
79
123
  },
80
- }
124
+ },
81
125
  };
82
126
  </script>
83
127
 
84
128
  <style scoped>
85
- .common-view-iframe{
86
- height: 100%
129
+ .common-view-iframe {
130
+ height: 100%;
87
131
  }
88
- </style>
132
+ </style>
@@ -0,0 +1,195 @@
1
+ <template>
2
+ <BaseSameLayer
3
+ :hosSameLayerArgs="hosSameLayerArgs"
4
+ embedType="native/midea-iotlinkvideo-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: 'MideaIotlinkvideoView',
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
+ 'iotLinkApi',
116
+ {
117
+ method: 'switchVideoQuality',
118
+ name: this.embedId,
119
+ params
120
+ },
121
+ callback
122
+ );
123
+ },
124
+ getVideoNetworkSpeed(params,callback) {
125
+ weexModule.callNative(
126
+ 'iotLinkApi',
127
+ {
128
+ method: 'getVideoNetworkSpeed',
129
+ name: this.embedId,
130
+ params
131
+ },
132
+ callback
133
+ );
134
+ },
135
+ startRecord(params,callback) {
136
+ weexModule.callNative(
137
+ 'iotLinkApi',
138
+ {
139
+ method: 'startRecord',
140
+ name: this.embedId,
141
+ params
142
+ },
143
+ callback
144
+ );
145
+ },
146
+ stopRecord(params,callback) {
147
+ weexModule.callNative(
148
+ 'iotLinkApi',
149
+ {
150
+ method: 'stopRecord',
151
+ name: this.embedId,
152
+ params
153
+ },
154
+ callback
155
+ );
156
+ },
157
+ changeAudioStatus(params,callback){
158
+ weexModule.callNative(
159
+ 'iotLinkApi',
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,6 +74,11 @@ const componentMap = [
74
74
  componentAddress: 'midea-ijkplayer-view.vue',
75
75
  isInPlugin: false
76
76
  },
77
+ {
78
+ componentName: 'MideaIotlinkvideoView',
79
+ componentAddress: 'midea-iotlinkvideo-view.vue',
80
+ isInPlugin: false
81
+ },
77
82
  {
78
83
  componentName: 'MideaSeekBar',
79
84
  componentAddress: 'midea-seek-bar-base.vue',