@dolphinweex/weex-harmony 0.1.32 → 0.1.34
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,11 +1,11 @@
|
|
1
1
|
<template>
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
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
9
|
|
10
10
|
</template>
|
11
11
|
|
@@ -14,100 +14,100 @@ import BaseSameLayer from "./baseSameLayer.vue";
|
|
14
14
|
let count = 0
|
15
15
|
|
16
16
|
export default {
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
},
|
30
|
-
},
|
31
|
-
src: {
|
32
|
-
type: String,
|
33
|
-
required: true,
|
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 {};
|
34
29
|
},
|
35
|
-
harmonyStyle: {
|
36
|
-
type: Object,
|
37
|
-
required: false,
|
38
|
-
}
|
39
30
|
},
|
31
|
+
src: {
|
32
|
+
type: String,
|
33
|
+
required: true,
|
34
|
+
},
|
35
|
+
harmonyStyle: {
|
36
|
+
type: Object,
|
37
|
+
required: false,
|
38
|
+
}
|
39
|
+
},
|
40
40
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
}
|
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,
|
54
53
|
}
|
55
|
-
}
|
56
|
-
|
57
|
-
|
58
|
-
|
54
|
+
}
|
55
|
+
},
|
56
|
+
mounted() {
|
57
|
+
this.width = this.$el.clientWidth;
|
58
|
+
this.height = this.$el.clientHeight;
|
59
59
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
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
68
|
|
69
|
-
|
69
|
+
this.$refs["iframe"].addEventListener('load', this.onPageFinish);
|
70
70
|
|
71
|
-
|
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)
|
72
79
|
},
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
iframe.contentWindow.postMessage(
|
78
|
-
|
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
|
-
},
|
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);
|
103
86
|
},
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
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
|
+
}
|
110
109
|
},
|
110
|
+
},
|
111
111
|
};
|
112
112
|
</script>
|
113
113
|
|
@@ -122,9 +122,7 @@
|
|
122
122
|
<div class="flexBox">
|
123
123
|
<img
|
124
124
|
:src="data.list[draggingIndex].iconImage.url"
|
125
|
-
:style="
|
126
|
-
applyNormalAttribute(data.list[draggingIndex].iconImage)
|
127
|
-
"
|
125
|
+
:style="applyNormalAttribute(data.list[draggingIndex].iconImage)"
|
128
126
|
/>
|
129
127
|
<div @click.stop.prevent>
|
130
128
|
<img
|
@@ -134,9 +132,7 @@
|
|
134
132
|
? data.list[draggingIndex].selectIcon.selectedUrl
|
135
133
|
: data.list[draggingIndex].selectIcon.url
|
136
134
|
"
|
137
|
-
:style="
|
138
|
-
applyNormalAttribute(data.list[draggingIndex].selectIcon)
|
139
|
-
"
|
135
|
+
:style="applyNormalAttribute(data.list[draggingIndex].selectIcon)"
|
140
136
|
/>
|
141
137
|
</div>
|
142
138
|
</div>
|
@@ -152,7 +148,6 @@
|
|
152
148
|
</template>
|
153
149
|
|
154
150
|
<script>
|
155
|
-
import { weex_harmony_rebindGestureDelayed } from '@dolphinweex/harmony-webpack-adapter/registerGesture.js'; // 请替换为实际的loader文件路径
|
156
151
|
import lottie from 'lottie-web';
|
157
152
|
const scla = 2;
|
158
153
|
export default {
|
@@ -177,7 +172,6 @@ export default {
|
|
177
172
|
selected: null,
|
178
173
|
longPressTimer: null,
|
179
174
|
longPressDuration: 350,
|
180
|
-
longPressStartIndex: null,
|
181
175
|
draggingIndex: null,
|
182
176
|
hoverIndex: null,
|
183
177
|
isTouchDragging: false,
|
@@ -199,10 +193,6 @@ export default {
|
|
199
193
|
fixedItemHeight: 0,
|
200
194
|
animationFrameId: null,
|
201
195
|
isProcessingData: false,
|
202
|
-
// 手势事件配置 - 根据实际使用的手势事件来配置
|
203
|
-
gestureEventMap: [],
|
204
|
-
// 元素ID - 用于标识需要绑定手势的元素
|
205
|
-
elementId: 'grid-item'
|
206
196
|
};
|
207
197
|
},
|
208
198
|
computed: {
|
@@ -210,7 +200,9 @@ export default {
|
|
210
200
|
return {
|
211
201
|
'--grid-cols': this.data.spanCount || this.cols,
|
212
202
|
'--grid-gap': `${this.data.spaceSize || 8}px`,
|
213
|
-
'--grid-margin': `${
|
203
|
+
'--grid-margin': `${
|
204
|
+
this.data.layoutConfig.marginStart + this.data.layoutConfig.marginEnd
|
205
|
+
}px`,
|
214
206
|
marginTop: this.data.layoutConfig.marginTop * scla,
|
215
207
|
marginBottom: this.data.layoutConfig.marginBottom * scla,
|
216
208
|
marginLeft: this.data.layoutConfig.marginStart * scla,
|
@@ -222,7 +214,6 @@ export default {
|
|
222
214
|
if (this.draggingIndex === null) {
|
223
215
|
return { display: 'none' };
|
224
216
|
}
|
225
|
-
|
226
217
|
const item = this.data.list[this.draggingIndex];
|
227
218
|
let itemView = {};
|
228
219
|
if (item) {
|
@@ -248,108 +239,49 @@ export default {
|
|
248
239
|
updateListItem(data) {
|
249
240
|
console.log('updateListItem收到数据:', JSON.stringify(data));
|
250
241
|
const id = data.itemView.id;
|
251
|
-
const index = this.data.list.findIndex(
|
252
|
-
(item) => item.itemView.id == id
|
253
|
-
);
|
242
|
+
const index = this.data.list.findIndex((item) => item.itemView.id == id);
|
254
243
|
|
255
244
|
if (index === -1) {
|
256
245
|
return;
|
257
246
|
}
|
258
247
|
|
259
|
-
// 检查是否有动画URL的变化
|
260
|
-
const oldBgAnimUrl = this.data.list[index].bgAnimView.animUrl || '';
|
261
|
-
const oldLoadingAnimUrl = this.data.list[index].loadingAnimView.animUrl || '';
|
262
|
-
const oldFrontAnimUrl = this.data.list[index].frontAnimView.animUrl || '';
|
263
|
-
const newBgAnimUrl = data.bgAnimView.animUrl || '';
|
264
|
-
const newLoadingAnimUrl = data.loadingAnimView.animUrl || '';
|
265
|
-
const newFrontAnimUrl = data.frontAnimView.animUrl || '';
|
266
|
-
|
267
248
|
// 合并全局数据到新数据
|
268
249
|
const mergedData = this.mergeItemData(data);
|
269
|
-
|
270
|
-
// 更新数据
|
271
|
-
this.$set(this.data.list, index, mergedData);
|
272
250
|
|
251
|
+
this.$set(this.data.list, index, mergedData);
|
273
252
|
this.$nextTick(() => {
|
274
253
|
const itemId = String(data.itemView.id);
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
254
|
+
if (mergedData.bgAnimView.animUrl) {
|
255
|
+
this.createLottieAnimation(
|
256
|
+
'bg',
|
257
|
+
itemId,
|
258
|
+
mergedData.bgAnimView,
|
259
|
+
mergedData
|
260
|
+
);
|
279
261
|
}
|
280
262
|
|
281
|
-
|
282
|
-
|
283
|
-
|
263
|
+
if (mergedData.loadingAnimView.animUrl) {
|
264
|
+
this.createLottieAnimation(
|
265
|
+
'loading',
|
266
|
+
itemId,
|
267
|
+
mergedData.loadingAnimView,
|
268
|
+
mergedData
|
269
|
+
);
|
284
270
|
}
|
285
271
|
|
286
|
-
|
287
|
-
|
288
|
-
|
272
|
+
if (mergedData.frontAnimView.animUrl) {
|
273
|
+
this.createLottieAnimation(
|
274
|
+
'front',
|
275
|
+
itemId,
|
276
|
+
mergedData.frontAnimView,
|
277
|
+
mergedData
|
278
|
+
);
|
289
279
|
}
|
290
|
-
// 重新绑定手势事件 - 解决DOM更新后手势失效问题
|
291
|
-
this.rebindGestureEvents();
|
292
280
|
});
|
293
281
|
},
|
294
|
-
// 重新绑定手势事件的方法
|
295
|
-
rebindGestureEvents() {
|
296
|
-
try {
|
297
|
-
// 延迟执行确保DOM完全更新
|
298
|
-
weex_harmony_rebindGestureDelayed(
|
299
|
-
this.$el, // 组件根元素
|
300
|
-
this.gestureEventMap, // 手势事件配置数组
|
301
|
-
this.elementId, // 元素类名ID
|
302
|
-
100 // 延迟100ms
|
303
|
-
);
|
304
|
-
console.log('手势事件重新绑定完成');
|
305
|
-
} catch (error) {
|
306
|
-
console.error('重新绑定手势事件失败:', error);
|
307
|
-
}
|
308
|
-
},
|
309
|
-
// 初始化手势事件配置
|
310
|
-
initGestureConfig() {
|
311
|
-
// 根据你实际使用的手势事件来配置
|
312
|
-
this.gestureEventMap = [
|
313
|
-
{
|
314
|
-
name: "@touchstart",
|
315
|
-
handler: this.startLongPress,
|
316
|
-
params: ['event', 'index'],
|
317
|
-
isEvent: true,
|
318
|
-
modifier: []
|
319
|
-
},
|
320
|
-
{
|
321
|
-
name: "@touchmove",
|
322
|
-
handler: this.checkLongPressMove,
|
323
|
-
params: [],
|
324
|
-
isEvent: true,
|
325
|
-
modifier: []
|
326
|
-
},
|
327
|
-
{
|
328
|
-
name: "@touchend",
|
329
|
-
handler: this.endTouch,
|
330
|
-
params: [],
|
331
|
-
isEvent: true,
|
332
|
-
modifier: []
|
333
|
-
},
|
334
|
-
{
|
335
|
-
name: "@touchcancel",
|
336
|
-
handler: this.endTouch,
|
337
|
-
params: [],
|
338
|
-
isEvent: true,
|
339
|
-
modifier: []
|
340
|
-
}
|
341
|
-
];
|
342
|
-
},
|
343
|
-
// 简化的动画创建方法
|
344
282
|
createLottieAnimation(type, itemId, animView, itemData) {
|
345
283
|
const animKey = `${type}-${itemId}`;
|
346
284
|
const refName = `${type}Anim-${itemId}`;
|
347
|
-
|
348
|
-
// 销毁旧动画
|
349
|
-
if (this.lottieAnimations[animKey]) {
|
350
|
-
this.lottieAnimations[animKey].destroy();
|
351
|
-
delete this.lottieAnimations[animKey];
|
352
|
-
}
|
353
285
|
|
354
286
|
// 检查DOM元素是否存在
|
355
287
|
const animEl = this.$refs[refName];
|
@@ -358,10 +290,43 @@ export default {
|
|
358
290
|
}
|
359
291
|
|
360
292
|
// 检查可见性
|
361
|
-
if (
|
293
|
+
if (
|
294
|
+
typeof animView.visibility === 'number' &&
|
295
|
+
animView.visibility === 0
|
296
|
+
) {
|
362
297
|
return;
|
363
298
|
}
|
364
299
|
|
300
|
+
// 如果是bg或front动画,需要检查并清理另一个
|
301
|
+
if (type === 'bg' || type === 'front') {
|
302
|
+
const otherType = type === 'bg' ? 'front' : 'bg';
|
303
|
+
const otherAnimKey = `${otherType}-${itemId}`;
|
304
|
+
|
305
|
+
// 如果另一个动画正在运行,先销毁它
|
306
|
+
if (this.lottieAnimations[otherAnimKey]) {
|
307
|
+
this.lottieAnimations[otherAnimKey].destroy();
|
308
|
+
delete this.lottieAnimations[otherAnimKey];
|
309
|
+
|
310
|
+
// 清空对应的animUrl数据
|
311
|
+
const index = this.data.list.findIndex(
|
312
|
+
(i) => i.itemView.id == itemId
|
313
|
+
);
|
314
|
+
if (index !== -1) {
|
315
|
+
this.$set(
|
316
|
+
this.data.list[index][`${otherType}AnimView`],
|
317
|
+
'animUrl',
|
318
|
+
''
|
319
|
+
);
|
320
|
+
}
|
321
|
+
}
|
322
|
+
}
|
323
|
+
|
324
|
+
// 销毁当前类型的旧动画
|
325
|
+
if (this.lottieAnimations[animKey]) {
|
326
|
+
this.lottieAnimations[animKey].destroy();
|
327
|
+
delete this.lottieAnimations[animKey];
|
328
|
+
}
|
329
|
+
|
365
330
|
try {
|
366
331
|
const anim = lottie.loadAnimation({
|
367
332
|
container: animEl[0],
|
@@ -384,11 +349,17 @@ export default {
|
|
384
349
|
if (this.lottieAnimations[animKey] === anim) {
|
385
350
|
anim.destroy();
|
386
351
|
delete this.lottieAnimations[animKey];
|
387
|
-
|
352
|
+
|
388
353
|
// 清空对应的animUrl数据
|
389
|
-
const index = this.data.list.findIndex(
|
354
|
+
const index = this.data.list.findIndex(
|
355
|
+
(i) => i.itemView.id == itemId
|
356
|
+
);
|
390
357
|
if (index !== -1) {
|
391
|
-
this.$set(
|
358
|
+
this.$set(
|
359
|
+
this.data.list[index][`${type}AnimView`],
|
360
|
+
'animUrl',
|
361
|
+
''
|
362
|
+
);
|
392
363
|
}
|
393
364
|
}
|
394
365
|
});
|
@@ -422,11 +393,11 @@ export default {
|
|
422
393
|
return selectedIds;
|
423
394
|
},
|
424
395
|
selectIconClick(e, item, index) {
|
425
|
-
e.preventDefault();
|
426
|
-
e.stopPropagation();
|
427
396
|
if (item.selectIcon.visibility) {
|
428
397
|
item.itemView.isSelected = !item.itemView.isSelected;
|
429
398
|
}
|
399
|
+
e.preventDefault();
|
400
|
+
e.stopPropagation();
|
430
401
|
const target = {
|
431
402
|
...item.itemView,
|
432
403
|
id: String(item.itemView.id),
|
@@ -439,19 +410,16 @@ export default {
|
|
439
410
|
},
|
440
411
|
|
441
412
|
itemViewClick(e, item, index) {
|
442
|
-
if (e.defaultPrevented) {
|
443
|
-
return;
|
444
|
-
}
|
445
|
-
|
446
413
|
console.log('itemViewClick');
|
447
|
-
// 确保取消任何长按计时器
|
448
|
-
this.cancelLongPress();
|
449
414
|
if (this.data.isEditing) {
|
450
415
|
if (item.selectIcon.visibility) {
|
451
416
|
item.itemView.isSelected = !item.itemView.isSelected;
|
452
417
|
}
|
453
|
-
return;
|
454
418
|
}
|
419
|
+
|
420
|
+
// 确保取消任何长按计时器
|
421
|
+
this.cancelLongPress();
|
422
|
+
|
455
423
|
e.preventDefault();
|
456
424
|
e.stopPropagation();
|
457
425
|
const target = {
|
@@ -461,6 +429,7 @@ export default {
|
|
461
429
|
...e,
|
462
430
|
};
|
463
431
|
this.$emit('onClickItem', target);
|
432
|
+
this.$emit('onSelectItems', target);
|
464
433
|
},
|
465
434
|
|
466
435
|
actionClick(e, item, index) {
|
@@ -571,7 +540,7 @@ export default {
|
|
571
540
|
'bgAnimView',
|
572
541
|
'frontAnimView',
|
573
542
|
];
|
574
|
-
|
543
|
+
|
575
544
|
types.forEach((type) => {
|
576
545
|
// 使用mergeDate合并全局数据和项目数据
|
577
546
|
processedItem[type] = this.mergeDate(item[type] || {}, type);
|
@@ -648,7 +617,6 @@ export default {
|
|
648
617
|
return;
|
649
618
|
}
|
650
619
|
this.$emit('onDragEventStart', e);
|
651
|
-
|
652
620
|
// 只在编辑模式下阻止事件冒泡和默认行为
|
653
621
|
this.cancelLongPress();
|
654
622
|
// 记录起始触摸位置和索引
|
@@ -656,7 +624,6 @@ export default {
|
|
656
624
|
this.touchStartX = touch.pageX;
|
657
625
|
this.touchStartY = touch.pageY;
|
658
626
|
console.log('开始长按ddddddddd', touch, touch.pageY, touch.pageX);
|
659
|
-
this.longPressStartIndex = index;
|
660
627
|
this.isScrolling = false; // 重置滚动状态
|
661
628
|
|
662
629
|
// 设置新的长按计时器
|
@@ -670,7 +637,7 @@ export default {
|
|
670
637
|
|
671
638
|
// 检查长按过程中的移动
|
672
639
|
checkLongPressMove(e) {
|
673
|
-
if(this.data.isEditing){
|
640
|
+
if (this.data.isEditing) {
|
674
641
|
e.oriEvent.stopImmediatePropagation();
|
675
642
|
}
|
676
643
|
if (!this.data.isEditable) {
|
@@ -682,7 +649,7 @@ export default {
|
|
682
649
|
const moveY = Math.abs(touch.pageY - this.touchStartY);
|
683
650
|
|
684
651
|
// 如果水平移动大于垂直移动,则阻止事件传播
|
685
|
-
if (moveX > moveY
|
652
|
+
if (moveX > moveY && !this.isTouchDragging && this.data.isEditing) {
|
686
653
|
if (e.oriEvent) {
|
687
654
|
e.oriEvent.preventDefault();
|
688
655
|
e.oriEvent.stopPropagation();
|
@@ -717,38 +684,37 @@ export default {
|
|
717
684
|
console.log('长按触发,进入编辑模式');
|
718
685
|
// 进入编辑模式
|
719
686
|
|
720
|
-
if(this.data.isEditing){
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
});
|
687
|
+
if (this.data.isEditing) {
|
688
|
+
// 设置当前拖拽索引
|
689
|
+
this.draggingIndex = index;
|
690
|
+
this.isTouchDragging = true;
|
691
|
+
|
692
|
+
// 使用存储的固定宽高
|
693
|
+
this.draggedItemRect = {
|
694
|
+
width: this.fixedItemWidth,
|
695
|
+
height: this.fixedItemHeight,
|
696
|
+
};
|
697
|
+
|
698
|
+
// 获取当前元素位置用于计算偏移
|
699
|
+
const element = document.querySelectorAll('.grid-item')[index];
|
700
|
+
if (element) {
|
701
|
+
const rect = element.getBoundingClientRect();
|
702
|
+
// 计算触摸点相对于元素左上角的偏移
|
703
|
+
this.touchOffsetX = this.touchStartX - rect.left;
|
704
|
+
this.touchOffsetY = this.touchStartY - rect.top;
|
705
|
+
|
706
|
+
// 设置克隆元素的初始位置
|
707
|
+
this.dragCloneX = rect.left;
|
708
|
+
this.dragCloneY = rect.top;
|
709
|
+
this.isDragClone = true;
|
710
|
+
|
711
|
+
requestAnimationFrame(() => {
|
712
|
+
this.dragCloneX = this.touchStartX - this.touchOffsetX;
|
713
|
+
this.dragCloneY = this.touchStartY - this.touchOffsetY;
|
714
|
+
});
|
749
715
|
|
750
|
-
|
751
|
-
|
716
|
+
console.log('拖拽克隆已创建');
|
717
|
+
}
|
752
718
|
}
|
753
719
|
this.data.isEditing = true;
|
754
720
|
this.$emit('onEditStateChanged', true);
|
@@ -761,7 +727,6 @@ export default {
|
|
761
727
|
clearTimeout(this.longPressTimer);
|
762
728
|
this.longPressTimer = null;
|
763
729
|
}
|
764
|
-
this.longPressStartIndex = null;
|
765
730
|
},
|
766
731
|
|
767
732
|
// 触摸移动处理
|
@@ -808,7 +773,7 @@ export default {
|
|
808
773
|
if (itemIndex === this.draggingIndex) continue;
|
809
774
|
|
810
775
|
const rect = item.getBoundingClientRect();
|
811
|
-
|
776
|
+
|
812
777
|
// 触摸点是否在元素的中心区域内
|
813
778
|
const centerX = (rect.left + rect.right) / 2;
|
814
779
|
const centerY = (rect.top + rect.bottom) / 2;
|
@@ -832,10 +797,7 @@ export default {
|
|
832
797
|
|
833
798
|
// 执行交换
|
834
799
|
if (targetIndex !== null && targetIndex !== this.draggingIndex) {
|
835
|
-
[
|
836
|
-
this.data.list[this.draggingIndex],
|
837
|
-
this.data.list[targetIndex],
|
838
|
-
] = [
|
800
|
+
[this.data.list[this.draggingIndex], this.data.list[targetIndex]] = [
|
839
801
|
this.data.list[targetIndex],
|
840
802
|
this.data.list[this.draggingIndex],
|
841
803
|
];
|
@@ -944,10 +906,7 @@ export default {
|
|
944
906
|
// 重置动画实例对象
|
945
907
|
this.lottieAnimations = {};
|
946
908
|
|
947
|
-
console.log(
|
948
|
-
'开始初始化Lottie动画,列表项数量:',
|
949
|
-
this.data.list.length
|
950
|
-
);
|
909
|
+
console.log('开始初始化Lottie动画,列表项数量:', this.data.list.length);
|
951
910
|
|
952
911
|
// 延迟一点时间确保DOM完全更新并且之前的动画已被销毁
|
953
912
|
setTimeout(() => {
|
@@ -958,10 +917,20 @@ export default {
|
|
958
917
|
this.createLottieAnimation('bg', itemId, item.bgAnimView, item);
|
959
918
|
|
960
919
|
// 加载加载中动画
|
961
|
-
this.createLottieAnimation(
|
920
|
+
this.createLottieAnimation(
|
921
|
+
'loading',
|
922
|
+
itemId,
|
923
|
+
item.loadingAnimView,
|
924
|
+
item
|
925
|
+
);
|
962
926
|
|
963
927
|
// 加载前景动画
|
964
|
-
this.createLottieAnimation(
|
928
|
+
this.createLottieAnimation(
|
929
|
+
'front',
|
930
|
+
itemId,
|
931
|
+
item.frontAnimView,
|
932
|
+
item
|
933
|
+
);
|
965
934
|
});
|
966
935
|
}, 50); // 小延迟确保DOM已更新和旧动画已销毁
|
967
936
|
});
|
@@ -988,13 +957,14 @@ export default {
|
|
988
957
|
},
|
989
958
|
},
|
990
959
|
watch: {
|
991
|
-
'data.isEditing':{
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
}
|
997
|
-
|
960
|
+
'data.isEditing': {
|
961
|
+
handler(newVal) {
|
962
|
+
this.generateDataList();
|
963
|
+
this.$nextTick(() => {
|
964
|
+
this.initLottieAnimations();
|
965
|
+
});
|
966
|
+
},
|
967
|
+
deep: true,
|
998
968
|
},
|
999
969
|
// 监听列表数据变化,自动更新处理后的数据
|
1000
970
|
'data.list': {
|
@@ -1003,20 +973,19 @@ export default {
|
|
1003
973
|
if (this.isProcessingData) {
|
1004
974
|
return;
|
1005
975
|
}
|
1006
|
-
|
1007
|
-
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1011
|
-
|
1012
|
-
}
|
976
|
+
if (newList.length !== oldList.length) {
|
977
|
+
console.log('检测到data.list变化');
|
978
|
+
this.generateDataList();
|
979
|
+
this.$nextTick(() => {
|
980
|
+
this.initLottieAnimations();
|
981
|
+
});
|
982
|
+
}
|
1013
983
|
},
|
1014
984
|
deep: true,
|
1015
985
|
},
|
1016
986
|
},
|
1017
987
|
|
1018
988
|
mounted() {
|
1019
|
-
this.initGestureConfig()
|
1020
989
|
console.log(this.data, 'djdjdjdjdjdjdj');
|
1021
990
|
// 初始获取grid-box宽度
|
1022
991
|
this.updateGridBoxWidth();
|
@@ -1045,10 +1014,12 @@ export default {
|
|
1045
1014
|
button {
|
1046
1015
|
border: none;
|
1047
1016
|
}
|
1017
|
+
|
1048
1018
|
.disabled-item {
|
1049
1019
|
opacity: 0.6;
|
1050
1020
|
pointer-events: none;
|
1051
1021
|
}
|
1022
|
+
|
1052
1023
|
.outer-container {
|
1053
1024
|
width: 100%;
|
1054
1025
|
position: relative;
|
@@ -1083,6 +1054,7 @@ button {
|
|
1083
1054
|
will-change: transform, opacity, box-shadow;
|
1084
1055
|
overflow: hidden;
|
1085
1056
|
}
|
1057
|
+
|
1086
1058
|
.grid-box {
|
1087
1059
|
position: relative;
|
1088
1060
|
display: flex;
|
@@ -1093,16 +1065,19 @@ button {
|
|
1093
1065
|
overflow: hidden;
|
1094
1066
|
height: auto;
|
1095
1067
|
}
|
1068
|
+
|
1096
1069
|
.leftTopIcon {
|
1097
1070
|
position: fixed;
|
1098
1071
|
left: 0;
|
1099
1072
|
top: 0;
|
1100
1073
|
}
|
1074
|
+
|
1101
1075
|
.actionButton {
|
1102
1076
|
display: flex;
|
1103
1077
|
justify-content: center;
|
1104
1078
|
align-items: center;
|
1105
1079
|
}
|
1080
|
+
|
1106
1081
|
/* Lottie容器样式 */
|
1107
1082
|
.lottie-container {
|
1108
1083
|
position: absolute;
|
@@ -1120,6 +1095,7 @@ button {
|
|
1120
1095
|
width: 100%;
|
1121
1096
|
height: 100%;
|
1122
1097
|
}
|
1098
|
+
|
1123
1099
|
.bg-anim,
|
1124
1100
|
.front-anim {
|
1125
1101
|
position: absolute;
|
@@ -1144,7 +1120,8 @@ button {
|
|
1144
1120
|
/* 正在拖拽的元素样式 */
|
1145
1121
|
.being-dragged {
|
1146
1122
|
z-index: 10;
|
1147
|
-
opacity: 0.3;
|
1123
|
+
opacity: 0.3;
|
1124
|
+
/* 降低原位置的不透明度 */
|
1148
1125
|
}
|
1149
1126
|
|
1150
1127
|
/* 被拖拽时原位置隐藏 */
|
@@ -1168,6 +1145,7 @@ button {
|
|
1168
1145
|
left: 0;
|
1169
1146
|
top: 0;
|
1170
1147
|
}
|
1148
|
+
|
1171
1149
|
.flexBox {
|
1172
1150
|
display: flex;
|
1173
1151
|
justify-content: space-between;
|
@@ -1175,6 +1153,7 @@ button {
|
|
1175
1153
|
position: relative;
|
1176
1154
|
flex-direction: row;
|
1177
1155
|
}
|
1156
|
+
|
1178
1157
|
.itemText {
|
1179
1158
|
display: block;
|
1180
1159
|
width: 80%;
|
@@ -1184,7 +1163,7 @@ button {
|
|
1184
1163
|
}
|
1185
1164
|
|
1186
1165
|
.shaking {
|
1187
|
-
animation: shake 0.
|
1166
|
+
animation: shake 0.6s infinite;
|
1188
1167
|
transform-origin: center center;
|
1189
1168
|
}
|
1190
1169
|
|
@@ -1193,22 +1172,21 @@ button {
|
|
1193
1172
|
0% {
|
1194
1173
|
transform: rotateZ(2deg);
|
1195
1174
|
}
|
1175
|
+
|
1196
1176
|
25% {
|
1197
1177
|
transform: rotateZ(-2deg);
|
1198
1178
|
}
|
1179
|
+
|
1199
1180
|
50% {
|
1200
1181
|
transform: rotateZ(2deg);
|
1201
1182
|
}
|
1183
|
+
|
1202
1184
|
75% {
|
1203
1185
|
transform: rotateZ(-2deg);
|
1204
1186
|
}
|
1187
|
+
|
1205
1188
|
100% {
|
1206
1189
|
transform: rotateZ(2deg);
|
1207
1190
|
}
|
1208
1191
|
}
|
1209
|
-
|
1210
|
-
.grid-item.shaking {
|
1211
|
-
animation: seesaw-rotate 0.6s linear infinite;
|
1212
|
-
transform-origin: center center;
|
1213
|
-
}
|
1214
1192
|
</style>
|