@dolphinweex/weex-harmony 0.1.23 → 0.1.25

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.23",
3
+ "version": "0.1.25",
4
4
  "description": "weex harmony adapter",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -72,7 +72,10 @@ export default {
72
72
  },
73
73
  methods: {
74
74
  postMessage(message){
75
- this.$refs["iframe"].contentWindow.postMessage(message, this.src)
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)
76
79
  },
77
80
  // 自定义拓展其它逻辑
78
81
  onPageFinish(res) {
@@ -260,10 +260,6 @@ export default {
260
260
  const oldVisibility = this.processedList[index].actionButton.visibility;
261
261
  const newVisibility = data.actionButton.visibility;
262
262
 
263
- if (typeof newVisibility === 'number') {
264
- console.log(`按钮可见性从 ${oldVisibility} 变更为 ${newVisibility}`);
265
- }
266
-
267
263
  // 检查是否有动画URL的变化
268
264
  const oldBgAnimUrl = this.processedList[index].bgAnimView.animUrl || '';
269
265
  const oldLoadingAnimUrl =
@@ -292,7 +288,6 @@ export default {
292
288
 
293
289
  // 如果动画URL有变化,重新初始化相关的Lottie动画
294
290
  if (hasAnimUrlChanged) {
295
- console.log('检测到动画URL变化,重新初始化动画');
296
291
 
297
292
  // 等待下一帧DOM更新完成后再操作
298
293
  this.$nextTick(() => {
@@ -307,7 +302,6 @@ export default {
307
302
  ];
308
303
  animKeys.forEach((key) => {
309
304
  if (this.lottieAnimations[key]) {
310
- console.log(`销毁动画实例: ${key}`);
311
305
  const anim = this.lottieAnimations[key];
312
306
  try {
313
307
  anim.removeEventListener('complete');
@@ -316,14 +310,12 @@ export default {
316
310
  anim.removeEventListener('loaded_images');
317
311
  anim.removeEventListener('loopComplete');
318
312
  } catch (e) {
319
- console.warn(`移除事件监听器失败: ${e.message}`);
320
313
  }
321
314
  anim.destroy();
322
315
  delete this.lottieAnimations[key];
323
316
  }
324
317
  });
325
318
 
326
- console.log('清理完成,开始重新初始化动画');
327
319
 
328
320
  // 延迟一点时间确保DOM完全更新
329
321
  setTimeout(() => {
@@ -361,11 +353,17 @@ export default {
361
353
  }
362
354
  },
363
355
  getListData(callback) {
364
- const data = Array.from(this.processedList);
356
+ let data = Array.from(this.processedList);
357
+ data = data.map((item)=>({
358
+ ...item,
359
+ itemView: {
360
+ ...item.itemView,
361
+ id:String(item.itemView.id)
362
+ }
363
+ }))
365
364
  callback({ listData: data });
366
365
  },
367
366
  rightIconClick(e) {
368
- console.log('rightIconClick执行,阻止事件冒泡');
369
367
  e.preventDefault();
370
368
  e.stopPropagation();
371
369
  this.$emit('onClickRightIcon', e);
@@ -374,7 +372,7 @@ export default {
374
372
  onSelectItems() {
375
373
  const selectedIds = this.data.list
376
374
  .filter((item) => item.itemView.isSelected)
377
- .map((item) => item.itemView.id);
375
+ .map((item) => String(item.itemView.id));
378
376
  return selectedIds;
379
377
  },
380
378
  selectIconClick(e, item, index) {
@@ -388,6 +386,7 @@ export default {
388
386
  ...e,
389
387
  };
390
388
  this.$emit('onClickSelectIcon', target);
389
+ this.$emit('onSelectItems',target)
391
390
  return false;
392
391
  },
393
392
 
@@ -396,16 +395,15 @@ export default {
396
395
  if (e.defaultPrevented) {
397
396
  return;
398
397
  }
399
-
400
- console.log('itemViewClick');
398
+ e.preventDefault();
399
+ e.stopPropagation();
401
400
  // 确保取消任何长按计时器
402
401
  this.cancelLongPress();
403
402
  if (this.data.isEditing) {
404
403
  item.itemView.isSelected = !item.itemView.isSelected;
404
+ this.$emit('onSelectItems',target)
405
405
  return;
406
406
  }
407
- e.preventDefault();
408
- e.stopPropagation();
409
407
  const target = {
410
408
  ...item.itemView,
411
409
  id: String(item.itemView.id),
@@ -416,7 +414,6 @@ export default {
416
414
  },
417
415
 
418
416
  actionClick(e, item, index) {
419
- console.log('actionClick执行,阻止事件冒泡');
420
417
  e.preventDefault();
421
418
  e.stopPropagation(); // 阻止事件冒泡到itemViewClick
422
419
 
@@ -435,14 +432,12 @@ export default {
435
432
 
436
433
  // 新增方法:清理除指定项目外的所有动画实例
437
434
  cleanupOtherAnimations(currentItemId) {
438
- console.log('清理其他项目的动画实例,当前项目ID:', currentItemId);
439
435
 
440
436
  // 遍历所有动画实例
441
437
  Object.keys(this.lottieAnimations).forEach((key) => {
442
438
  // 检查是否为其他项目的动画
443
439
  if (!key.includes(`-${currentItemId}`)) {
444
440
  if (this.lottieAnimations[key]) {
445
- console.log(`销毁其他项目的动画实例: ${key}`);
446
441
  const anim = this.lottieAnimations[key];
447
442
 
448
443
  // 移除所有事件监听器
@@ -471,7 +466,6 @@ export default {
471
466
  const animContainer =
472
467
  this.$refs[refName] && this.$refs[refName][0];
473
468
  if (animContainer) {
474
- console.log(`隐藏动画容器: ${refName}`);
475
469
  animContainer.style.display = 'none';
476
470
  }
477
471
  });
@@ -515,7 +509,6 @@ export default {
515
509
  },
516
510
  getItemStyle(item, type) {
517
511
  const result = this.mergeDate(item[type] || {}, type);
518
- console.log(type, this.applyNormalAttribute(result), 'ggg');
519
512
  return this.applyNormalAttribute(result);
520
513
  },
521
514
  mergeDate(target, type) {
@@ -591,7 +584,6 @@ export default {
591
584
  const touch = e.changedTouches[0];
592
585
  this.touchStartX = touch.pageX;
593
586
  this.touchStartY = touch.pageY;
594
- console.log('开始长按ddddddddd', touch, touch.pageY, touch.pageX);
595
587
  this.longPressStartIndex = index;
596
588
  this.isScrolling = false; // 重置滚动状态
597
589
 
@@ -608,9 +600,7 @@ export default {
608
600
  items: [...this.itemsList],
609
601
  });
610
602
  }
611
- console.log(
612
- `准备长按: index=${index}, 触摸坐标=(${touch.pageX}, ${touch.pageY})`
613
- );
603
+
614
604
 
615
605
  // 设置新的长按计时器
616
606
  this.longPressTimer = setTimeout(() => {
@@ -969,12 +959,6 @@ export default {
969
959
  // 为每个列表项初始化动画
970
960
  this.processedList.forEach((item) => {
971
961
  const itemId = item.itemView.id;
972
-
973
- console.log('处理项目ID:', itemId);
974
- console.log('loadingAnimView:', item.loadingAnimView);
975
- console.log('bgAnimView:', item.bgAnimView);
976
- console.log('frontAnimView:', item.frontAnimView);
977
-
978
962
  // 加载背景动画
979
963
  this.loadLottieAnimation(
980
964
  item.bgAnimView,
@@ -1006,27 +990,17 @@ export default {
1006
990
  // 抽取公共的loadLottieAnimation方法
1007
991
  loadLottieAnimation(animView, refName, animKey, item) {
1008
992
  if (!animView || !animView.animUrl) {
1009
- console.log(`[${animKey}] 跳过加载:animUrl不存在`);
1010
993
  return;
1011
994
  }
1012
995
 
1013
- console.log(
1014
- `[${animKey}] 尝试初始化${refName}, animUrl:`,
1015
- animView.animUrl,
1016
- '可见性:',
1017
- animView.visibility
1018
- );
1019
-
1020
996
  const animEl = this.$refs[refName];
1021
997
  if (!animEl || !animEl[0]) {
1022
- console.warn(`[${animKey}] 未找到${refName}的DOM引用,请检查DOM结构`);
1023
998
  return;
1024
999
  }
1025
1000
 
1026
1001
  try {
1027
1002
  // 如果已经有实例,先销毁它
1028
1003
  if (this.lottieAnimations[animKey]) {
1029
- console.log(`[${animKey}] 销毁现有的动画实例`);
1030
1004
  this.lottieAnimations[animKey].destroy();
1031
1005
  delete this.lottieAnimations[animKey];
1032
1006
  }
@@ -1037,33 +1011,21 @@ export default {
1037
1011
  animView.visibility !== 0
1038
1012
  ) {
1039
1013
  // 使用fetch方式获取动画数据
1040
- console.log(`[${animKey}] 开始获取动画数据:`, animView.animUrl);
1041
1014
  fetch(animView.animUrl)
1042
1015
  .then((response) => {
1043
1016
  if (!response.ok) {
1044
- console.error(
1045
- `[${animKey}] 获取动画数据失败,HTTP状态码:`,
1046
- response.status
1047
- );
1048
1017
  throw new Error('Network response was not ok');
1049
1018
  }
1050
- console.log(`[${animKey}] 网络请求成功,正在解析JSON`);
1051
1019
  return response.json();
1052
1020
  })
1053
1021
  .then((animationData) => {
1054
- console.log(
1055
- `[${animKey}] 动画数据已加载,数据大小:`,
1056
- JSON.stringify(animationData).length
1057
- );
1058
1022
  // 再次检查是否已有实例(可能在fetch期间创建了)
1059
1023
  if (this.lottieAnimations[animKey]) {
1060
- console.log(`[${animKey}] 销毁fetch期间创建的动画实例`);
1061
1024
  this.lottieAnimations[animKey].destroy();
1062
1025
  delete this.lottieAnimations[animKey];
1063
1026
  }
1064
1027
 
1065
1028
  // 创建新的动画实例
1066
- console.log(`[${animKey}] 创建新的动画实例`);
1067
1029
  const anim = lottie.loadAnimation({
1068
1030
  container: animEl[0],
1069
1031
  renderer: 'svg',
@@ -1079,15 +1041,10 @@ export default {
1079
1041
  this.lottieAnimations[animKey] = anim;
1080
1042
 
1081
1043
  // 添加动画事件监听
1082
- anim.addEventListener('DOMLoaded', () => {
1083
- console.log(`[${animKey}] 动画DOM已加载完成`);
1084
- });
1085
1044
 
1086
1045
  anim.addEventListener('complete', () => {
1087
- console.log(`[${animKey}] 动画播放完成一次`);
1088
1046
  // 检查是否需要销毁动画(非循环动画完成后销毁)
1089
1047
  if (!item.animRepeatCount) {
1090
- console.log(`[${animKey}] 非循环动画播放完成,执行销毁`);
1091
1048
  // 销毁前再次检查实例是否存在
1092
1049
  if (this.lottieAnimations[animKey] === anim) {
1093
1050
  anim.removeEventListener('complete');
@@ -1097,7 +1054,6 @@ export default {
1097
1054
  anim.removeEventListener('loopComplete');
1098
1055
  anim.destroy();
1099
1056
  delete this.lottieAnimations[animKey];
1100
- console.log(`[${animKey}] 动画实例已销毁`);
1101
1057
 
1102
1058
  // 查找并隐藏对应的动画容器
1103
1059
  this.$nextTick(() => {
@@ -1166,23 +1122,17 @@ export default {
1166
1122
  );
1167
1123
  }
1168
1124
  }
1169
- console.log(`[${animKey}] 已清空动画URL数据`);
1170
1125
  }
1171
1126
  });
1172
1127
  }
1173
1128
  }
1174
1129
  });
1175
1130
 
1176
- console.log(`[${animKey}] ${refName}初始化成功`);
1177
1131
  })
1178
1132
  .catch((error) => {
1179
- console.error(`[${animKey}] 加载${refName}动画数据失败:`, error);
1180
1133
  });
1181
- } else {
1182
- console.log(`[${animKey}] ${refName}可见性为0,跳过初始化`);
1183
- }
1134
+ }
1184
1135
  } catch (error) {
1185
- console.error(`[${animKey}] ${refName}初始化失败,详细错误:`, error);
1186
1136
  }
1187
1137
  },
1188
1138
 
@@ -1194,18 +1144,12 @@ export default {
1194
1144
  const rect = gridItem.getBoundingClientRect();
1195
1145
  this.fixedItemWidth = rect.width;
1196
1146
  this.fixedItemHeight = rect.height;
1197
- console.log(
1198
- '固定宽高已更新:',
1199
- this.fixedItemWidth,
1200
- this.fixedItemHeight
1201
- );
1202
1147
  }
1203
1148
  });
1204
1149
  },
1205
1150
 
1206
1151
  // 暂未使用,但保留用于将来扩展
1207
1152
  leftTopIconClick(e) {
1208
- console.log('leftTopIconClick执行,阻止事件冒泡');
1209
1153
  e.preventDefault();
1210
1154
  e.stopPropagation();
1211
1155
  // 这里可以添加将来的处理逻辑
@@ -1225,21 +1169,8 @@ export default {
1225
1169
  // 监听列表数据变化,自动更新处理后的数据
1226
1170
  'data.list': {
1227
1171
  handler(newList, oldList) {
1228
- console.log('检测到data.list变化');
1229
1172
  this.processedList = this.generateDataList();
1230
1173
  this.$nextTick(() => {
1231
- // 日志输出当前列表中所有按钮的可见性
1232
- if (this.processedList && this.processedList.length > 0) {
1233
- console.log('更新后的按钮可见性状态:');
1234
- this.processedList.forEach((item, idx) => {
1235
- if (item.actionButton) {
1236
- console.log(
1237
- `项目${idx} (ID:${item.itemView.id}) 按钮可见性: ${item.actionButton.visibility}`
1238
- );
1239
- }
1240
- });
1241
- }
1242
-
1243
1174
  this.updateGridBoxWidth();
1244
1175
  this.updateFixedItemSize();
1245
1176
  this.initLottieAnimations();
@@ -1289,10 +1220,6 @@ export default {
1289
1220
  oldList[index].bgAnimView &&
1290
1221
  item.bgAnimView.animUrl !== oldList[index].bgAnimView.animUrl
1291
1222
  ) {
1292
- console.log(
1293
- '检测到bgAnimView.animUrl变化:',
1294
- item.bgAnimView.animUrl
1295
- );
1296
1223
  this.$nextTick(() => {
1297
1224
  const itemId = item.itemView.id;
1298
1225
  if (this.lottieAnimations[`bg-${itemId}`]) {
@@ -1315,10 +1242,6 @@ export default {
1315
1242
  item.loadingAnimView.animUrl !==
1316
1243
  oldList[index].loadingAnimView.animUrl
1317
1244
  ) {
1318
- console.log(
1319
- '检测到loadingAnimView.animUrl变化:',
1320
- item.loadingAnimView.animUrl
1321
- );
1322
1245
  this.$nextTick(() => {
1323
1246
  const itemId = item.itemView.id;
1324
1247
  if (this.lottieAnimations[`loading-${itemId}`]) {
@@ -1340,10 +1263,6 @@ export default {
1340
1263
  oldList[index].frontAnimView &&
1341
1264
  item.frontAnimView.animUrl !== oldList[index].frontAnimView.animUrl
1342
1265
  ) {
1343
- console.log(
1344
- '检测到frontAnimView.animUrl变化:',
1345
- item.frontAnimView.animUrl
1346
- );
1347
1266
  this.$nextTick(() => {
1348
1267
  const itemId = item.itemView.id;
1349
1268
  if (this.lottieAnimations[`front-${itemId}`]) {
@@ -1403,7 +1322,6 @@ export default {
1403
1322
  Object.keys(this.lottieAnimations).forEach((key) => {
1404
1323
  const anim = this.lottieAnimations[key];
1405
1324
  if (anim && typeof anim.destroy === 'function') {
1406
- console.log(`组件销毁时清理动画: ${key}`);
1407
1325
  try {
1408
1326
  anim.removeEventListener('complete');
1409
1327
  anim.removeEventListener('DOMLoaded');
@@ -1411,7 +1329,6 @@ export default {
1411
1329
  anim.removeEventListener('loaded_images');
1412
1330
  anim.removeEventListener('loopComplete');
1413
1331
  } catch (e) {
1414
- console.warn(`移除事件监听器失败: ${e.message}`);
1415
1332
  }
1416
1333
  anim.destroy();
1417
1334
  }
@@ -343,6 +343,10 @@ module.exports = function (source) {
343
343
  script,
344
344
  styles
345
345
  } = moduleResoveRet
346
+ if (!template) {
347
+ return source
348
+ }
349
+
346
350
  const tempAst = parse(template.content)
347
351
  tempAst.forEach((node) => {
348
352
  traverseNode(node)
package/src/.DS_Store DELETED
Binary file
Binary file