@dolphinweex/weex-harmony 0.1.16 → 0.1.18

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.18",
4
4
  "description": "weex harmony adapter",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -64,12 +64,10 @@ export default {
64
64
  return filtered;
65
65
  },
66
66
  embedWidth() {
67
- this.$forceUpdate()
68
67
  // 如果hosSameLayerArgs.width存在且定义了,则使用该值,否则使用defaultWidth
69
68
  return this.hosSameLayerArgs.width || this.defaultWidth;
70
69
  },
71
70
  embedHeight() {
72
- this.$forceUpdate()
73
71
  // 如果hosSameLayerArgs.height存在且定义了,则使用该值,否则使用defaultHeight
74
72
  return this.hosSameLayerArgs.height || this.defaultHeight;
75
73
  },
@@ -147,9 +145,11 @@ export default {
147
145
  deep: true,
148
146
  handler: function (newVal, oldVal) {
149
147
  console.log("[sameLayerRendering] web component update.");
150
- weexModule.callNative("transferSameLayerArgs", {
151
- componentId: this.embedId,
152
- ...newVal,
148
+ this.$nextTick(() => {
149
+ weexModule.callNative("transferSameLayerArgs", {
150
+ componentId: this.embedId,
151
+ ...newVal,
152
+ });
153
153
  });
154
154
  },
155
155
  },
@@ -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
 
@@ -1,6 +1,5 @@
1
1
  <template>
2
- <BaseSameLayer :hosSameLayerArgs="hosSameLayerArgs" embedType="native/midea-scene-card-drag-list-view" :defaultWidth="300"
3
- :defaultHeight="300" ref="sceneCardRed"></BaseSameLayer>
2
+ <BaseSameLayer :hosSameLayerArgs="hosSameLayerArgs" embedType="native/midea-scene-card-drag-list-view" ref="sceneCardRed"></BaseSameLayer>
4
3
  </template>
5
4
 
6
5
  <script>