@fonixtree/magic-design 2.0.88 → 2.0.90

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.
Files changed (25) hide show
  1. package/es/common/LinkModal/SelectVideoModal/index.js +3 -2
  2. package/es/common/LinkModal/index.js +8 -5
  3. package/es/common/Video/QualityComponent/index.js +169 -0
  4. package/es/common/Video/QualityComponent/index.less +78 -0
  5. package/es/common/Video/index.js +142 -86
  6. package/es/common/VideoUpload/index.js +1 -1
  7. package/es/composite-comp/bol/second-config-panels/VideoSecondConfig/index.js +3 -1
  8. package/es/composite-comp/dito/second-config-panels/HeadNavigationSecondConfig/index.js +1 -1
  9. package/es/composite-comp/dito/second-config-panels/MenuNavigationSecondConfig/index.js +1 -1
  10. package/es/decorator/index.js +4 -1
  11. package/lib/common/LinkModal/SelectVideoModal/index.js +3 -2
  12. package/lib/common/LinkModal/index.js +8 -5
  13. package/lib/common/Video/QualityComponent/index.js +169 -0
  14. package/lib/common/Video/QualityComponent/index.less +78 -0
  15. package/lib/common/Video/index.js +142 -86
  16. package/lib/common/VideoUpload/index.js +1 -1
  17. package/lib/composite-comp/bol/second-config-panels/VideoSecondConfig/index.js +3 -1
  18. package/lib/composite-comp/dito/second-config-panels/HeadNavigationSecondConfig/index.js +1 -1
  19. package/lib/composite-comp/dito/second-config-panels/MenuNavigationSecondConfig/index.js +1 -1
  20. package/lib/decorator/index.js +4 -1
  21. package/package.json +1 -1
  22. /package/es/common/Video/{components → RateComponent}/index.js +0 -0
  23. /package/es/common/Video/{components → RateComponent}/index.less +0 -0
  24. /package/lib/common/Video/{components → RateComponent}/index.js +0 -0
  25. /package/lib/common/Video/{components → RateComponent}/index.less +0 -0
