@fonixtree/magic-design 0.0.161 → 0.0.162

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.
@@ -427,46 +427,18 @@ function ImageModal(_a) {
427
427
  }
428
428
  });
429
429
  });
430
- };
431
-
432
- var getPreConfig = function getPreConfig() {
433
- return __awaiter(_this, void 0, void 0, function () {
434
- var wapUrl_1, error_1;
435
- return __generator(this, function (_a) {
436
- switch (_a.label) {
437
- case 0:
438
- _a.trys.push([0, 2,, 3]);
439
-
440
- return [4
441
- /*yield*/
442
- , (0, _commonUtil.commonFetch)("/designer/v1/" + window.magicDesign.MBaseUrl + "/pages/platforminfo")];
430
+ }; // const getPreConfig = async () => {
431
+ // try {
432
+ // const { wapUrl } = await commonFetch(`/designer/v1/${window.magicDesign.MBaseUrl}/pages/platforminfo`);
433
+ // setWapUrl(wapUrl);
434
+ // } catch (error) {
435
+ // console.error(error);
436
+ // }
437
+ // };
443
438
 
444
- case 1:
445
- wapUrl_1 = _a.sent().wapUrl;
446
- setWapUrl(wapUrl_1);
447
- return [3
448
- /*break*/
449
- , 3];
450
-
451
- case 2:
452
- error_1 = _a.sent();
453
- console.error(error_1);
454
- return [3
455
- /*break*/
456
- , 3];
457
-
458
- case 3:
459
- return [2
460
- /*return*/
461
- ];
462
- }
463
- });
464
- });
465
- };
466
439
 
467
440
  (0, _react.useEffect)(function () {
468
- getContentCatgs();
469
- getPreConfig();
441
+ getContentCatgs(); // getPreConfig();
470
442
  }, []);
471
443
 
