@dolphinweex/weex-harmony 0.1.48 → 0.1.50
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
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!-- <BaseSameLayer
|
|
3
|
+
:hosSameLayerArgs="hosSameLayerArgs"
|
|
4
|
+
embedType="native/web"
|
|
5
|
+
:defaultWidth="300"
|
|
6
|
+
:defaultHeight="120"
|
|
7
|
+
></BaseSameLayer> -->
|
|
8
|
+
<iframe :src="src" ref="iframe"></iframe>
|
|
9
|
+
|
|
10
|
+
</template>
|
|
11
|
+
|
|
12
|
+
<script>
|
|
13
|
+
import BaseSameLayer from "./baseSameLayer.vue";
|
|
14
|
+
let count = 0
|
|
15
|
+
|
|
16
|
+
export default {
|
|
17
|
+
name: "HlWeb",
|
|
18
|
+
data() {
|
|
19
|
+
return {
|
|
20
|
+
width: 0,
|
|
21
|
+
height: 0
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
props: {
|
|
25
|
+
hosUniqueProps: {
|
|
26
|
+
type: Object,
|
|
27
|
+
default() {
|
|
28
|
+
return {};
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
src: {
|
|
32
|
+
type: String,
|
|
33
|
+
required: true,
|
|
34
|
+
},
|
|
35
|
+
harmonyStyle: {
|
|
36
|
+
type: Object,
|
|
37
|
+
required: false,
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
computed: {
|
|
42
|
+
hosSameLayerArgs() {
|
|
43
|
+
return {
|
|
44
|
+
...this.hosUniqueProps, // 鸿蒙原生组件独有属性
|
|
45
|
+
src: this.src,
|
|
46
|
+
width: this.width,
|
|
47
|
+
height: (this.harmonyStyle && this.harmonyStyle.height) ? this.harmonyStyle.height : this.height,
|
|
48
|
+
pagefinish: this.onPageFinish,
|
|
49
|
+
pagestart: this.onPageStart,
|
|
50
|
+
error: this.onError,
|
|
51
|
+
receivedtitle: this.onReceivedTitle,
|
|
52
|
+
message: this.onMessage,
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
mounted() {
|
|
57
|
+
this.width = this.$el.clientWidth;
|
|
58
|
+
this.height = this.$el.clientHeight;
|
|
59
|
+
|
|
60
|
+
this.onPageStart();
|
|
61
|
+
var that = this
|
|
62
|
+
window.addEventListener('message', function (event) {
|
|
63
|
+
// 可以添加来源检查以确保消息来自预期的源
|
|
64
|
+
if (event.origin === window.origin && that.onMessage) {
|
|
65
|
+
that.onMessage(event.data)
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
this.$refs["iframe"].addEventListener('load', this.onPageFinish);
|
|
70
|
+
|
|
71
|
+
this.$refs["error"].addEventListener('load', this.onError);
|
|
72
|
+
},
|
|
73
|
+
methods: {
|
|
74
|
+
postMessage(message){
|
|
75
|
+
const iframe = this.$refs["iframe"]
|
|
76
|
+
const target = new URL(iframe.src).origin
|
|
77
|
+
iframe.contentWindow.postMessage(message, target)
|
|
78
|
+
//this.$refs["iframe"].contentWindow.postMessage(message, this.src)
|
|
79
|
+
},
|
|
80
|
+
// 自定义拓展其它逻辑
|
|
81
|
+
onPageFinish(res) {
|
|
82
|
+
console.log("[web] pagefinish ", res);
|
|
83
|
+
this.$refs["iframe"].contentWindow.$midea_harmony_native = window.$midea_harmony_native
|
|
84
|
+
this.$refs["iframe"].contentWindow.postMessage(JSON.stringify(window.$midea_harmony_native), '*');
|
|
85
|
+
this.$emit("pagefinish", res);
|
|
86
|
+
},
|
|
87
|
+
onPageStart(res) {
|
|
88
|
+
console.log("[web] pagestart ", res);
|
|
89
|
+
this.$emit("pagestart", res);
|
|
90
|
+
},
|
|
91
|
+
onError(res) {
|
|
92
|
+
console.log("[web] onError ", res);
|
|
93
|
+
this.$emit("error", res);
|
|
94
|
+
},
|
|
95
|
+
onReceivedTitle(res) {
|
|
96
|
+
console.log("[web] onReceivedTitle ", res);
|
|
97
|
+
this.$emit("receivedtitle", res);
|
|
98
|
+
},
|
|
99
|
+
onMessage(res){
|
|
100
|
+
console.log("[web] onMessage ", res);
|
|
101
|
+
this.$emit("message", res);
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
watch: {
|
|
105
|
+
loading(newText, oldText) {
|
|
106
|
+
if (newText !== oldText) {
|
|
107
|
+
this.scheduleTransfer(); // 当loading属性变化时重新调用
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
</script>
|
|
113
|
+
|
|
114
|
+
<style scoped>
|
|
115
|
+
</style>
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
2
|
+
<BaseSameLayer
|
|
3
3
|
:hosSameLayerArgs="hosSameLayerArgs"
|
|
4
4
|
embedType="native/web"
|
|
5
5
|
:defaultWidth="300"
|
|
6
6
|
:defaultHeight="120"
|
|
7
|
-
></BaseSameLayer>
|
|
8
|
-
<iframe :src="src" ref="iframe"></iframe>
|
|
7
|
+
></BaseSameLayer>
|
|
9
8
|
|
|
10
9
|
</template>
|
|
11
10
|
|
|
@@ -21,6 +20,10 @@ data() {
|
|
|
21
20
|
height: 0
|
|
22
21
|
}
|
|
23
22
|
},
|
|
23
|
+
components: {
|
|
24
|
+
BaseSameLayer,
|
|
25
|
+
},
|
|
26
|
+
|
|
24
27
|
props: {
|
|
25
28
|
hosUniqueProps: {
|
|
26
29
|
type: Object,
|
|
@@ -39,6 +39,22 @@ export default {
|
|
|
39
39
|
type: String,
|
|
40
40
|
default: "",
|
|
41
41
|
},
|
|
42
|
+
dataUrl: {
|
|
43
|
+
type: String,
|
|
44
|
+
default: "",
|
|
45
|
+
},
|
|
46
|
+
repeatCount: {
|
|
47
|
+
type: Number,
|
|
48
|
+
default: 0,
|
|
49
|
+
},
|
|
50
|
+
progress: {
|
|
51
|
+
type: Number,
|
|
52
|
+
default: 0,
|
|
53
|
+
},
|
|
54
|
+
autoPlay: {
|
|
55
|
+
type: Boolean,
|
|
56
|
+
default: true,
|
|
57
|
+
},
|
|
42
58
|
},
|
|
43
59
|
computed: {
|
|
44
60
|
hosSameLayerArgs() {
|
|
@@ -48,6 +64,10 @@ export default {
|
|
|
48
64
|
height: this.height,
|
|
49
65
|
loop: this.loop,
|
|
50
66
|
data: this.data,
|
|
67
|
+
dataUrl: this.dataUrl,
|
|
68
|
+
repeatCount: this.repeatCount,
|
|
69
|
+
progress: this.progress,
|
|
70
|
+
autoPlay: this.autoPlay,
|
|
51
71
|
};
|
|
52
72
|
},
|
|
53
73
|
},
|