@dolphinweex/weex-harmony 0.1.57 → 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,15 +1,32 @@
|
|
1
1
|
<template>
|
2
|
-
<
|
2
|
+
<div>
|
3
|
+
<!-- <text v-if="progressText.length > 0">{{progressText}}</text> -->
|
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>
|
13
|
+
<!-- <image v-if="progressText.length > 0" /> -->
|
14
|
+
</div>
|
3
15
|
</template>
|
4
16
|
|
5
17
|
<script>
|
6
|
-
const weexModule = weex.requireModule(
|
18
|
+
const weexModule = weex.requireModule("weexModule");
|
7
19
|
|
8
20
|
export default {
|
9
21
|
data() {
|
10
22
|
return {
|
11
23
|
url: "",
|
12
24
|
backgroundColor: "transparent",
|
25
|
+
progressText: "",
|
26
|
+
embedId: `embedId_iframe_${
|
27
|
+
Date.now().toString(36) + Math.random().toString(36).substring(2)
|
28
|
+
}`,
|
29
|
+
height: "100%",
|
13
30
|
};
|
14
31
|
},
|
15
32
|
name: "MideaCommonWeexView",
|
@@ -33,6 +50,11 @@ export default {
|
|
33
50
|
type: Object,
|
34
51
|
},
|
35
52
|
},
|
53
|
+
// watch:{
|
54
|
+
// backgroundColor(oldColor, newColor){
|
55
|
+
// this.$refs["iframe"].contentWindow.document.style.backgroundColor = newColor
|
56
|
+
// }
|
57
|
+
// },
|
36
58
|
created() {
|
37
59
|
weexModule.callNative(
|
38
60
|
`webview.webHandle`,
|
@@ -44,25 +66,67 @@ export default {
|
|
44
66
|
pluginData: this.pluginData,
|
45
67
|
},
|
46
68
|
(args) => {
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
69
|
+
if (args.progressText) {
|
70
|
+
this.progressText = args.progressText;
|
71
|
+
} else if (args.url) {
|
72
|
+
this.url = args.url;
|
73
|
+
this.backgroundColor = args.pageBackgroundColor;
|
74
|
+
}
|
51
75
|
}
|
52
76
|
);
|
53
77
|
},
|
54
78
|
mounted() {
|
55
|
-
this.$refs["iframe"].addEventListener('load', this.onPageFinish);
|
56
|
-
|
57
|
-
|
58
|
-
|
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);
|
59
111
|
},
|
60
|
-
methods: {
|
112
|
+
methods: {
|
61
113
|
onPageFinish() {
|
62
|
-
this.$refs["iframe"]
|
63
|
-
|
64
|
-
|
114
|
+
if (this.$refs["iframe"]) {
|
115
|
+
this.$refs["iframe"].contentWindow.$midea_harmony_native =
|
116
|
+
window.$midea_harmony_native;
|
117
|
+
this.$refs["iframe"].contentWindow.isIframe = true;
|
118
|
+
this.$refs["iframe"].contentWindow.postMessage(
|
119
|
+
JSON.stringify(window.$midea_harmony_native),
|
120
|
+
"*"
|
121
|
+
);
|
122
|
+
}
|
65
123
|
},
|
66
|
-
}
|
124
|
+
},
|
67
125
|
};
|
68
126
|
</script>
|
127
|
+
|
128
|
+
<style scoped>
|
129
|
+
.common-view-iframe {
|
130
|
+
height: 100%;
|
131
|
+
}
|
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',
|