472
444
  var selectFolder = function selectFolder(id) {
@@ -310,7 +310,32 @@ function (_super) {
310
310
  var _this = _super !== null && _super.apply(this, arguments) || this;
311
311
 
312
312
  _this.state = {};
313
- _this.player = null;
313
+ _this.player = {
314
+ play: function play() {
315
+ if (_this.aliPlayer) {
316
+ _this.aliPlayer.play();
317
+ }
318
+
319
+ if (_this.ytPlayer) {
320
+ _this.ytPlayer.playVideo();
321
+ }
322
+ },
323
+ pause: function pause() {
324
+ if (_this.aliPlayer) {
325
+ _this.aliPlayer.play();
326
+ }
327
+
328
+ if (_this.ytPlayer) {
329
+ _this.ytPlayer.pauseVideo();
330
+ }
331
+ }
332
+ };
333
+ /** 阿里播放器 */
334
+
335
+ _this.aliPlayer = null;
336
+ /** YouTube播放器 */
337
+
338
+ _this.ytPlayer = null;
314
339
  /** 创建视频弹框显示 */
315
340
 
316
341
  _this.createVideoModal = function (videoId) {
@@ -352,7 +377,7 @@ function (_super) {
352
377
 
353
378
  _this.getInit = function () {
354
379
  return __awaiter(_this, void 0, void 0, function () {
355
- var _a;
380
+ var videoId_1, _a;
356
381
 
357
382
  var _this = this;
358
383
 
@@ -372,23 +397,60 @@ function (_super) {
372
397
  _b.label = 2;
373
398
 
374
399
  case 2:
375
- if (!this.props.opts.source) return [3
400
+ if (!!window.YT) return [3
376
401
  /*break*/
377
402
  , 4];
403
+ return [4
404
+ /*yield*/
405
+ , Promise.all([(0, _commonUtil.importAsync)('https://www.youtube.com/iframe_api', 'js')])];
406
+
407
+ case 3:
408
+ _b.sent();
409
+
410
+ _b.label = 4;
411
+
412
+ case 4:
413
+ if (!this.props.opts.source) return [3
414
+ /*break*/
415
+ , 7];
416
+ if (!/youtu/.test(this.props.opts.source)) return [3
417
+ /*break*/
418
+ , 5];
419
+ videoId_1 = this.props.opts.source.split('youtu.be/')[1];
420
+ (0, _commonUtil.nextTick)(function () {
421
+ _this.ytPlayer = new YT.Player('video' + _this.props.videoId, {
422
+ height: '100%',
423
+ width: '100%',
424
+ videoId: videoId_1,
425
+ events: {
426
+ onReady: function onReady() {
427
+ console.log('onReady');
428
+ },
429
+ onStateChange: function onStateChange() {
430
+ console.log('onStateChange');
431
+ }
432
+ }
433
+ });
434
+ }, 500, 10);
435
+ return [3
436
+ /*break*/
437
+ , 7];
438
+
439
+ case 5:
378
440
  _a = this;
379
441
  return [4
380
442
  /*yield*/
381
443
  , createVideo(this.props.videoId, this.props.opts)];
382
444
 
383
- case 3:
384
- _a.player = _b.sent();
385
- this.player.on('ended', function () {
445
+ case 6:
446
+ _a.aliPlayer = _b.sent();
447
+ this.aliPlayer.on('ended', function () {
386
448
  if (!_this.props.opts.loop) {// this.props.onEnd();
387
449
  }
388
450
  });
389
- _b.label = 4;
451
+ _b.label = 7;
390
452
 
391
- case 4:
453
+ case 7:
392
454
  return [2
393
455
  /*return*/
394
456
  ];
@@ -397,13 +459,8 @@ function (_super) {
397
459
  });
398
460
  };
399
461
 
400
- _this.fullPlay = function (type) {
401
- // if (type == 'h5') {
402
- // this.player.fullscreenService.requestFullScreen();
403
- // }
404
- // if (type == 'pc') {
405
- _this.createVideoModal(_this.props.videoId); // }
406
-
462
+ _this.fullPlay = function () {
463
+ _this.createVideoModal(_this.props.videoId);
407
464
  };
408
465
 
409
466
  return _this;
@@ -418,10 +475,10 @@ function (_super) {
418
475
  videoId = _a.videoId,
419
476
  opts = _a.opts,
420
477
  play = _a.play;
421
- console.log('play: ', play);
422
478
  return /*#__PURE__*/_react["default"].createElement("div", {
423
479
  className: "video-container"
424
480
  }, opts.source ? /*#__PURE__*/_react["default"].createElement("div", {
481
+ className: "video-wrap",
425
482
  id: 'video' + videoId
426
483
  }) : null, !play && /*#__PURE__*/_react["default"].createElement("div", {
427
484
  className: "cover-video"
@@ -15,6 +15,11 @@
15
15
  top: 0;
16
16
  background-color: rgba(0, 0, 0, 0);
17
17
  }
18
+
19
+ .video-wrap {
20
+ width: 100%;
21
+ height: 100%;
22
+ }
18
23
  }
19
24
 
20
25
  .pc-video-modal-wrap {
@@ -7,10 +7,6 @@ exports.getDefaultJSON = exports.bannerGroupSourceJSON = void 0;
7
7
 
8
8
  var _uuid = require("uuid");
9
9
 
10
- var _banner = _interopRequireDefault(require("./imgs/banner.png"));
11
-
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
13
-
14
10
  var bannerGroupSourceJSON = function bannerGroupSourceJSON() {
15
11
  var groupId = (0, _uuid.v4)();
16
12
  return {
@@ -23,8 +19,8 @@ var bannerGroupSourceJSON = function bannerGroupSourceJSON() {
23
19
  content: {
24
20
  h5Name: 'name2',
25
21
  pcName: 'name2',
26
- h5ImgSrc: _banner["default"],
27
- pcImgSrc: _banner["default"],
22
+ h5ImgSrc: '',
23
+ pcImgSrc: '',
28
24
  clickUrl: ''
29
25
  },
30
26
  hover: {
@@ -7,10 +7,6 @@ exports.videoGroupSourceJSON = exports.getDefaultJSON = void 0;
7
7
 
8
8
  var _uuid = require("uuid");
9
9
 
10
- var _banner = _interopRequireDefault(require("./imgs/banner.png"));
11
-
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
13
-
14
10
  var videoGroupSourceJSON = function videoGroupSourceJSON(parentId) {
15
11
  var groupId = (0, _uuid.v4)();
16
12
  return {
@@ -24,8 +20,8 @@ var videoGroupSourceJSON = function videoGroupSourceJSON(parentId) {
24
20
  content: {
25
21
  h5Name: 'name2',
26
22
  pcName: 'name2',
27
- h5ImgSrc: _banner["default"],
28
- pcImgSrc: _banner["default"],
23
+ h5ImgSrc: '',
24
+ pcImgSrc: '',
29
25
  clickUrl: ''
30
26
  },
31
27
  hover: {
@@ -141,8 +137,8 @@ var videoGroupSourceJSON = function videoGroupSourceJSON(parentId) {
141
137
  content: {
142
138
  h5Name: 'name2',
143
139
  pcName: 'name2',
144
- h5ImgSrc: _banner["default"],
145
- pcImgSrc: _banner["default"],
140
+ h5ImgSrc: '',
141
+ pcImgSrc: '',
146
142
  clickUrl: ''
147
143
  },
148
144
  hover: {}
@@ -15,6 +15,8 @@ var _immutabilityHelper = _interopRequireDefault(require("immutability-helper"))
15
15
 
16
16
  var _react = _interopRequireWildcard(require("react"));
17
17
 
18
+ var _lodash = require("lodash");
19
+
18
20
  var _common = require("../../../common");
19
21
 
20
22
  var _coreUtil = require("../../../utils/coreUtil");
@@ -78,6 +80,15 @@ function PageCompList(_a) {
78
80
  setHoveredFloor = _e[1];
79
81
 
80
82
  var ref = (0, _react.useRef)();
83
+
84
+ var getActiveComponents = function getActiveComponents() {
85
+ var filter = components.filter(function (comp) {
86
+ return (0, _coreUtil.isActiveFloor)(comp.activeTerminal);
87
+ });
88
+ return filter;
89
+ };
90
+
91
+ var activeComponents = getActiveComponents();
81
92
  (0, _react.useEffect)(function () {
82
93
  setComponents(pageData || []);
83
94
  }, [pageData]);
@@ -109,7 +120,6 @@ function PageCompList(_a) {
109
120
  };
110
121
 
111
122
  var onDragEnter = function onDragEnter(e) {
112
- console.log('drag enter');
113
123
  var hoverNodeId = e.currentTarget.dataset.nodeid;
114
124
 
115
125
  if (dragId === hoverNodeId) {
@@ -127,18 +137,36 @@ function PageCompList(_a) {
127
137
  }
128
138
  };
129
139
 
140
+ var getLastSameIndex = function getLastSameIndex(comps, index) {
141
+ var lastComps = comps.slice(0, index);
142
+ var newIndex = (0, _lodash.findLastIndex)(lastComps, function (comp) {
143
+ return (0, _coreUtil.isActiveFloor)(comp.activeTerminal);
144
+ });
145
+ return newIndex;
146
+ };
147
+
148
+ var getNextSameIndex = function getNextSameIndex(comps, index) {
149
+ var nextComps = comps.slice(index + 1);
150
+ var newIndex = (0, _lodash.findIndex)(nextComps, function (comp) {
151
+ return (0, _coreUtil.isActiveFloor)(comp.activeTerminal);
152
+ });
153
+ return newIndex + index + 1;
154
+ };
155
+
130
156
  var onMenuClick = function onMenuClick(activeComp, operType) {
131
157
  var newComponents = __spreadArrays(components);
132
158
 
133
159
  var index = newComponents.indexOf(activeComp);
134
160
 
135
161
  if (operType === operTypeMap.MOVE_UP) {
136
- var temp = newComponents[index - 1];
137
- newComponents[index - 1] = newComponents[index];
162
+ var newIndex = getLastSameIndex(newComponents, index);
163
+ var temp = newComponents[newIndex];
164
+ newComponents[newIndex] = newComponents[index];
138
165
  newComponents[index] = temp;
139
166
  } else if (operType === operTypeMap.MOVE_DOWN) {
140
- var temp = newComponents[index + 1];
141
- newComponents[index + 1] = newComponents[index];
167
+ var newIndex = getNextSameIndex(newComponents, index);
168
+ var temp = newComponents[newIndex];
169
+ newComponents[newIndex] = newComponents[index];
142
170
  newComponents[index] = temp;
143
171
  } else if (operType === operTypeMap.COPY) {
144
172
  var copyComponent = (0, _coreUtil.copyNode)(newComponents[index]);
@@ -193,7 +221,7 @@ function PageCompList(_a) {
193
221
  }, index !== 0 && /*#__PURE__*/_react["default"].createElement(_antd.Menu.Item, {
194
222
  className: "menu_item",
195
223
  value: "1"
196
- }, (0, _locale.i18n)('MOVE_UP')), index !== components.length - 1 && /*#__PURE__*/_react["default"].createElement(_antd.Menu.Item, {
224
+ }, (0, _locale.i18n)('MOVE_UP')), index !== activeComponents.length - 1 && /*#__PURE__*/_react["default"].createElement(_antd.Menu.Item, {
197
225
  className: "menu_item",
198
226
  value: "2"
199
227
  }, (0, _locale.i18n)('MOVE_DOWN')), /*#__PURE__*/_react["default"].createElement(_antd.Menu.Item, {
@@ -277,14 +305,6 @@ function PageCompList(_a) {
277
305
  })));
278
306
  };
279
307
 
280
- var getActiveComponents = function getActiveComponents() {
281
- var filter = components.filter(function (comp) {
282
- return (0, _coreUtil.isActiveFloor)(comp.activeTerminal);
283
- });
284
- return filter;
285
- };
286
-
287
- var activeComponents = getActiveComponents();
288
308
  return /*#__PURE__*/_react["default"].createElement("div", {
289
309
  className: "page-comp-wrap"
290
310
  }, /*#__PURE__*/_react["default"].createElement("div", {
@@ -14,7 +14,7 @@ exports.dragSource = void 0;
14
14
  exports.ensure = ensure;
15
15
  exports.getColorRgba = void 0;
16
16
  exports.getPageDataMap = getPageDataMap;
17
- exports.navigateTo = exports.importAsync = exports.getUrlParams = void 0;
17
+ exports.nextTick = exports.navigateTo = exports.importAsync = exports.getUrlParams = void 0;
18
18
  exports.pushGA = pushGA;
19
19
  exports.shareFacebook = shareFacebook;
20
20
  exports.shareLinkedin = shareLinkedin;
@@ -474,4 +474,29 @@ function covertKey(data, func) {
474
474
  var newData = (0, _lodash.cloneDeep)(data);
475
475
  func(newData);
476
476
  return JSON.stringify(newData);
477
- }
477
+ }
478
+
479
+ var nextTick = function nextTick(func, interval, count) {
480
+ if (interval === void 0) {
481
+ interval = 100;
482
+ }
483
+
484
+ if (count === void 0) {
485
+ count = 5;
486
+ }
487
+
488
+ try {
489
+ func();
490
+ } catch (error) {
491
+ if (count == 0) {
492
+ console.error('nextTick 失败');
493
+ return;
494
+ }
495
+
496
+ setTimeout(function () {
497
+ nextTick(func, interval, count - 1);
498
+ }, interval);
499
+ }
500
+ };
501
+
502
+ exports.nextTick = nextTick;
@@ -427,46 +427,18 @@ function ImageModal(_a) {
427
427
  }
428
428
  });
429
429
  });
430
- };
431
-
432
- var getPreConfig = function getPreConfig() {
433
- return __awaiter(_this, void 0, void 0, function () {
434
- var wapUrl_1, error_1;
435
- return __generator(this, function (_a) {
436
- switch (_a.label) {
437
- case 0:
438
- _a.trys.push([0, 2,, 3]);
439
-
440
- return [4
441
- /*yield*/
442
- , (0, _commonUtil.commonFetch)("/designer/v1/" + window.magicDesign.MBaseUrl + "/pages/platforminfo")];
430
+ }; // const getPreConfig = async () => {
431
+ // try {
432
+ // const { wapUrl } = await commonFetch(`/designer/v1/${window.magicDesign.MBaseUrl}/pages/platforminfo`);
433
+ // setWapUrl(wapUrl);
434
+ // } catch (error) {
435
+ // console.error(error);
436
+ // }
437
+ // };
443
438
 
444
- case 1:
445
- wapUrl_1 = _a.sent().wapUrl;
446
- setWapUrl(wapUrl_1);
447
- return [3
448
- /*break*/
449
- , 3];
450
-
451
- case 2:
452
- error_1 = _a.sent();
453
- console.error(error_1);
454
- return [3
455
- /*break*/
456
- , 3];
457
-
458
- case 3:
459
- return [2
460
- /*return*/
461
- ];
462
- }
463
- });
464
- });
465
- };
466
439
 
467
440
  (0, _react.useEffect)(function () {
468
- getContentCatgs();
469
- getPreConfig();
441
+ getContentCatgs(); // getPreConfig();
470
442
  }, []);
471
443
 
472
444
  var selectFolder = function selectFolder(id) {
@@ -310,7 +310,32 @@ function (_super) {
310
310
  var _this = _super !== null && _super.apply(this, arguments) || this;
311
311
 
312
312
  _this.state = {};
313
- _this.player = null;
313
+ _this.player = {
314
+ play: function play() {
315
+ if (_this.aliPlayer) {
316
+ _this.aliPlayer.play();
317
+ }
318
+
319
+ if (_this.ytPlayer) {
320
+ _this.ytPlayer.playVideo();
321
+ }
322
+ },
323
+ pause: function pause() {
324
+ if (_this.aliPlayer) {
325
+ _this.aliPlayer.play();
326
+ }
327
+
328
+ if (_this.ytPlayer) {
329
+ _this.ytPlayer.pauseVideo();
330
+ }
331
+ }
332
+ };
333
+ /** 阿里播放器 */
334
+
335
+ _this.aliPlayer = null;
336
+ /** YouTube播放器 */
337
+
338
+ _this.ytPlayer = null;
314
339
  /** 创建视频弹框显示 */
315
340
 
316
341
  _this.createVideoModal = function (videoId) {
@@ -352,7 +377,7 @@ function (_super) {
352
377
 
353
378
  _this.getInit = function () {
354
379
  return __awaiter(_this, void 0, void 0, function () {
355
- var _a;
380
+ var videoId_1, _a;
356
381
 
357
382
  var _this = this;
358
383
 
@@ -372,23 +397,60 @@ function (_super) {
372
397
  _b.label = 2;
373
398
 
374
399
  case 2:
375
- if (!this.props.opts.source) return [3
400
+ if (!!window.YT) return [3
376
401
  /*break*/
377
402
  , 4];
403
+ return [4
404
+ /*yield*/
405
+ , Promise.all([(0, _commonUtil.importAsync)('https://www.youtube.com/iframe_api', 'js')])];
406
+
407
+ case 3:
408
+ _b.sent();
409
+
410
+ _b.label = 4;
411
+
412
+ case 4:
413
+ if (!this.props.opts.source) return [3
414
+ /*break*/
415
+ , 7];
416
+ if (!/youtu/.test(this.props.opts.source)) return [3
417
+ /*break*/
418
+ , 5];
419
+ videoId_1 = this.props.opts.source.split('youtu.be/')[1];
420
+ (0, _commonUtil.nextTick)(function () {
421
+ _this.ytPlayer = new YT.Player('video' + _this.props.videoId, {
422
+ height: '100%',
423
+ width: '100%',
424
+ videoId: videoId_1,
425
+ events: {
426
+ onReady: function onReady() {
427
+ console.log('onReady');
428
+ },
429
+ onStateChange: function onStateChange() {
430
+ console.log('onStateChange');
431
+ }
432
+ }
433
+ });
434
+ }, 500, 10);
435
+ return [3
436
+ /*break*/
437
+ , 7];
438
+
439
+ case 5:
378
440
  _a = this;
379
441
  return [4
380
442
  /*yield*/
381
443
  , createVideo(this.props.videoId, this.props.opts)];
382
444
 
383
- case 3:
384
- _a.player = _b.sent();
385
- this.player.on('ended', function () {
445
+ case 6:
446
+ _a.aliPlayer = _b.sent();
447
+ this.aliPlayer.on('ended', function () {
386
448
  if (!_this.props.opts.loop) {// this.props.onEnd();
387
449
  }
388
450
  });
389
- _b.label = 4;
451
+ _b.label = 7;
390
452
 
391
- case 4:
453
+ case 7:
392
454
  return [2
393
455
  /*return*/
394
456
  ];
@@ -397,13 +459,8 @@ function (_super) {
397
459
  });
398
460
  };
399
461
 
400
- _this.fullPlay = function (type) {
401
- // if (type == 'h5') {
402
- // this.player.fullscreenService.requestFullScreen();
403
- // }
404
- // if (type == 'pc') {
405
- _this.createVideoModal(_this.props.videoId); // }
406
-
462
+ _this.fullPlay = function () {
463
+ _this.createVideoModal(_this.props.videoId);
407
464
  };
408
465
 
409
466
  return _this;
@@ -418,10 +475,10 @@ function (_super) {
418
475
  videoId = _a.videoId,
419
476
  opts = _a.opts,
420
477
  play = _a.play;
421
- console.log('play: ', play);
422
478
  return /*#__PURE__*/_react["default"].createElement("div", {
423
479
  className: "video-container"
424
480
  }, opts.source ? /*#__PURE__*/_react["default"].createElement("div", {
481
+ className: "video-wrap",
425
482
  id: 'video' + videoId
426
483
  }) : null, !play && /*#__PURE__*/_react["default"].createElement("div", {
427
484
  className: "cover-video"
@@ -15,6 +15,11 @@
15
15
  top: 0;
16
16
  background-color: rgba(0, 0, 0, 0);
17
17
  }
18
+
19
+ .video-wrap {
20
+ width: 100%;
21
+ height: 100%;
22
+ }
18
23
  }
19
24
 
20
25
  .pc-video-modal-wrap {
@@ -7,10 +7,6 @@ exports.getDefaultJSON = exports.bannerGroupSourceJSON = void 0;
7
7
 
8
8
  var _uuid = require("uuid");
9
9
 
10
- var _banner = _interopRequireDefault(require("./imgs/banner.png"));
11
-
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
13
-
14
10
  var bannerGroupSourceJSON = function bannerGroupSourceJSON() {
15
11
  var groupId = (0, _uuid.v4)();
16
12
  return {
@@ -23,8 +19,8 @@ var bannerGroupSourceJSON = function bannerGroupSourceJSON() {
23
19
  content: {
24
20
  h5Name: 'name2',
25
21
  pcName: 'name2',
26
- h5ImgSrc: _banner["default"],
27
- pcImgSrc: _banner["default"],
22
+ h5ImgSrc: '',
23
+ pcImgSrc: '',
28
24
  clickUrl: ''
29
25
  },
30
26
  hover: {
@@ -7,10 +7,6 @@ exports.videoGroupSourceJSON = exports.getDefaultJSON = void 0;
7
7
 
8
8
  var _uuid = require("uuid");
9
9
 
10
- var _banner = _interopRequireDefault(require("./imgs/banner.png"));
11
-
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
13
-
14
10
  var videoGroupSourceJSON = function videoGroupSourceJSON(parentId) {
15
11
  var groupId = (0, _uuid.v4)();
16
12
  return {
@@ -24,8 +20,8 @@ var videoGroupSourceJSON = function videoGroupSourceJSON(parentId) {
24
20
  content: {
25
21
  h5Name: 'name2',
26
22
  pcName: 'name2',
27
- h5ImgSrc: _banner["default"],
28
- pcImgSrc: _banner["default"],
23
+ h5ImgSrc: '',
24
+ pcImgSrc: '',
29
25
  clickUrl: ''
30
26
  },
31
27
  hover: {
@@ -141,8 +137,8 @@ var videoGroupSourceJSON = function videoGroupSourceJSON(parentId) {
141
137
  content: {
142
138
  h5Name: 'name2',
143
139
  pcName: 'name2',
144
- h5ImgSrc: _banner["default"],
145
- pcImgSrc: _banner["default"],
140
+ h5ImgSrc: '',
141
+ pcImgSrc: '',
146
142
  clickUrl: ''
147
143
  },
148
144
  hover: {}
@@ -15,6 +15,8 @@ var _immutabilityHelper = _interopRequireDefault(require("immutability-helper"))
15
15
 
16
16
  var _react = _interopRequireWildcard(require("react"));
17
17
 
18
+ var _lodash = require("lodash");
19
+
18
20
  var _common = require("../../../common");
19
21
 
20
22
  var _coreUtil = require("../../../utils/coreUtil");
@@ -78,6 +80,15 @@ function PageCompList(_a) {
78
80
  setHoveredFloor = _e[1];
79
81
 
80
82
  var ref = (0, _react.useRef)();
83
+
84
+ var getActiveComponents = function getActiveComponents() {
85
+ var filter = components.filter(function (comp) {
86
+ return (0, _coreUtil.isActiveFloor)(comp.activeTerminal);
87
+ });
88
+ return filter;
89
+ };
90
+
91
+ var activeComponents = getActiveComponents();
81
92
  (0, _react.useEffect)(function () {
82
93
  setComponents(pageData || []);
83
94
  }, [pageData]);
@@ -109,7 +120,6 @@ function PageCompList(_a) {
109
120
  };
110
121
 
111
122
  var onDragEnter = function onDragEnter(e) {
112
- console.log('drag enter');
113
123
  var hoverNodeId = e.currentTarget.dataset.nodeid;
114
124
 
115
125
  if (dragId === hoverNodeId) {
@@ -127,18 +137,36 @@ function PageCompList(_a) {
127
137
  }
128
138
  };
129
139
 
140
+ var getLastSameIndex = function getLastSameIndex(comps, index) {
141
+ var lastComps = comps.slice(0, index);
142
+ var newIndex = (0, _lodash.findLastIndex)(lastComps, function (comp) {
143
+ return (0, _coreUtil.isActiveFloor)(comp.activeTerminal);
144
+ });
145
+ return newIndex;
146
+ };
147
+
148
+ var getNextSameIndex = function getNextSameIndex(comps, index) {
149
+ var nextComps = comps.slice(index + 1);
150
+ var newIndex = (0, _lodash.findIndex)(nextComps, function (comp) {
151
+ return (0, _coreUtil.isActiveFloor)(comp.activeTerminal);
152
+ });
153
+ return newIndex + index + 1;
154
+ };
155
+
130
156
  var onMenuClick = function onMenuClick(activeComp, operType) {
131
157
  var newComponents = __spreadArrays(components);
132
158
 
133
159
  var index = newComponents.indexOf(activeComp);
134
160
 
135
161
  if (operType === operTypeMap.MOVE_UP) {
136
- var temp = newComponents[index - 1];
137
- newComponents[index - 1] = newComponents[index];
162
+ var newIndex = getLastSameIndex(newComponents, index);
163
+ var temp = newComponents[newIndex];
164
+ newComponents[newIndex] = newComponents[index];
138
165
  newComponents[index] = temp;
139
166
  } else if (operType === operTypeMap.MOVE_DOWN) {
140
- var temp = newComponents[index + 1];
141
- newComponents[index + 1] = newComponents[index];
167
+ var newIndex = getNextSameIndex(newComponents, index);
168
+ var temp = newComponents[newIndex];
169
+ newComponents[newIndex] = newComponents[index];
142
170
  newComponents[index] = temp;
143
171
  } else if (operType === operTypeMap.COPY) {
144
172
  var copyComponent = (0, _coreUtil.copyNode)(newComponents[index]);
@@ -193,7 +221,7 @@ function PageCompList(_a) {
193
221
  }, index !== 0 && /*#__PURE__*/_react["default"].createElement(_antd.Menu.Item, {
194
222
  className: "menu_item",
195
223
  value: "1"
196
- }, (0, _locale.i18n)('MOVE_UP')), index !== components.length - 1 && /*#__PURE__*/_react["default"].createElement(_antd.Menu.Item, {
224
+ }, (0, _locale.i18n)('MOVE_UP')), index !== activeComponents.length - 1 && /*#__PURE__*/_react["default"].createElement(_antd.Menu.Item, {
197
225
  className: "menu_item",
198
226
  value: "2"
199
227
  }, (0, _locale.i18n)('MOVE_DOWN')), /*#__PURE__*/_react["default"].createElement(_antd.Menu.Item, {
@@ -277,14 +305,6 @@ function PageCompList(_a) {
277
305
  })));
278
306
  };
279
307
 
280
- var getActiveComponents = function getActiveComponents() {
281
- var filter = components.filter(function (comp) {
282
- return (0, _coreUtil.isActiveFloor)(comp.activeTerminal);
283
- });
284
- return filter;
285
- };
286
-
287
- var activeComponents = getActiveComponents();
288
308
  return /*#__PURE__*/_react["default"].createElement("div", {
289
309
  className: "page-comp-wrap"
290
310
  }, /*#__PURE__*/_react["default"].createElement("div", {
@@ -14,7 +14,7 @@ exports.dragSource = void 0;
14
14
  exports.ensure = ensure;
15
15
  exports.getColorRgba = void 0;
16
16
  exports.getPageDataMap = getPageDataMap;
17
- exports.navigateTo = exports.importAsync = exports.getUrlParams = void 0;
17
+ exports.nextTick = exports.navigateTo = exports.importAsync = exports.getUrlParams = void 0;
18
18
  exports.pushGA = pushGA;
19
19
  exports.shareFacebook = shareFacebook;
20
20
  exports.shareLinkedin = shareLinkedin;
@@ -474,4 +474,29 @@ function covertKey(data, func) {
474
474
  var newData = (0, _lodash.cloneDeep)(data);
475
475
  func(newData);
476
476
  return JSON.stringify(newData);
477
- }
477
+ }
478
+
479
+ var nextTick = function nextTick(func, interval, count) {
480
+ if (interval === void 0) {
481
+ interval = 100;
482
+ }
483
+
484
+ if (count === void 0) {
485
+ count = 5;
486
+ }
487
+
488
+ try {
489
+ func();
490
+ } catch (error) {
491
+ if (count == 0) {
492
+ console.error('nextTick 失败');
493
+ return;
494
+ }
495
+
496
+ setTimeout(function () {
497
+ nextTick(func, interval, count - 1);
498
+ }, interval);
499
+ }
500
+ };
501
+
502
+ exports.nextTick = nextTick;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@fonixtree/magic-design",
3
3
  "author": "Cylon Team",
4
- "version": "0.0.161",
4
+ "version": "0.0.162",
5
5
  "description": "Magic Design",
6
6
  "license": "MIT",
7
7
  "module": "es/index.js",