@@ -128,10 +128,11 @@ function (_super) {
128
128
  size: "20px",
129
129
  type: "icon-delete1"
130
130
  })))), this.videoSetting.sourceType === 'Upload' && /*#__PURE__*/_react["default"].createElement(_VideoUpload["default"], {
131
- onChange: function onChange(v, n) {
131
+ onChange: function onChange(v, n, id) {
132
132
  _this.onFieldChange({
133
133
  sourceUrl: v,
134
- name: n
134
+ name: n,
135
+ sourceId: id
135
136
  });
136
137
  },
137
138
  value: this.videoSetting.sourceUrl
@@ -234,7 +234,7 @@ var LinkModal = function LinkModal(props) {
234
234
 
235
235
  var getLinkTypes = function getLinkTypes() {
236
236
  return __awaiter(void 0, void 0, void 0, function () {
237
- var types, type;
237
+ var types, type_1;
238
238
  return __generator(this, function (_a) {
239
239
  switch (_a.label) {
240
240
  case 0:
@@ -248,12 +248,15 @@ var LinkModal = function LinkModal(props) {
248
248
  types = _a.sent();
249
249
 
250
250
  if (onlySpecificCode) {
251
- type = types.filter(function (item) {
252
- return item.linkTypeCode === onlySpecificCode;
251
+ type_1 = [];
252
+ onlySpecificCode.forEach(function (code) {
253
+ type_1.push(types.find(function (item) {
254
+ return item.linkTypeCode === code;
255
+ }));
253
256
  });
254
257
 
255
- if (type.length > 0) {
256
- types = type;
258
+ if (type_1.length > 0) {
259
+ types = type_1;
257
260
  }
258
261
  }
259
262
 
@@ -0,0 +1,169 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+
8
+ require("./index.less");
9
+
10
+ function parseDom(html) {
11
+ var ele = document.createElement('div');
12
+ ele.innerHTML = html;
13
+ return ele.childNodes[0];
14
+ }
15
+
16
+ function cookieSet(cname, cvalue, exdays) {
17
+ var d = new Date();
18
+ d.setTime(d.getTime() + exdays * 24 * 60 * 60 * 1000);
19
+ var expires = 'expires=' + d.toGMTString();
20
+ document.cookie = cname + '=' + escape(cvalue) + '; ' + expires;
21
+ }
22
+
23
+ var qualityHtml = "<div class=\"quality-components\">\n <div class=\"current-quality\" data-ref=\"\"></div>\n <ul class=\"quality-list\">\n </ul>\n</div>";
24
+ var qualityModal = "<div class=\"quality-modal\">\n <span class=\"switchimg\"></span> <span class=\"current-quality-tag\"></span> , <span class=\"wait\"></span>\n</div>";
25
+ /**
26
+ * 切换清晰度组件
27
+ */
28
+
29
+ var QualityComponent =
30
+ /** @class */
31
+ function () {
32
+ function QualityComponent(getQuality) {
33
+ this.html = parseDom(qualityHtml);
34
+ this.modalHtml = parseDom(qualityModal);
35
+ this.hasCreated = false;
36
+ this.definition = '';
37
+ this.getQuality = getQuality;
38
+ }
39
+
40
+ QualityComponent.prototype.createEl = function (el, player) {
41
+ var lang = player._options && player._options.language;
42
+ this.isEn = lang && lang === 'en-us';
43
+ this.html.querySelector('.current-quality').innerText = this.isEn ? 'Resolution' : '清晰度';
44
+ this.modalHtml.querySelector('.switchimg').innerText = this.isEn ? 'Switching to you for' : '正在为您切换到';
45
+ this.modalHtml.querySelector('.wait').innerText = this.isEn ? 'Please wait...' : '请稍后...';
46
+ var eleControlbar = el.querySelector('.prism-controlbar');
47
+ eleControlbar.appendChild(this.html);
48
+ el.appendChild(this.modalHtml);
49
+ };
50
+
51
+ QualityComponent.prototype.setCurrentQuality = function (quality, def) {
52
+ var currentQuality = this.html.querySelector('.current-quality');
53
+ currentQuality.innerText = quality;
54
+ currentQuality.dataset.def = def;
55
+ this.definition = def;
56
+ var qualityListEle = this.html.querySelector('.quality-list');
57
+ var currentEle = qualityListEle.querySelector('.current');
58
+
59
+ if (currentEle) {
60
+ currentEle.className = '';
61
+ }
62
+
63
+ var liTarget = qualityListEle.querySelector("li[data-def=\"" + def + "\"]");
64
+
65
+ if (liTarget) {
66
+ liTarget.className = 'current';
67
+ }
68
+ };
69
+
70
+ QualityComponent.prototype.created = function (player) {
71
+ var _this = this;
72
+
73
+ this._urls = player._urls;
74
+ var currentQualityEle = this.html.querySelector('.current-quality');
75
+ var qualityListEle = this.html.querySelector('.quality-list');
76
+
77
+ var lisEle = this._urls.map(function (url) {
78
+ return "<li data-def=\"" + url.definition + "\">" + url.desc + "</li>";
79
+ });
80
+
81
+ this.html.querySelector('.quality-list').innerHTML = lisEle.join('');
82
+ console.log(this.definition);
83
+
84
+ if (this.hasCreated == false && this.definition) {
85
+ var liTarget = qualityListEle.querySelector("li[data-def=\"" + this.definition + "\"]");
86
+ liTarget.className = 'current';
87
+ }
88
+
89
+ this.hasCreated = true;
90
+ var timeId = null;
91
+
92
+ currentQualityEle.onclick = function () {
93
+ var listVisible = qualityListEle.style.display !== 'none';
94
+
95
+ if (listVisible) {
96
+ qualityListEle.style.display = 'none';
97
+ } else {
98
+ qualityListEle.style.display = 'block';
99
+ }
100
+ };
101
+
102
+ currentQualityEle.onmouseleave = function () {
103
+ if (timeId) clearTimeout(timeId);
104
+ timeId = setTimeout(function () {
105
+ qualityListEle.style.display = 'none';
106
+ }, 150);
107
+ };
108
+
109
+ qualityListEle.onmouseenter = function () {
110
+ clearTimeout(timeId);
111
+ };
112
+
113
+ qualityListEle.onmouseleave = function () {
114
+ if (timeId) clearTimeout(timeId);
115
+ timeId = setTimeout(function () {
116
+ qualityListEle.style.display = 'none';
117
+ }, 150);
118
+ };
119
+
120
+ qualityListEle.onclick = function (_a) {
121
+ var target = _a.target;
122
+ var definition = target.dataset.def;
123
+ var desc = target.innerText;
124
+
125
+ if (definition && target.className !== 'current') {
126
+ var url = _this._urls.find(function (url) {
127
+ return url.definition === definition;
128
+ });
129
+
130
+ if (url) {
131
+ cookieSet('selectedStreamLevel', url.definition, 365);
132
+
133
+ if (player._switchLevel && !player._options.isLive) {
134
+ player._switchLevel(url.Url);
135
+ } else {
136
+ player._loadByUrlInner(url.Url, player.getCurrentTime(), true
137
+ /* autoPlay */
138
+ , true
139
+ /* isSwitchLevel */
140
+ );
141
+ }
142
+
143
+ _this.setCurrentQuality(url.desc, url.definition);
144
+
145
+ _this.modalHtml.style.display = 'block';
146
+ _this.modalHtml.querySelector('span.current-quality-tag').innerText = url.desc;
147
+ }
148
+ } // 点击切换清晰度时,调用这个方法
149
+
150
+
151
+ _this.getQuality(definition, desc);
152
+ };
153
+ };
154
+
155
+ QualityComponent.prototype.ready = function (player) {
156
+ this.modalHtml.style.display = 'none'; // 隐藏设置里面的倍速播放
157
+
158
+ var settingEle = document.querySelector('.prism-setting-item.prism-setting-quality');
159
+
160
+ if (settingEle) {
161
+ settingEle.classList.add('player-hidden');
162
+ }
163
+ };
164
+
165
+ return QualityComponent;
166
+ }();
167
+
168
+ var _default = QualityComponent;
169
+ exports["default"] = _default;
@@ -0,0 +1,78 @@
1
+ .player-hidden {
2
+ display: none !important;
3
+ }
4
+
5
+ .quality-components {
6
+ float: right;
7
+ color: #fff;
8
+ height: 35px;
9
+ position: relative;
10
+ box-sizing: border-box;
11
+ margin-top: 4px;
12
+ }
13
+
14
+ .current-quality {
15
+ display: flex;
16
+ height: 100%;
17
+ align-items: center;
18
+ justify-content: center;
19
+ // width: 70px;
20
+ cursor: pointer;
21
+ }
22
+
23
+ .quality-list {
24
+ position: absolute;
25
+ bottom: 46px;
26
+ display: none;
27
+ padding: 0;
28
+ margin: 0;
29
+ list-style: none;
30
+
31
+ li {
32
+ text-align: center;
33
+ // width: 70px;
34
+ line-height: 30px;
35
+ background-color: rgba(0, 0, 0, .6);
36
+ cursor: pointer;
37
+
38
+ &.current {
39
+ color: #00c1de;
40
+ }
41
+
42
+ &+li {
43
+ border-top: 1px solid rgba(78, 78, 78, 0.3);
44
+ }
45
+
46
+ &:hover {
47
+ background-color: rgba(0, 0, 0, .5);
48
+ }
49
+
50
+ ;
51
+ }
52
+ }
53
+
54
+ .quality-modal {
55
+ position: absolute;
56
+ bottom: 20%;
57
+ left: 5%;
58
+ background-color: rgba(0, 0, 0, .6);
59
+ border-radius: 5px;
60
+ color: #fff;
61
+ padding: 10px 15px;
62
+ font-size: 14px;
63
+ display: none;
64
+
65
+ span.current-quality-tag {
66
+ color: #00c1de;
67
+ }
68
+ }
69
+
70
+ @media(max-width: 768px) {
71
+ .current-quality {
72
+ width: 40px;
73
+ }
74
+
75
+ .quality-list li {
76
+ width: 45px;
77
+ }
78
+ }
@@ -7,7 +7,9 @@ exports["default"] = exports.createVideoModal = void 0;
7
7
 
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
 
10
- var _components = _interopRequireDefault(require("./components"));
10
+ var _index = _interopRequireDefault(require("./RateComponent/index"));
11
+
12
+ var _index2 = _interopRequireDefault(require("./QualityComponent/index"));
11
13
 
12
14
  var _closeImg = _interopRequireDefault(require("./closeImg.png"));
13
15
 
@@ -267,95 +269,149 @@ var createAliVideo = function createAliVideo(domId, opts) {
267
269
  }
268
270
 
269
271
  return new Promise(function (resolve) {
270
- var _window$Aliplayer;
271
-
272
- var skinLayout = [{
273
- name: 'H5Loading',
274
- align: 'cc'
275
- }, {
276
- name: 'errorDisplay',
277
- align: 'tlabs',
278
- x: 0,
279
- y: 0
280
- }, {
281
- name: 'tooltip',
282
- align: 'blabs',
283
- x: 0,
284
- y: 56
285
- }, {
286
- name: 'thumbnail'
287
- }];
288
- var controlBar = {
289
- name: 'controlBar',
290
- align: 'blabs',
291
- x: 0,
292
- y: 0,
293
- children: [{
294
- name: 'playButton',
295
- align: 'tl',
296
- x: 15,
297
- y: 12
298
- }, {
299
- name: 'timeDisplay',
300
- align: 'tl',
301
- x: 10,
302
- y: 7
303
- }, {
304
- name: 'volume',
305
- align: 'tr',
306
- x: 5,
307
- y: 10
308
- }, {
309
- name: 'fullScreenButton',
310
- align: 'tr',
311
- x: 10,
312
- y: 12
313
- }]
314
- };
315
- skinLayout.push(controlBar);
316
-
317
- if (opts.progressBar) {
318
- controlBar.children.push({
319
- name: 'progress',
320
- align: 'blabs',
321
- x: 0,
322
- y: 10
323
- });
324
- }
272
+ return __awaiter(void 0, void 0, void 0, function () {
273
+ var components, res, qualitySource, source, skinLayout, controlBar;
274
+ return __generator(this, function (_a) {
275
+ var _window$Aliplayer;
325
276
 
326
- new window.Aliplayer((_window$Aliplayer = {
327
- id: 'video' + domId,
328
- source: opts.source,
329
- cover: opts.cover,
330
- width: '100%',
331
- height: '100%',
332
- autoplay: false,
333
- isLive: false,
334
- rePlay: false,
335
- playsinline: true,
336
- preload: true,
337
- controlBarVisibility: 'hover',
338
- useH5Prism: true,
339
- skinLayout: skinLayout
340
- }, _defineProperty(_window$Aliplayer, "autoplay", opts.autoplay), _defineProperty(_window$Aliplayer, "rePlay", opts.loop), _defineProperty(_window$Aliplayer, "components", [{
341
- name: 'RateComponent',
342
- type: _components["default"]
343
- }]), _window$Aliplayer), function (player) {
344
- if (!opts.videoSound) {
345
- player.setVolume(0);
346
- }
277
+ switch (_a.label) {
278
+ case 0:
279
+ components = [{
280
+ name: 'RateComponent',
281
+ type: _index["default"]
282
+ }];
283
+ return [4
284
+ /*yield*/
285
+ , (0, _commonUtil.commonFetch)('/designer/v1/content/' + opts.sourceId, {}, 'GET')];
347
286
 
348
- if (opts.speed) {
349
- var speed = Number(opts.speed).toFixed(1);
350
- player.setSpeed(speed);
351
- player._speed = speed;
352
- }
287
+ case 1:
288
+ res = _a.sent();
289
+ qualitySource = {};
290
+ source = opts.source;
353
291
 
354
- if (opts.startAt) {
355
- player.seek(opts.startAt);
356
- }
292
+ if (res.smallImgUrl) {
293
+ qualitySource['480P'] = res.smallImgUrl;
294
+ }
295
+
296
+ if (res.url) {
297
+ qualitySource['720P'] = res.url;
298
+ }
299
+
300
+ if (res.bigImgUrl) {
301
+ qualitySource['1080P'] = res.bigImgUrl;
302
+ }
357
303
 
358
- resolve(player);
304
+ if (Object.keys(qualitySource).length) {
305
+ source = JSON.stringify(qualitySource);
306
+ components.push({
307
+ name: 'QualityComponent',
308
+ type: _index2["default"]
309
+ });
310
+ }
311
+
312
+ skinLayout = [{
313
+ name: 'H5Loading',
314
+ align: 'cc'
315
+ }, {
316
+ name: 'errorDisplay',
317
+ align: 'tlabs',
318
+ x: 0,
319
+ y: 0
320
+ }, {
321
+ name: 'tooltip',
322
+ align: 'blabs',
323
+ x: 0,
324
+ y: 56
325
+ }, {
326
+ name: 'thumbnail'
327
+ }];
328
+ controlBar = {
329
+ name: 'controlBar',
330
+ align: 'blabs',
331
+ x: 0,
332
+ y: 0,
333
+ children: [{
334
+ name: 'playButton',
335
+ align: 'tl',
336
+ x: 15,
337
+ y: 12
338
+ }, {
339
+ name: 'timeDisplay',
340
+ align: 'tl',
341
+ x: 10,
342
+ y: 7
343
+ }, {
344
+ name: 'volume',
345
+ align: 'tr',
346
+ x: 5,
347
+ y: 10
348
+ }, {
349
+ name: 'fullScreenButton',
350
+ align: 'tr',
351
+ x: 10,
352
+ y: 12
353
+ }]
354
+ };
355
+ skinLayout.push(controlBar);
356
+
357
+ if (opts.progressBar) {
358
+ controlBar.children.push({
359
+ name: 'progress',
360
+ align: 'blabs',
361
+ x: 0,
362
+ y: 10
363
+ });
364
+ }
365
+
366
+ console.log('source: ', source);
367
+ new window.Aliplayer((_window$Aliplayer = {
368
+ id: 'video' + domId,
369
+ source: source,
370
+ cover: opts.cover,
371
+ width: '100%',
372
+ height: '100%',
373
+ autoplay: false,
374
+ isLive: false,
375
+ rePlay: false,
376
+ playsinline: true,
377
+ preload: true,
378
+ controlBarVisibility: 'hover',
379
+ useH5Prism: true,
380
+ skinLayout: skinLayout
381
+ }, _defineProperty(_window$Aliplayer, "autoplay", opts.autoplay), _defineProperty(_window$Aliplayer, "rePlay", opts.loop), _defineProperty(_window$Aliplayer, "components", components), _window$Aliplayer), function (player) {
382
+ if (!opts.videoSound) {
383
+ player.setVolume(0);
384
+ }
385
+
386
+ if (opts.speed) {
387
+ var speed = Number(opts.speed).toFixed(1);
388
+ player.setSpeed(speed);
389
+ player._speed = speed;
390
+ }
391
+
392
+ if (opts.startAt) {
393
+ player.seek(opts.startAt);
394
+ }
395
+
396
+ if (Object.keys(qualitySource).length) {
397
+ var defaultKey = Object.keys(qualitySource)[0];
398
+
399
+ if (qualitySource['720P']) {
400
+ defaultKey = '720P';
401
+ } else {
402
+ defaultKey = '480P';
403
+ }
404
+
405
+ player.getComponent('QualityComponent').setCurrentQuality(defaultKey, defaultKey);
406
+ }
407
+
408
+ resolve(player);
409
+ });
410
+ return [2
411
+ /*return*/
412
+ ];
413
+ }
414
+ });
359
415
  });
360
416
  });
361
417
  };
@@ -67,7 +67,7 @@ function (_super) {
67
67
  });
68
68
 
69
69
  if ((data === null || data === void 0 ? void 0 : data.length) > 0) {
70
- _this.props.onChange(data[0].url, data[0].contentTitle);
70
+ _this.props.onChange(data[0].url, data[0].contentTitle, data[0].contentId);
71
71
  }
72
72
  };
73
73
 
@@ -219,8 +219,10 @@ function (_super) {
219
219
  size: "20px",
220
220
  type: "icon-delete1"
221
221
  })))), panelProps.video.sourceType === 'Upload' && /*#__PURE__*/_react["default"].createElement(_common.VideoUpload, {
222
- onChange: function onChange(v) {
222
+ onChange: function onChange(v, n, id) {
223
223
  panelProps.video.sourceUrl = v;
224
+ panelProps.video.sourceName = n;
225
+ panelProps.video.sourceId = id;
224
226
 
225
227
  _this.reRender();
226
228
  },
@@ -71,7 +71,7 @@ function (_super) {
71
71
  value: /*#__PURE__*/_react["default"].createElement(_ImageConfig["default"], {
72
72
  data: panelProps.image,
73
73
  needHover: false,
74
- onlySpecificCode: "FunctionPage"
74
+ onlySpecificCode: ['CustomizedPage', 'FunctionPage']
75
75
  }),
76
76
  metaOption: panelProps.image
77
77
  }];
@@ -71,7 +71,7 @@ function (_super) {
71
71
  value: /*#__PURE__*/_react["default"].createElement(_ImageConfig["default"], {
72
72
  data: panelProps.image,
73
73
  needClickArea: false,
74
- onlySpecificCode: "FunctionPage"
74
+ onlySpecificCode: ['CustomizedPage', 'FunctionPage']
75
75
  }),
76
76
  metaOption: panelProps.image
77
77
  }];
@@ -55,11 +55,14 @@ function shouldUpdate() {
55
55
  descriptor.value = function (nextProps, nextState) {
56
56
  var nowPropsJson = JSON.stringify(nextProps);
57
57
  var nowStateJson = JSON.stringify(nextState);
58
+ var nowDevice = window.magicDesign.device;
58
59
  var should1 = nowPropsJson != this.preProps;
59
60
  var should2 = nowStateJson != this.preState;
61
+ var should3 = nowDevice != this.preDevice;
60
62
  this.preProps = nowPropsJson;
61
63
  this.preState = nowStateJson;
62
- var result = should1 || should2;
64
+ this.preDevice = nowDevice;
65
+ var result = should1 || should2 || should3;
63
66
  return result && fn.apply(this, {
64
67
  nextProps: nextProps
65
68
  });
@@ -128,10 +128,11 @@ function (_super) {
128
128
  size: "20px",
129
129
  type: "icon-delete1"
130
130
  })))), this.videoSetting.sourceType === 'Upload' && /*#__PURE__*/_react["default"].createElement(_VideoUpload["default"], {
131
- onChange: function onChange(v, n) {
131
+ onChange: function onChange(v, n, id) {
132
132
  _this.onFieldChange({
133
133
  sourceUrl: v,
134
- name: n
134
+ name: n,
135
+ sourceId: id
135
136
  });
136
137
  },
137
138
  value: this.videoSetting.sourceUrl
@@ -234,7 +234,7 @@ var LinkModal = function LinkModal(props) {
234
234
 
235
235
  var getLinkTypes = function getLinkTypes() {
236
236
  return __awaiter(void 0, void 0, void 0, function () {
237
- var types, type;
237
+ var types, type_1;
238
238
  return __generator(this, function (_a) {
239
239
  switch (_a.label) {
240
240
  case 0:
@@ -248,12 +248,15 @@ var LinkModal = function LinkModal(props) {
248
248
  types = _a.sent();
249
249
 
250
250
  if (onlySpecificCode) {
251
- type = types.filter(function (item) {
252
- return item.linkTypeCode === onlySpecificCode;
251
+ type_1 = [];
252
+ onlySpecificCode.forEach(function (code) {
253
+ type_1.push(types.find(function (item) {
254
+ return item.linkTypeCode === code;
255
+ }));
253
256
  });
254
257
 
255
- if (type.length > 0) {
256
- types = type;
258
+ if (type_1.length > 0) {
259
+ types = type_1;
257
260
  }
258
261
  }
259
262
 
@@ -0,0 +1,169 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+
8
+ require("./index.less");
9
+
10
+ function parseDom(html) {
11
+ var ele = document.createElement('div');
12
+ ele.innerHTML = html;
13
+ return ele.childNodes[0];
14
+ }
15
+
16
+ function cookieSet(cname, cvalue, exdays) {
17
+ var d = new Date();
18
+ d.setTime(d.getTime() + exdays * 24 * 60 * 60 * 1000);
19
+ var expires = 'expires=' + d.toGMTString();
20
+ document.cookie = cname + '=' + escape(cvalue) + '; ' + expires;
21
+ }
22
+
23
+ var qualityHtml = "<div class=\"quality-components\">\n <div class=\"current-quality\" data-ref=\"\"></div>\n <ul class=\"quality-list\">\n </ul>\n</div>";
24
+ var qualityModal = "<div class=\"quality-modal\">\n <span class=\"switchimg\"></span> <span class=\"current-quality-tag\"></span> , <span class=\"wait\"></span>\n</div>";
25
+ /**
26
+ * 切换清晰度组件
27
+ */
28
+
29
+ var QualityComponent =
30
+ /** @class */
31
+ function () {
32
+ function QualityComponent(getQuality) {
33
+ this.html = parseDom(qualityHtml);
34
+ this.modalHtml = parseDom(qualityModal);
35
+ this.hasCreated = false;
36
+ this.definition = '';
37
+ this.getQuality = getQuality;
38
+ }
39
+
40
+ QualityComponent.prototype.createEl = function (el, player) {
41
+ var lang = player._options && player._options.language;
42
+ this.isEn = lang && lang === 'en-us';
43
+ this.html.querySelector('.current-quality').innerText = this.isEn ? 'Resolution' : '清晰度';
44
+ this.modalHtml.querySelector('.switchimg').innerText = this.isEn ? 'Switching to you for' : '正在为您切换到';
45
+ this.modalHtml.querySelector('.wait').innerText = this.isEn ? 'Please wait...' : '请稍后...';
46
+ var eleControlbar = el.querySelector('.prism-controlbar');
47
+ eleControlbar.appendChild(this.html);
48
+ el.appendChild(this.modalHtml);
49
+ };
50
+
51
+ QualityComponent.prototype.setCurrentQuality = function (quality, def) {
52
+ var currentQuality = this.html.querySelector('.current-quality');
53
+ currentQuality.innerText = quality;
54
+ currentQuality.dataset.def = def;
55
+ this.definition = def;
56
+ var qualityListEle = this.html.querySelector('.quality-list');
57
+ var currentEle = qualityListEle.querySelector('.current');
58
+
59
+ if (currentEle) {
60
+ currentEle.className = '';
61
+ }
62
+
63
+ var liTarget = qualityListEle.querySelector("li[data-def=\"" + def + "\"]");
64
+
65
+ if (liTarget) {
66
+ liTarget.className = 'current';
67
+ }
68
+ };
69
+
70
+ QualityComponent.prototype.created = function (player) {
71
+ var _this = this;
72
+
73
+ this._urls = player._urls;
74
+ var currentQualityEle = this.html.querySelector('.current-quality');
75
+ var qualityListEle = this.html.querySelector('.quality-list');
76
+
77
+ var lisEle = this._urls.map(function (url) {
78
+ return "<li data-def=\"" + url.definition + "\">" + url.desc + "</li>";
79
+ });
80
+
81
+ this.html.querySelector('.quality-list').innerHTML = lisEle.join('');
82
+ console.log(this.definition);
83
+
84
+ if (this.hasCreated == false && this.definition) {
85
+ var liTarget = qualityListEle.querySelector("li[data-def=\"" + this.definition + "\"]");
86
+ liTarget.className = 'current';
87
+ }
88
+
89
+ this.hasCreated = true;
90
+ var timeId = null;
91
+
92
+ currentQualityEle.onclick = function () {
93
+ var listVisible = qualityListEle.style.display !== 'none';
94
+
95
+ if (listVisible) {
96
+ qualityListEle.style.display = 'none';
97
+ } else {
98
+ qualityListEle.style.display = 'block';
99
+ }
100
+ };
101
+
102
+ currentQualityEle.onmouseleave = function () {
103
+ if (timeId) clearTimeout(timeId);
104
+ timeId = setTimeout(function () {
105
+ qualityListEle.style.display = 'none';
106
+ }, 150);
107
+ };
108
+
109
+ qualityListEle.onmouseenter = function () {
110
+ clearTimeout(timeId);
111
+ };
112
+
113
+ qualityListEle.onmouseleave = function () {
114
+ if (timeId) clearTimeout(timeId);
115
+ timeId = setTimeout(function () {
116
+ qualityListEle.style.display = 'none';
117
+ }, 150);
118
+ };
119
+
120
+ qualityListEle.onclick = function (_a) {
121
+ var target = _a.target;
122
+ var definition = target.dataset.def;
123
+ var desc = target.innerText;
124
+
125
+ if (definition && target.className !== 'current') {
126
+ var url = _this._urls.find(function (url) {
127
+ return url.definition === definition;
128
+ });
129
+
130
+ if (url) {
131
+ cookieSet('selectedStreamLevel', url.definition, 365);
132
+
133
+ if (player._switchLevel && !player._options.isLive) {
134
+ player._switchLevel(url.Url);
135
+ } else {
136
+ player._loadByUrlInner(url.Url, player.getCurrentTime(), true
137
+ /* autoPlay */
138
+ , true
139
+ /* isSwitchLevel */
140
+ );
141
+ }
142
+
143
+ _this.setCurrentQuality(url.desc, url.definition);
144
+
145
+ _this.modalHtml.style.display = 'block';
146
+ _this.modalHtml.querySelector('span.current-quality-tag').innerText = url.desc;
147
+ }
148
+ } // 点击切换清晰度时,调用这个方法
149
+
150
+
151
+ _this.getQuality(definition, desc);
152
+ };
153
+ };
154
+
155
+ QualityComponent.prototype.ready = function (player) {
156
+ this.modalHtml.style.display = 'none'; // 隐藏设置里面的倍速播放
157
+
158
+ var settingEle = document.querySelector('.prism-setting-item.prism-setting-quality');
159
+
160
+ if (settingEle) {
161
+ settingEle.classList.add('player-hidden');
162
+ }
163
+ };
164
+
165
+ return QualityComponent;
166
+ }();
167
+
168
+ var _default = QualityComponent;
169
+ exports["default"] = _default;
@@ -0,0 +1,78 @@
1
+ .player-hidden {
2
+ display: none !important;
3
+ }
4
+
5
+ .quality-components {
6
+ float: right;
7
+ color: #fff;
8
+ height: 35px;
9
+ position: relative;
10
+ box-sizing: border-box;
11
+ margin-top: 4px;
12
+ }
13
+
14
+ .current-quality {
15
+ display: flex;
16
+ height: 100%;
17
+ align-items: center;
18
+ justify-content: center;
19
+ // width: 70px;
20
+ cursor: pointer;
21
+ }
22
+
23
+ .quality-list {
24
+ position: absolute;
25
+ bottom: 46px;
26
+ display: none;
27
+ padding: 0;
28
+ margin: 0;
29
+ list-style: none;
30
+
31
+ li {
32
+ text-align: center;
33
+ // width: 70px;
34
+ line-height: 30px;
35
+ background-color: rgba(0, 0, 0, .6);
36
+ cursor: pointer;
37
+
38
+ &.current {
39
+ color: #00c1de;
40
+ }
41
+
42
+ &+li {
43
+ border-top: 1px solid rgba(78, 78, 78, 0.3);
44
+ }
45
+
46
+ &:hover {
47
+ background-color: rgba(0, 0, 0, .5);
48
+ }
49
+
50
+ ;
51
+ }
52
+ }
53
+
54
+ .quality-modal {
55
+ position: absolute;
56
+ bottom: 20%;
57
+ left: 5%;
58
+ background-color: rgba(0, 0, 0, .6);
59
+ border-radius: 5px;
60
+ color: #fff;
61
+ padding: 10px 15px;
62
+ font-size: 14px;
63
+ display: none;
64
+
65
+ span.current-quality-tag {
66
+ color: #00c1de;
67
+ }
68
+ }
69
+
70
+ @media(max-width: 768px) {
71
+ .current-quality {
72
+ width: 40px;
73
+ }
74
+
75
+ .quality-list li {
76
+ width: 45px;
77
+ }
78
+ }
@@ -7,7 +7,9 @@ exports["default"] = exports.createVideoModal = void 0;
7
7
 
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
 
10
- var _components = _interopRequireDefault(require("./components"));
10
+ var _index = _interopRequireDefault(require("./RateComponent/index"));
11
+
12
+ var _index2 = _interopRequireDefault(require("./QualityComponent/index"));
11
13
 
12
14
  var _closeImg = _interopRequireDefault(require("./closeImg.png"));
13
15
 
@@ -267,95 +269,149 @@ var createAliVideo = function createAliVideo(domId, opts) {
267
269
  }
268
270
 
269
271
  return new Promise(function (resolve) {
270
- var _window$Aliplayer;
271
-
272
- var skinLayout = [{
273
- name: 'H5Loading',
274
- align: 'cc'
275
- }, {
276
- name: 'errorDisplay',
277
- align: 'tlabs',
278
- x: 0,
279
- y: 0
280
- }, {
281
- name: 'tooltip',
282
- align: 'blabs',
283
- x: 0,
284
- y: 56
285
- }, {
286
- name: 'thumbnail'
287
- }];
288
- var controlBar = {
289
- name: 'controlBar',
290
- align: 'blabs',
291
- x: 0,
292
- y: 0,
293
- children: [{
294
- name: 'playButton',
295
- align: 'tl',
296
- x: 15,
297
- y: 12
298
- }, {
299
- name: 'timeDisplay',
300
- align: 'tl',
301
- x: 10,
302
- y: 7
303
- }, {
304
- name: 'volume',
305
- align: 'tr',
306
- x: 5,
307
- y: 10
308
- }, {
309
- name: 'fullScreenButton',
310
- align: 'tr',
311
- x: 10,
312
- y: 12
313
- }]
314
- };
315
- skinLayout.push(controlBar);
316
-
317
- if (opts.progressBar) {
318
- controlBar.children.push({
319
- name: 'progress',
320
- align: 'blabs',
321
- x: 0,
322
- y: 10
323
- });
324
- }
272
+ return __awaiter(void 0, void 0, void 0, function () {
273
+ var components, res, qualitySource, source, skinLayout, controlBar;
274
+ return __generator(this, function (_a) {
275
+ var _window$Aliplayer;
325
276
 
326
- new window.Aliplayer((_window$Aliplayer = {
327
- id: 'video' + domId,
328
- source: opts.source,
329
- cover: opts.cover,
330
- width: '100%',
331
- height: '100%',
332
- autoplay: false,
333
- isLive: false,
334
- rePlay: false,
335
- playsinline: true,
336
- preload: true,
337
- controlBarVisibility: 'hover',
338
- useH5Prism: true,
339
- skinLayout: skinLayout
340
- }, _defineProperty(_window$Aliplayer, "autoplay", opts.autoplay), _defineProperty(_window$Aliplayer, "rePlay", opts.loop), _defineProperty(_window$Aliplayer, "components", [{
341
- name: 'RateComponent',
342
- type: _components["default"]
343
- }]), _window$Aliplayer), function (player) {
344
- if (!opts.videoSound) {
345
- player.setVolume(0);
346
- }
277
+ switch (_a.label) {
278
+ case 0:
279
+ components = [{
280
+ name: 'RateComponent',
281
+ type: _index["default"]
282
+ }];
283
+ return [4
284
+ /*yield*/
285
+ , (0, _commonUtil.commonFetch)('/designer/v1/content/' + opts.sourceId, {}, 'GET')];
347
286
 
348
- if (opts.speed) {
349
- var speed = Number(opts.speed).toFixed(1);
350
- player.setSpeed(speed);
351
- player._speed = speed;
352
- }
287
+ case 1:
288
+ res = _a.sent();
289
+ qualitySource = {};
290
+ source = opts.source;
353
291
 
354
- if (opts.startAt) {
355
- player.seek(opts.startAt);
356
- }
292
+ if (res.smallImgUrl) {
293
+ qualitySource['480P'] = res.smallImgUrl;
294
+ }
295
+
296
+ if (res.url) {
297
+ qualitySource['720P'] = res.url;
298
+ }
299
+
300
+ if (res.bigImgUrl) {
301
+ qualitySource['1080P'] = res.bigImgUrl;
302
+ }
357
303
 
358
- resolve(player);
304
+ if (Object.keys(qualitySource).length) {
305
+ source = JSON.stringify(qualitySource);
306
+ components.push({
307
+ name: 'QualityComponent',
308
+ type: _index2["default"]
309
+ });
310
+ }
311
+
312
+ skinLayout = [{
313
+ name: 'H5Loading',
314
+ align: 'cc'
315
+ }, {
316
+ name: 'errorDisplay',
317
+ align: 'tlabs',
318
+ x: 0,
319
+ y: 0
320
+ }, {
321
+ name: 'tooltip',
322
+ align: 'blabs',
323
+ x: 0,
324
+ y: 56
325
+ }, {
326
+ name: 'thumbnail'
327
+ }];
328
+ controlBar = {
329
+ name: 'controlBar',
330
+ align: 'blabs',
331
+ x: 0,
332
+ y: 0,
333
+ children: [{
334
+ name: 'playButton',
335
+ align: 'tl',
336
+ x: 15,
337
+ y: 12
338
+ }, {
339
+ name: 'timeDisplay',
340
+ align: 'tl',
341
+ x: 10,
342
+ y: 7
343
+ }, {
344
+ name: 'volume',
345
+ align: 'tr',
346
+ x: 5,
347
+ y: 10
348
+ }, {
349
+ name: 'fullScreenButton',
350
+ align: 'tr',
351
+ x: 10,
352
+ y: 12
353
+ }]
354
+ };
355
+ skinLayout.push(controlBar);
356
+
357
+ if (opts.progressBar) {
358
+ controlBar.children.push({
359
+ name: 'progress',
360
+ align: 'blabs',
361
+ x: 0,
362
+ y: 10
363
+ });
364
+ }
365
+
366
+ console.log('source: ', source);
367
+ new window.Aliplayer((_window$Aliplayer = {
368
+ id: 'video' + domId,
369
+ source: source,
370
+ cover: opts.cover,
371
+ width: '100%',
372
+ height: '100%',
373
+ autoplay: false,
374
+ isLive: false,
375
+ rePlay: false,
376
+ playsinline: true,
377
+ preload: true,
378
+ controlBarVisibility: 'hover',
379
+ useH5Prism: true,
380
+ skinLayout: skinLayout
381
+ }, _defineProperty(_window$Aliplayer, "autoplay", opts.autoplay), _defineProperty(_window$Aliplayer, "rePlay", opts.loop), _defineProperty(_window$Aliplayer, "components", components), _window$Aliplayer), function (player) {
382
+ if (!opts.videoSound) {
383
+ player.setVolume(0);
384
+ }
385
+
386
+ if (opts.speed) {
387
+ var speed = Number(opts.speed).toFixed(1);
388
+ player.setSpeed(speed);
389
+ player._speed = speed;
390
+ }
391
+
392
+ if (opts.startAt) {
393
+ player.seek(opts.startAt);
394
+ }
395
+
396
+ if (Object.keys(qualitySource).length) {
397
+ var defaultKey = Object.keys(qualitySource)[0];
398
+
399
+ if (qualitySource['720P']) {
400
+ defaultKey = '720P';
401
+ } else {
402
+ defaultKey = '480P';
403
+ }
404
+
405
+ player.getComponent('QualityComponent').setCurrentQuality(defaultKey, defaultKey);
406
+ }
407
+
408
+ resolve(player);
409
+ });
410
+ return [2
411
+ /*return*/
412
+ ];
413
+ }
414
+ });
359
415
  });
360
416
  });
361
417
  };
@@ -67,7 +67,7 @@ function (_super) {
67
67
  });
68
68
 
69
69
  if ((data === null || data === void 0 ? void 0 : data.length) > 0) {
70
- _this.props.onChange(data[0].url, data[0].contentTitle);
70
+ _this.props.onChange(data[0].url, data[0].contentTitle, data[0].contentId);
71
71
  }
72
72
  };
73
73
 
@@ -219,8 +219,10 @@ function (_super) {
219
219
  size: "20px",
220
220
  type: "icon-delete1"
221
221
  })))), panelProps.video.sourceType === 'Upload' && /*#__PURE__*/_react["default"].createElement(_common.VideoUpload, {
222
- onChange: function onChange(v) {
222
+ onChange: function onChange(v, n, id) {
223
223
  panelProps.video.sourceUrl = v;
224
+ panelProps.video.sourceName = n;
225
+ panelProps.video.sourceId = id;
224
226
 
225
227
  _this.reRender();
226
228
  },
@@ -71,7 +71,7 @@ function (_super) {
71
71
  value: /*#__PURE__*/_react["default"].createElement(_ImageConfig["default"], {
72
72
  data: panelProps.image,
73
73
  needHover: false,
74
- onlySpecificCode: "FunctionPage"
74
+ onlySpecificCode: ['CustomizedPage', 'FunctionPage']
75
75
  }),
76
76
  metaOption: panelProps.image
77
77
  }];
@@ -71,7 +71,7 @@ function (_super) {
71
71
  value: /*#__PURE__*/_react["default"].createElement(_ImageConfig["default"], {
72
72
  data: panelProps.image,
73
73
  needClickArea: false,
74
- onlySpecificCode: "FunctionPage"
74
+ onlySpecificCode: ['CustomizedPage', 'FunctionPage']
75
75
  }),
76
76
  metaOption: panelProps.image
77
77
  }];
@@ -55,11 +55,14 @@ function shouldUpdate() {
55
55
  descriptor.value = function (nextProps, nextState) {
56
56
  var nowPropsJson = JSON.stringify(nextProps);
57
57
  var nowStateJson = JSON.stringify(nextState);
58
+ var nowDevice = window.magicDesign.device;
58
59
  var should1 = nowPropsJson != this.preProps;
59
60
  var should2 = nowStateJson != this.preState;
61
+ var should3 = nowDevice != this.preDevice;
60
62
  this.preProps = nowPropsJson;
61
63
  this.preState = nowStateJson;
62
- var result = should1 || should2;
64
+ this.preDevice = nowDevice;
65
+ var result = should1 || should2 || should3;
63
66
  return result && fn.apply(this, {
64
67
  nextProps: nextProps
65
68
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@fonixtree/magic-design",
3
3
  "author": "Cylon Team",
4
- "version": "2.0.88",
4
+ "version": "2.0.90",
5
5
  "description": "Magic Design",
6
6
  "license": "MIT",
7
7
  "module": "es/index.js",