@dolphinweex/weex-harmony 0.1.58 → 0.1.60

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.60",
4
4
  "description": "weex harmony adapter",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -1,22 +1,49 @@
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 && pluginType != 'old-h5'"
8
+ :src="url"
9
+ :style="{ backgroundColor: backgroundColor, height: height }"
10
+ ref="iframe"
11
+ @load="onPageFinish"
12
+ ></iframe>
13
+
14
+ <BaseSameLayer
15
+ class="common-view-iframe"
16
+ v-if="pluginType == 'old-h5'"
17
+ :hosSameLayerArgs="hosSameLayerArgs"
18
+ embedType="native/midea-common-weex-view"
19
+ :defaultWidth="300"
20
+ :defaultHeight="300"
21
+ ></BaseSameLayer>
5
22
  <!-- <image v-if="progressText.length > 0" /> -->
6
23
  </div>
7
24
  </template>
8
25
 
9
26
  <script>
10
- const weexModule = weex.requireModule('weexModule')
27
+ import BaseSameLayer from "./baseSameLayer.vue";
28
+
29
+ const weexModule = weex.requireModule("weexModule");
11
30
 
12
31
  export default {
13
32
  data() {
14
33
  return {
15
34
  url: "",
35
+ pluginType: "weex",
16
36
  backgroundColor: "transparent",
17
- progressText: ""
37
+ progressText: "",
38
+ embedId: `embedId_iframe_${
39
+ Date.now().toString(36) + Math.random().toString(36).substring(2)
40
+ }`,
41
+ height: "100%",
18
42
  };
19
43
  },
44
+ components: {
45
+ BaseSameLayer,
46
+ },
20
47
  name: "MideaCommonWeexView",
21
48
  props: {
22
49
  hosUniqueProps: {
@@ -38,11 +65,6 @@ export default {
38
65
  type: Object,
39
66
  },
40
67
  },
41
- // watch:{
42
- // backgroundColor(oldColor, newColor){
43
- // this.$refs["iframe"].contentWindow.document.style.backgroundColor = newColor
44
- // }
45
- // },
46
68
  created() {
47
69
  weexModule.callNative(
48
70
  `webview.webHandle`,
@@ -54,35 +76,83 @@ export default {
54
76
  pluginData: this.pluginData,
55
77
  },
56
78
  (args) => {
57
- if (args.progressText){
79
+ if (args.progressText) {
58
80
  this.progressText = args.progressText;
59
- } else if (args.url) {
60
- this.url = args.url;
81
+ } else if (args.url) {
82
+ this.url = args.url;
61
83
  this.backgroundColor = args.pageBackgroundColor;
84
+ this.pluginType = args.pluginType
62
85
  }
63
86
  }
64
87
  );
65
88
  },
89
+ computed: {
90
+ hosSameLayerArgs() {
91
+ return {
92
+ ...this.hosUniqueProps, // 鸿蒙原生组件独有属性
93
+ width: this.$el.clientWidth,
94
+ height: this.$el.clientHeight,
95
+ data: {
96
+ router: this.router,
97
+ src: this.url,
98
+ backgroundColor: this.backgroundColor,
99
+ pluginData: this.pluginData,
100
+ }
101
+ };
102
+ },
103
+ },
66
104
  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
- });
105
+ // this.$refs["iframe"].addEventListener('load', this.onPageFinish);
106
+ const iframeEl = this.$refs.iframe;
107
+ if (iframeEl) iframeEl.addEventListener("load", this.onPageFinish);
108
+ // 从父组件根节点内查找:既是 .midea-common-weex-view,又包含当前 iframe 的 embedId
109
+ const findWrapperFromParent = () => {
110
+ const parentEl = this.$parent && this.$parent.$el;
111
+ if (!parentEl) return null;
112
+
113
+ const candidates = parentEl.querySelectorAll(".midea-common-weex-view");
114
+ // 用 CSS.escape 规避特殊字符(低端内核可用兜底)
115
+ const idSelector =
116
+ window.CSS && CSS.escape
117
+ ? `#${CSS.escape(this.embedId)}`
118
+ : `[id="${this.embedId}"]`;
119
+
120
+ for (const el of candidates) {
121
+ if (el.querySelector(idSelector)) return el;
122
+ }
123
+ return null;
124
+ };
125
+ this._wrapperEl = findWrapperFromParent(); // 保存容器引用
126
+ this._onMessage = (event) => {
127
+ const h = Number(event.data.height) || 0;
128
+ if (!h) {
129
+ return;
130
+ }
131
+ if (this._wrapperEl) {
132
+ this._wrapperEl.style.height = `${h}px`;
133
+ }
134
+ this.height = `${h / weex.config.env.scale}px`;
135
+ };
136
+ window.addEventListener("message", this._onMessage, false);
71
137
  },
72
- methods: {
138
+ methods: {
73
139
  onPageFinish() {
74
140
  if (this.$refs["iframe"]) {
75
- this.$refs["iframe"].contentWindow.$midea_harmony_native = window.$midea_harmony_native;
141
+ this.$refs["iframe"].contentWindow.$midea_harmony_native =
142
+ window.$midea_harmony_native;
76
143
  this.$refs["iframe"].contentWindow.isIframe = true;
77
- this.$refs["iframe"].contentWindow.postMessage(JSON.stringify(window.$midea_harmony_native), '*');
144
+ this.$refs["iframe"].contentWindow.postMessage(
145
+ JSON.stringify(window.$midea_harmony_native),
146
+ "*"
147
+ );
78
148
  }
79
149
  },
80
- }
150
+ },
81
151
  };
82
152
  </script>
83
153
 
84
154
  <style scoped>
85
- .common-view-iframe{
86
- height: 100%
155
+ .common-view-iframe {
156
+ height: 100%;
87
157
  }
88
- </style>
158
+ </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',