@dolphinweex/weex-harmony 0.1.82 → 0.1.84
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
|
@@ -40,6 +40,7 @@ export default {
|
|
|
40
40
|
embedId: `embedId_iframe_${
|
|
41
41
|
Date.now().toString(36) + Math.random().toString(36).substring(2)
|
|
42
42
|
}`,
|
|
43
|
+
isPluginMenu: window.location.href.includes('plugin-menu'),
|
|
43
44
|
height: window.location.href.includes('plugin-menu') ? '0px' : '100%',
|
|
44
45
|
_resizeObserver: null,
|
|
45
46
|
_heightCheckTimer: null,
|
|
@@ -177,9 +178,9 @@ export default {
|
|
|
177
178
|
JSON.stringify(window.$midea_harmony_native),
|
|
178
179
|
"*"
|
|
179
180
|
);
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
181
|
+
setTimeout(()=>{
|
|
182
|
+
this.startWeexRootHeightMonitoring();
|
|
183
|
+
})
|
|
183
184
|
}
|
|
184
185
|
},
|
|
185
186
|
|
|
@@ -209,7 +210,7 @@ export default {
|
|
|
209
210
|
// 如果方法1计算出的高度为0或太小,则累加所有子元素的高度
|
|
210
211
|
if (totalHeight <= 0) {
|
|
211
212
|
children.forEach((child) => {
|
|
212
|
-
const childHeight = child.offsetHeight || child.clientHeight ||
|
|
213
|
+
const childHeight = child.offsetHeight || child.clientHeight || 0;
|
|
213
214
|
totalHeight += childHeight;
|
|
214
215
|
});
|
|
215
216
|
}
|
|
@@ -221,7 +222,7 @@ export default {
|
|
|
221
222
|
startWeexRootHeightMonitoring() {
|
|
222
223
|
// 尝试多次查找元素(因为 iframe 内容可能还在加载)
|
|
223
224
|
let attempts = 0;
|
|
224
|
-
const maxAttempts =
|
|
225
|
+
const maxAttempts = 10; // 最多尝试 20 次
|
|
225
226
|
|
|
226
227
|
this._heightCheckTimer = setInterval(() => {
|
|
227
228
|
attempts++;
|
|
@@ -240,7 +241,6 @@ export default {
|
|
|
240
241
|
let targetElement = null;
|
|
241
242
|
let elementDesc = '';
|
|
242
243
|
let useChildrenTotalHeight = false; // 标记是否使用子元素总高度
|
|
243
|
-
|
|
244
244
|
// 查找 .weex-root
|
|
245
245
|
const weexRoot = iframeDocument.querySelector('.weex-root');
|
|
246
246
|
const weexRootFirstChild = (weexRoot && weexRoot.children.length > 0) ? weexRoot.children[0] : null;
|
|
@@ -339,7 +339,7 @@ export default {
|
|
|
339
339
|
|
|
340
340
|
// 如果子元素总高度为0或未使用,则使用元素本身的高度
|
|
341
341
|
if (elementHeight <= 0) {
|
|
342
|
-
elementHeight = element.offsetHeight || element.clientHeight
|
|
342
|
+
elementHeight = element.offsetHeight || element.clientHeight;
|
|
343
343
|
}
|
|
344
344
|
|
|
345
345
|
if (elementHeight > 0) {
|
|
@@ -364,7 +364,7 @@ export default {
|
|
|
364
364
|
maxHeight = Math.max(maxHeight, 0);
|
|
365
365
|
|
|
366
366
|
// 如果计算出的高度超过了最大限制,则使用最大限制
|
|
367
|
-
const finalHeight = elementHeight > maxHeight ? maxHeight : elementHeight
|
|
367
|
+
const finalHeight = !this.isPluginMenu ? elementHeight > maxHeight ? maxHeight : elementHeight : elementHeight
|
|
368
368
|
|
|
369
369
|
// 更新包装器高度
|
|
370
370
|
if (this._wrapperEl) {
|
|
@@ -184,6 +184,11 @@ export default {
|
|
|
184
184
|
});
|
|
185
185
|
},
|
|
186
186
|
methods: {
|
|
187
|
+
finishFullScreen(){
|
|
188
|
+
this.embedPosition = this.defaultPosition;
|
|
189
|
+
this.embedHeight = this.defaultHeight;
|
|
190
|
+
this.embedWidth = this.defaultWidth;
|
|
191
|
+
},
|
|
187
192
|
onFullscreenChange(isFullScreeen) {
|
|
188
193
|
if (isFullScreeen.flag) {
|
|
189
194
|
this.embedPosition = 'fixed';
|
|
@@ -236,5 +241,10 @@ export default {
|
|
|
236
241
|
this.$emit('onPreviewImageClick', res);
|
|
237
242
|
},
|
|
238
243
|
},
|
|
244
|
+
destroy(){
|
|
245
|
+
this.embedPosition = this.defaultPosition;
|
|
246
|
+
this.embedHeight = this.defaultHeight;
|
|
247
|
+
this.embedWidth = this.defaultWidth;
|
|
248
|
+
}
|
|
239
249
|
};
|
|
240
250
|
</script>
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
embedType="native/midea-progresscycle-view"
|
|
5
5
|
:defaultWidth="300"
|
|
6
6
|
:defaultHeight="300"
|
|
7
|
+
:key="dataVersion"
|
|
7
8
|
></BaseSameLayer>
|
|
8
9
|
</template>
|
|
9
10
|
|
|
@@ -15,7 +16,8 @@ export default {
|
|
|
15
16
|
data() {
|
|
16
17
|
return {
|
|
17
18
|
width: 0,
|
|
18
|
-
height: 0
|
|
19
|
+
height: 0,
|
|
20
|
+
dataVersion: 0
|
|
19
21
|
}
|
|
20
22
|
},
|
|
21
23
|
components: {
|
|
@@ -37,13 +39,28 @@ export default {
|
|
|
37
39
|
},
|
|
38
40
|
computed: {
|
|
39
41
|
hosSameLayerArgs() {
|
|
40
|
-
|
|
42
|
+
const result = {
|
|
41
43
|
...this.hosUniqueProps, // 鸿蒙原生组件独有属性
|
|
42
44
|
width: this.width,
|
|
43
45
|
height: this.height,
|
|
44
|
-
data: this.data,
|
|
46
|
+
data: this.data,
|
|
45
47
|
handleProgresscycleTap: this.handleProgresscycleTap,
|
|
46
48
|
};
|
|
49
|
+
return result;
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
watch: {
|
|
53
|
+
// 深度监听 data 对象的变化
|
|
54
|
+
data: {
|
|
55
|
+
handler(newVal, oldVal) {
|
|
56
|
+
const newStr = JSON.stringify(newVal);
|
|
57
|
+
const oldStr = JSON.stringify(oldVal);
|
|
58
|
+
if (newStr !== oldStr) {
|
|
59
|
+
this.dataVersion++;
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
deep: true,
|
|
63
|
+
immediate: false
|
|
47
64
|
},
|
|
48
65
|
},
|
|
49
66
|
mounted() {
|
package/src/transform-loader.js
CHANGED
|
@@ -285,33 +285,38 @@ function createVBindMethod(methodName, paramName) {
|
|
|
285
285
|
t.returnStatement(t.objectExpression([]))
|
|
286
286
|
])
|
|
287
287
|
),
|
|
288
|
+
// 先创建一个新对象(深拷贝),避免修改原始响应式数据
|
|
289
|
+
t.variableDeclaration('const', [
|
|
290
|
+
t.variableDeclarator(
|
|
291
|
+
t.identifier('newObj'),
|
|
292
|
+
t.callExpression(
|
|
293
|
+
t.memberExpression(t.identifier('Object'), t.identifier('assign')),
|
|
294
|
+
[t.objectExpression([]), t.identifier(paramName)]
|
|
295
|
+
)
|
|
296
|
+
)
|
|
297
|
+
]),
|
|
298
|
+
// 如果新对象有 style 属性,则对其进行 px → rem 转换
|
|
288
299
|
t.ifStatement(
|
|
289
300
|
t.logicalExpression(
|
|
290
301
|
'&&',
|
|
291
|
-
t.identifier(
|
|
292
|
-
t.memberExpression(t.identifier(
|
|
302
|
+
t.identifier('newObj'),
|
|
303
|
+
t.memberExpression(t.identifier('newObj'), t.identifier('style'))
|
|
293
304
|
),
|
|
294
|
-
// 1) 如果入参存在且包含 style,先做 px → rem 转换
|
|
295
305
|
t.blockStatement([
|
|
296
306
|
t.expressionStatement(
|
|
297
307
|
t.assignmentExpression(
|
|
298
308
|
'=',
|
|
299
|
-
t.memberExpression(t.identifier(
|
|
309
|
+
t.memberExpression(t.identifier('newObj'), t.identifier('style')),
|
|
300
310
|
t.callExpression(
|
|
301
311
|
t.memberExpression(t.thisExpression(), t.identifier('_px2rem')),
|
|
302
|
-
[t.memberExpression(t.identifier(
|
|
312
|
+
[t.memberExpression(t.identifier('newObj'), t.identifier('style'))]
|
|
303
313
|
)
|
|
304
314
|
)
|
|
305
315
|
)
|
|
306
316
|
])
|
|
307
317
|
),
|
|
308
|
-
//
|
|
309
|
-
t.returnStatement(
|
|
310
|
-
t.callExpression(
|
|
311
|
-
t.memberExpression(t.identifier('Object'), t.identifier('assign')),
|
|
312
|
-
[t.objectExpression([]), t.identifier(paramName)]
|
|
313
|
-
)
|
|
314
|
-
)
|
|
318
|
+
// 返回处理后的新对象
|
|
319
|
+
t.returnStatement(t.identifier('newObj'))
|
|
315
320
|
])
|
|
316
321
|
)
|
|
317
322
|
}
|