@dolphinweex/weex-harmony 0.1.8 → 0.1.10

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.8",
3
+ "version": "0.1.10",
4
4
  "description": "weex harmony adapter",
5
5
  "main": "index.js",
6
6
  "files": [
package/src/.DS_Store ADDED
Binary file
Binary file
@@ -0,0 +1,72 @@
1
+ <template>
2
+ <BaseSameLayer
3
+ :hosSameLayerArgs="hosSameLayerArgs"
4
+ embedType="native/midea-audio-wave-view"
5
+ :defaultWidth="300"
6
+ :defaultHeight="300"
7
+ ref="audioWaveRef"
8
+ ></BaseSameLayer>
9
+ </template>
10
+
11
+ <script>
12
+ import BaseSameLayer from "./baseSameLayer.vue";
13
+ const weexModule = weex.requireModule('weexModule');
14
+
15
+ export default {
16
+ name: "mideaAudioWaveView",
17
+ data() {
18
+ return {
19
+ width: 0,
20
+ height: 0
21
+ }
22
+ },
23
+ components: {
24
+ BaseSameLayer,
25
+ },
26
+ props: {
27
+ hosUniqueProps: {
28
+ type: Object,
29
+ default() {
30
+ return {};
31
+ },
32
+ },
33
+ data: {
34
+ type: Object,
35
+ default() {
36
+ return {
37
+ embedId:''
38
+ };
39
+ },
40
+ },
41
+ },
42
+ computed: {
43
+ hosSameLayerArgs() {
44
+ return {
45
+ ...this.hosUniqueProps, // 鸿蒙原生组件独有属性
46
+ width: this.width,
47
+ height: this.height,
48
+ data: this.data,
49
+ updateVolume: this.updateVolume,
50
+ };
51
+ },
52
+ },
53
+ mounted() {
54
+ this.width = this.$el.clientWidth;
55
+ this.height = this.$el.clientHeight;
56
+ this.embedId = this.$refs.audioWaveRef.embedId;
57
+ },
58
+
59
+ methods: {
60
+ updateVolume(volume) {
61
+ weexModule.callNative(
62
+ 'audioWaveHandle',
63
+ {
64
+ method: 'updateVolume',
65
+ name: this.embedId,
66
+ volume
67
+ },
68
+ );
69
+ },
70
+ },
71
+ };
72
+ </script>
@@ -0,0 +1,53 @@
1
+ <template>
2
+ <BaseSameLayer
3
+ :hosSameLayerArgs="hosSameLayerArgs"
4
+ embedType="native/midea-villa-card-view"
5
+ :defaultWidth="100"
6
+ :defaultHeight="100"
7
+ ></BaseSameLayer>
8
+ </template>
9
+
10
+ <script>
11
+ import BaseSameLayer from './baseSameLayer.vue';
12
+
13
+ export default {
14
+ data() {
15
+ return {
16
+ width: 0,
17
+ height: 0,
18
+ };
19
+ },
20
+ name: 'MideaVillaCardView',
21
+ components: {
22
+ BaseSameLayer,
23
+ },
24
+ props: {
25
+ hosUniqueProps: {
26
+ type: Object,
27
+ default() {
28
+ return {};
29
+ },
30
+ },
31
+ data: {
32
+ type: Object,
33
+ default() {
34
+ return {};
35
+ },
36
+ },
37
+ },
38
+ computed: {
39
+ hosSameLayerArgs() {
40
+ return {
41
+ ...this.hosUniqueProps, // 鸿蒙原生组件独有属性
42
+ width: this.width,
43
+ height: this.height,
44
+ data: this.data,
45
+ };
46
+ },
47
+ },
48
+ mounted() {
49
+ this.width = this.$el.clientWidth;
50
+ this.height = this.$el.clientHeight;
51
+ },
52
+ };
53
+ </script>
@@ -0,0 +1,56 @@
1
+ <template>
2
+ <BaseSameLayer
3
+ :hosSameLayerArgs="hosSameLayerArgs"
4
+ embedType="native/midea-wave-progress-view"
5
+ :defaultWidth="300"
6
+ :defaultHeight="300"
7
+ ></BaseSameLayer>
8
+ </template>
9
+
10
+ <script>
11
+ import BaseSameLayer from "./baseSameLayer.vue";
12
+
13
+ export default {
14
+ name: "MideaWaveProgressView",
15
+ data() {
16
+ return {
17
+ width: 0,
18
+ height: 0
19
+ }
20
+ },
21
+ components: {
22
+ BaseSameLayer,
23
+ },
24
+ props: {
25
+ hosUniqueProps: {
26
+ type: Object,
27
+ default() {
28
+ return {};
29
+ },
30
+ },
31
+ data: {
32
+ type: Object,
33
+ default() {
34
+ return {};
35
+ },
36
+ },
37
+ },
38
+ computed: {
39
+ hosSameLayerArgs() {
40
+ return {
41
+ ...this.hosUniqueProps, // 鸿蒙原生组件独有属性
42
+ width: this.width,
43
+ height: this.height,
44
+ data: this.data,
45
+ };
46
+ },
47
+ },
48
+ mounted() {
49
+ this.width = this.$el.clientWidth;
50
+ this.height = this.$el.clientHeight;
51
+ },
52
+
53
+ methods: {
54
+ },
55
+ };
56
+ </script>
package/src/index.js CHANGED
@@ -174,7 +174,23 @@ const componentMap = [
174
174
  componentName: 'DragVerticalListView',
175
175
  componentAddress: 'drag-vertical-list-view.vue',
176
176
  isInPlugin: false
177
- }
177
+ },
178
+ {
179
+ componentName: 'mideaWaveProgressView',
180
+ componentAddress: 'midea-wave-progress-view.vue',
181
+ isInPlugin: false
182
+ },
183
+ {
184
+ componentName: 'mideaAudioWaveView',
185
+ componentAddress: 'midea-audio-wave-view.vue',
186
+ isInPlugin: false
187
+ },
188
+ {
189
+ componentName: 'MideaVillaCardView',
190
+ componentAddress: 'midea-villa-card-view.vue',
191
+ isInPlugin: false
192
+ },
193
+
178
194
  ]
