@dolphinweex/weex-harmony 0.1.16 → 0.1.17

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.16",
3
+ "version": "0.1.17",
4
4
  "description": "weex harmony adapter",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -1,14 +1,17 @@
1
1
  <template>
2
- <BaseSameLayer
2
+ <!-- <BaseSameLayer
3
3
  :hosSameLayerArgs="hosSameLayerArgs"
4
4
  embedType="native/web"
5
5
  :defaultWidth="300"
6
6
  :defaultHeight="120"
7
- ></BaseSameLayer>
7
+ ></BaseSameLayer> -->
8
+ <iframe :src="src" ref="iframe"></iframe>
9
+
8
10
  </template>
9
11
 
10
12
  <script>
11
13
  import BaseSameLayer from "./baseSameLayer.vue";
14
+ let count = 0
12
15
 
13
16
  export default {
14
17
  name: "HlWeb",
@@ -18,9 +21,6 @@ export default {
18
21
  height: 0
19
22
  }
20
23
  },
21
- components: {
22
- BaseSameLayer,
23
- },
24
24
  props: {
25
25
  hosUniqueProps: {
26
26
  type: Object,
@@ -40,7 +40,7 @@ export default {
40
40
 
41
41
  computed: {
42
42
  hosSameLayerArgs() {
43
- return {
43
+ return {
44
44
  ...this.hosUniqueProps, // 鸿蒙原生组件独有属性
45
45
  src: this.src,
46
46
  width: this.width,
@@ -56,8 +56,24 @@ export default {
56
56
  mounted() {
57
57
  this.width = this.$el.clientWidth;
58
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);
59
72
  },
60
- methods: {
73
+ methods: {
74
+ postMessage(message){
75
+ this.$refs["iframe"].contentWindow.postMessage(message, this.src)
76
+ },
61
77
  // 自定义拓展其它逻辑
62
78
  onPageFinish(res) {
63
79
  console.log("[web] pagefinish ", res);
@@ -77,7 +93,7 @@ export default {
77
93
  },
78
94
  onMessage(res){
79
95
  console.log("[web] onMessage ", res);
80
- this.$emit("message", res);
96
+ this.$emit("message", res);
81
97
  }
82
98
  },
83
99
  watch: {
@@ -5,6 +5,8 @@
5
5
  embedType="native/midea-apng-view"
6
6
  :defaultWidth="750"
7
7
  :defaultHeight="300"
8
+ v-on="$listeners"
9
+ :listenEvents="['click']"
8
10
  ></BaseSameLayer>
9
11
  </template>
10
12