179
195
 
180
196
  module.exports = componentMap
@@ -67,53 +67,60 @@ function hasTargetElement(tagName) {
67
67
  * 遍历html节点,将需要引入的组件添加到componentSet中
68
68
  * @param {*} node html节点
69
69
  */
70
- function traverseNode(node) {
70
+ function traverseNode(node, parent = null) {
71
71
  if (node.type === 'element') {
72
- const {hasElement, componentName} = hasTargetElement(node.tagName)
72
+ const { hasElement, componentName } = hasTargetElement(node.tagName);
73
73
  if (hasElement) {
74
- componentSet.add(componentName)
74
+ componentSet.add(componentName);
75
75
  }
76
- if (node.attributes) {
77
- node.attributes.forEach((attr, index) => {
78
- if (attr.key === 'v-bind') {
79
- //对象的话
80
- if (attr.value.trim().startsWith('{') && attr.value.trim().endsWith('}')) {
81
- const parsedAst = parser.parseExpression(attr.value);
82
- const styleProperty = parsedAst.properties.find(prop => prop.key && prop.key.name === 'style');
83
- if (styleProperty) {
84
- const styleValue = styleProperty.value;
85
76
 
86
- // style 的值套上 _px2rem 方法
87
- styleProperty.value = {
88
- type: 'CallExpression',
89
- callee: {
90
- type: 'Identifier',
91
- name: '_px2rem'
92
- },
93
- arguments: [styleValue] // 将原始的 style 对象作为参数传递给 _px2rem
77
+ // 判断父节点是否有 v-for,若父节点是 <template> 且有 v-for,则跳过
78
+ const isInsideVFor = parent && parent.attributes && parent.attributes.some(attr => attr.key === 'v-for');
79
+
80
+ if (!isInsideVFor) { // 如果不在 v-for 中,才处理 v-bind
81
+ if (node.attributes) {
82
+ node.attributes.forEach((attr, index) => {
83
+ if (attr.key === 'v-bind') {
84
+ // 如果是对象绑定,处理 style 属性
85
+ if (attr.value.trim().startsWith('{') && attr.value.trim().endsWith('}')) {
86
+ const parsedAst = parser.parseExpression(attr.value);
87
+ const styleProperty = parsedAst.properties.find(prop => prop.key && prop.key.name === 'style');
88
+ if (styleProperty) {
89
+ const styleValue = styleProperty.value;
90
+
91
+ // style 的值套上 _px2rem 方法
92
+ styleProperty.value = {
93
+ type: 'CallExpression',
94
+ callee: {
95
+ type: 'Identifier',
96
+ name: '_px2rem'
97
+ },
98
+ arguments: [styleValue] // 将原始的 style 对象作为参数传递给 _px2rem
99
+ };
100
+ }
101
+ node.attributes[index] = {
102
+ key: 'v-bind',
103
+ value: generator(parsedAst).code
94
104
  };
105
+ } else {
106
+ const customComputedName = `customVBindComputed${index}`; // 自定义的名字
107
+ vBindMap.set(customComputedName, {
108
+ computedName: attr.value,
109
+ customComputedName
110
+ });
111
+ // 更新属性值为自定义名字
112
+ node.attributes[index].value = customComputedName;
95
113
  }
96
- node.attributes[index] = {
97
- key: 'v-bind',
98
- value: generator(parsedAst).code
99
- };
100
- } else {
101
- const customComputedName = `customVBindComputed${index}`; // 自定义的名字
102
- vBindMap.set(customComputedName, {
103
- computedName: attr.value,
104
- customComputedName
105
- });
106
-
107
- // 更新属性值为自定义名字
108
- node.attributes[index].value = customComputedName;
109
114
  }
110
- }
111
- });
115
+ });
116
+ }
112
117
  }
118
+
119
+ // 继续递归处理子节点
113
120
  if (node.children) {
114
121
  node.children.forEach((child) => {
115
- traverseNode(child)
116
- })
122
+ traverseNode(child, node); // 将当前节点作为 parent 传递给子节点
123
+ });
117
124
  }
118
125
  }
119
126
  }