wargerm 0.4.22 → 0.4.23
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/dist/components/Video/example/VideoDemo/demo1.d.ts +3 -0
- package/dist/components/Video/example/VideoDemo/demo2.d.ts +3 -0
- package/dist/components/Video/example/VideoDemo/demo3.d.ts +3 -0
- package/dist/components/Video/example/VideoDemo/demo4.d.ts +3 -0
- package/dist/components/Video/example/VideoDemo/demo5.d.ts +3 -0
- package/dist/components/Video/example/VideoDemo/demo6.d.ts +3 -0
- package/dist/components/Video/example/VideoDemo/demo7.d.ts +3 -0
- package/dist/components/Video/example/VideoDemo/demo8.d.ts +3 -0
- package/dist/components/Video/example/VideoDemo/demo9.d.ts +3 -0
- package/dist/components/Video/index.d.ts +35 -0
- package/dist/index.css +9 -9
- package/dist/index.d.ts +1 -1
- package/dist/index.esm.css +9 -9
- package/dist/index.esm.js +252 -180
- package/dist/index.js +251 -179
- package/package.json +1 -1
- package/dist/components/VirtualList/index.d.ts +0 -35
- package/dist/global.d.ts +0 -1
package/dist/index.esm.js
CHANGED
@@ -4,7 +4,7 @@ import 'antd/es/dropdown/style';
|
|
4
4
|
import _Dropdown from 'antd/es/dropdown';
|
5
5
|
import 'antd/es/menu/style';
|
6
6
|
import _Menu from 'antd/es/menu';
|
7
|
-
import React, { memo, useState, useEffect, useMemo, useImperativeHandle, useRef, forwardRef, createRef } from 'react';
|
7
|
+
import React, { memo, useState, useEffect, useMemo, useImperativeHandle, useRef, forwardRef, createRef, useCallback } from 'react';
|
8
8
|
import { createFromIconfontCN, SearchOutlined, ReloadOutlined, CloseCircleOutlined, PlusOutlined, EllipsisOutlined, ExclamationCircleOutlined, EyeOutlined, EditOutlined, DeleteOutlined } from '@ant-design/icons';
|
9
9
|
import 'antd/es/input/style';
|
10
10
|
import _Input from 'antd/es/input';
|
@@ -51,6 +51,7 @@ import ProTable from '@ant-design/pro-table';
|
|
51
51
|
import Player from 'xgplayer';
|
52
52
|
import FlvPlayer from 'xgplayer-flv.js';
|
53
53
|
import HlsJsPlayer from 'xgplayer-hls.js';
|
54
|
+
import { isEmpty } from 'lodash';
|
54
55
|
|
55
56
|
function ownKeys(object, enumerableOnly) {
|
56
57
|
var keys = Object.keys(object);
|
@@ -8719,166 +8720,7 @@ var Index$8 = function Index(props) {
|
|
8719
8720
|
|
8720
8721
|
Index$8.defaultProps = {};
|
8721
8722
|
|
8722
|
-
var _excluded$a = ["
|
8723
|
-
|
8724
|
-
var _sizeProp, _positionProp;
|
8725
|
-
var DIRECTION;
|
8726
|
-
|
8727
|
-
(function (DIRECTION) {
|
8728
|
-
DIRECTION["HORIZONTAL"] = "horizontal";
|
8729
|
-
DIRECTION["VERTICAL"] = "vertical";
|
8730
|
-
})(DIRECTION || (DIRECTION = {}));
|
8731
|
-
|
8732
|
-
var STYLE_WRAPPER = {
|
8733
|
-
overflow: 'auto',
|
8734
|
-
willChange: 'transform',
|
8735
|
-
WebkitOverflowScrolling: 'touch'
|
8736
|
-
};
|
8737
|
-
var STYLE_INNER = {
|
8738
|
-
position: 'relative',
|
8739
|
-
minWidth: '100%',
|
8740
|
-
minHeight: '100%'
|
8741
|
-
};
|
8742
|
-
var sizeProp = (_sizeProp = {}, _defineProperty(_sizeProp, DIRECTION.VERTICAL, 'height'), _defineProperty(_sizeProp, DIRECTION.HORIZONTAL, 'width'), _sizeProp);
|
8743
|
-
var positionProp = (_positionProp = {}, _defineProperty(_positionProp, DIRECTION.VERTICAL, 'top'), _defineProperty(_positionProp, DIRECTION.HORIZONTAL, 'left'), _positionProp);
|
8744
|
-
|
8745
|
-
var VirtualList = function VirtualList(props) {
|
8746
|
-
var width = props.width,
|
8747
|
-
height = props.height,
|
8748
|
-
itemCount = props.itemCount,
|
8749
|
-
itemSize = props.itemSize,
|
8750
|
-
renderItem = props.renderItem,
|
8751
|
-
_props$style = props.style,
|
8752
|
-
style = _props$style === void 0 ? {} : _props$style,
|
8753
|
-
onScroll = props.onScroll,
|
8754
|
-
scrollOffset = props.scrollOffset,
|
8755
|
-
_props$overscanCount = props.overscanCount,
|
8756
|
-
overscanCount = _props$overscanCount === void 0 ? 3 : _props$overscanCount,
|
8757
|
-
_props$scrollDirectio = props.scrollDirection,
|
8758
|
-
scrollDirection = _props$scrollDirectio === void 0 ? DIRECTION.VERTICAL : _props$scrollDirectio,
|
8759
|
-
otherProps = _objectWithoutProperties(props, _excluded$a);
|
8760
|
-
|
8761
|
-
var rootNode = useRef(null);
|
8762
|
-
|
8763
|
-
var _useState = useState(scrollOffset || 0),
|
8764
|
-
_useState2 = _slicedToArray(_useState, 2),
|
8765
|
-
offset = _useState2[0],
|
8766
|
-
setOffset = _useState2[1];
|
8767
|
-
|
8768
|
-
var _useState3 = useState({}),
|
8769
|
-
_useState4 = _slicedToArray(_useState3, 1),
|
8770
|
-
styleCache = _useState4[0];
|
8771
|
-
|
8772
|
-
var _useState5 = useState(false),
|
8773
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
8774
|
-
isMount = _useState6[0],
|
8775
|
-
setMount = _useState6[1];
|
8776
|
-
|
8777
|
-
useEffect(function () {
|
8778
|
-
var _rootNode$current;
|
8779
|
-
|
8780
|
-
if (!isMount) setMount(true); // 强制更新一次,供 getVisibleRange 方法获取 DOM 挂载后 containerSize
|
8781
|
-
|
8782
|
-
if (scrollOffset) scrollTo(scrollOffset);
|
8783
|
-
(_rootNode$current = rootNode.current) === null || _rootNode$current === void 0 ? void 0 : _rootNode$current.addEventListener('scroll', handleScroll, {
|
8784
|
-
passive: true // 用于优化浏览器页面滚动的性能
|
8785
|
-
|
8786
|
-
});
|
8787
|
-
return function () {
|
8788
|
-
var _rootNode$current2;
|
8789
|
-
|
8790
|
-
(_rootNode$current2 = rootNode.current) === null || _rootNode$current2 === void 0 ? void 0 : _rootNode$current2.removeEventListener('scroll', handleScroll);
|
8791
|
-
};
|
8792
|
-
}, []);
|
8793
|
-
|
8794
|
-
var handleScroll = function handleScroll(event) {
|
8795
|
-
var _rootNode$current3 = rootNode.current,
|
8796
|
-
_rootNode$current3$sc = _rootNode$current3.scrollTop,
|
8797
|
-
scrollTop = _rootNode$current3$sc === void 0 ? 0 : _rootNode$current3$sc,
|
8798
|
-
_rootNode$current3$sc2 = _rootNode$current3.scrollLeft,
|
8799
|
-
scrollLeft = _rootNode$current3$sc2 === void 0 ? 0 : _rootNode$current3$sc2;
|
8800
|
-
var newOffset = scrollDirection === DIRECTION.VERTICAL ? scrollTop : scrollLeft;
|
8801
|
-
|
8802
|
-
if (newOffset < 0 || newOffset === offset || event.target !== rootNode.current) {
|
8803
|
-
return;
|
8804
|
-
}
|
8805
|
-
|
8806
|
-
setOffset(newOffset);
|
8807
|
-
|
8808
|
-
if (typeof onScroll === 'function') {
|
8809
|
-
onScroll(offset, event);
|
8810
|
-
}
|
8811
|
-
};
|
8812
|
-
|
8813
|
-
var scrollTo = function scrollTo(value) {
|
8814
|
-
if (scrollDirection === DIRECTION.VERTICAL) {
|
8815
|
-
rootNode.current.scrollTop = value;
|
8816
|
-
} else {
|
8817
|
-
rootNode.current.scrollLeft = value;
|
8818
|
-
}
|
8819
|
-
};
|
8820
|
-
|
8821
|
-
var getVisibleRange = function getVisibleRange() {
|
8822
|
-
var _ref = rootNode.current || {},
|
8823
|
-
_ref$clientHeight = _ref.clientHeight,
|
8824
|
-
clientHeight = _ref$clientHeight === void 0 ? 0 : _ref$clientHeight,
|
8825
|
-
_ref$clientWidth = _ref.clientWidth,
|
8826
|
-
clientWidth = _ref$clientWidth === void 0 ? 0 : _ref$clientWidth;
|
8827
|
-
|
8828
|
-
var containerSize = scrollDirection === DIRECTION.VERTICAL ? clientHeight : clientWidth;
|
8829
|
-
var start = Math.floor(offset / itemSize - 1); // start --> 向下取整 (索引是从0开始,所以 - 1)
|
8830
|
-
|
8831
|
-
var stop = Math.ceil((offset + containerSize) / itemSize - 1); // stop --> 向上取整
|
8832
|
-
|
8833
|
-
return {
|
8834
|
-
start: Math.max(0, start - overscanCount),
|
8835
|
-
stop: Math.min(stop + overscanCount, itemCount - 1)
|
8836
|
-
};
|
8837
|
-
};
|
8838
|
-
|
8839
|
-
var getStyle = function getStyle(index) {
|
8840
|
-
var _styleCache$index;
|
8841
|
-
|
8842
|
-
var style = styleCache[index];
|
8843
|
-
if (style) return style;
|
8844
|
-
return styleCache[index] = (_styleCache$index = {
|
8845
|
-
position: 'absolute',
|
8846
|
-
top: 0,
|
8847
|
-
left: 0,
|
8848
|
-
width: '100%'
|
8849
|
-
}, _defineProperty(_styleCache$index, sizeProp[scrollDirection], props.itemSize), _defineProperty(_styleCache$index, positionProp[scrollDirection], props.itemSize * index), _styleCache$index);
|
8850
|
-
};
|
8851
|
-
|
8852
|
-
var wrapperStyle = _objectSpread2(_objectSpread2(_objectSpread2({}, STYLE_WRAPPER), style), {}, {
|
8853
|
-
height: height,
|
8854
|
-
width: width
|
8855
|
-
});
|
8856
|
-
|
8857
|
-
var innerStyle = _objectSpread2(_objectSpread2({}, STYLE_INNER), {}, _defineProperty({}, sizeProp[scrollDirection], itemCount * itemSize));
|
8858
|
-
|
8859
|
-
var items = [];
|
8860
|
-
|
8861
|
-
var _getVisibleRange = getVisibleRange(),
|
8862
|
-
start = _getVisibleRange.start,
|
8863
|
-
stop = _getVisibleRange.stop;
|
8864
|
-
|
8865
|
-
for (var index = start; index <= stop; index++) {
|
8866
|
-
items.push(renderItem({
|
8867
|
-
index: index,
|
8868
|
-
style: getStyle(index)
|
8869
|
-
}));
|
8870
|
-
}
|
8871
|
-
|
8872
|
-
return /*#__PURE__*/React.createElement("div", _objectSpread2(_objectSpread2({
|
8873
|
-
ref: rootNode
|
8874
|
-
}, otherProps), {}, {
|
8875
|
-
style: wrapperStyle
|
8876
|
-
}), /*#__PURE__*/React.createElement("div", {
|
8877
|
-
style: innerStyle
|
8878
|
-
}, items));
|
8879
|
-
};
|
8880
|
-
|
8881
|
-
var _excluded$b = ["list", "render", "none", "partSize"];
|
8723
|
+
var _excluded$a = ["list", "render", "none", "partSize"];
|
8882
8724
|
|
8883
8725
|
function AutoScroll(props) {
|
8884
8726
|
var inner1 = useRef();
|
@@ -8963,7 +8805,7 @@ var Index$9 = function Index(_ref) {
|
|
8963
8805
|
none = _ref.none,
|
8964
8806
|
_ref$partSize = _ref.partSize,
|
8965
8807
|
partSize = _ref$partSize === void 0 ? 4 : _ref$partSize,
|
8966
|
-
otherProps = _objectWithoutProperties(_ref, _excluded$
|
8808
|
+
otherProps = _objectWithoutProperties(_ref, _excluded$a);
|
8967
8809
|
|
8968
8810
|
var _useState = useState([]),
|
8969
8811
|
_useState2 = _slicedToArray(_useState, 2),
|
@@ -9046,7 +8888,7 @@ var Index$9 = function Index(_ref) {
|
|
9046
8888
|
}, none || '暂无数据');
|
9047
8889
|
};
|
9048
8890
|
|
9049
|
-
var _excluded$
|
8891
|
+
var _excluded$b = ["data", "onClick", "slidesPerView", "rowKey", "onSwiperChange", "renderItem"];
|
9050
8892
|
|
9051
8893
|
SwiperCore.use([Pagination, Navigation, Autoplay, Virtual]);
|
9052
8894
|
|
@@ -9058,7 +8900,7 @@ var Index$a = function Index(props) {
|
|
9058
8900
|
rowKey = props.rowKey,
|
9059
8901
|
onSwiperChange = props.onSwiperChange,
|
9060
8902
|
renderItem = props.renderItem,
|
9061
|
-
extraProps = _objectWithoutProperties(props, _excluded$
|
8903
|
+
extraProps = _objectWithoutProperties(props, _excluded$b);
|
9062
8904
|
|
9063
8905
|
var _useState = useState(null),
|
9064
8906
|
_useState2 = _slicedToArray(_useState, 2),
|
@@ -9709,7 +9551,7 @@ function createBrowserHistory(props) {
|
|
9709
9551
|
return history;
|
9710
9552
|
}
|
9711
9553
|
|
9712
|
-
var _excluded$
|
9554
|
+
var _excluded$c = ["routes", "className"];
|
9713
9555
|
var history = createBrowserHistory();
|
9714
9556
|
|
9715
9557
|
function itemRender(route, params, routes, paths) {
|
@@ -9727,7 +9569,7 @@ function itemRender(route, params, routes, paths) {
|
|
9727
9569
|
var Index$b = function Index(_ref) {
|
9728
9570
|
var routes = _ref.routes,
|
9729
9571
|
className = _ref.className,
|
9730
|
-
props = _objectWithoutProperties(_ref, _excluded$
|
9572
|
+
props = _objectWithoutProperties(_ref, _excluded$c);
|
9731
9573
|
|
9732
9574
|
return /*#__PURE__*/React.createElement(_Breadcrumb, _objectSpread2({
|
9733
9575
|
className: className || 'default',
|
@@ -9737,7 +9579,7 @@ var Index$b = function Index(_ref) {
|
|
9737
9579
|
}, props));
|
9738
9580
|
};
|
9739
9581
|
|
9740
|
-
var _excluded$
|
9582
|
+
var _excluded$d = ["title", "className", "headerTail", "headerCenter", "sliderTabs"];
|
9741
9583
|
|
9742
9584
|
var Index$c = function Index(_ref, ref) {
|
9743
9585
|
var _classNames;
|
@@ -9748,7 +9590,7 @@ var Index$c = function Index(_ref, ref) {
|
|
9748
9590
|
headerTail = _ref.headerTail,
|
9749
9591
|
headerCenter = _ref.headerCenter,
|
9750
9592
|
sliderTabs = _ref.sliderTabs,
|
9751
|
-
props = _objectWithoutProperties(_ref, _excluded$
|
9593
|
+
props = _objectWithoutProperties(_ref, _excluded$d);
|
9752
9594
|
|
9753
9595
|
useImperativeHandle(ref, function () {
|
9754
9596
|
return {
|
@@ -9990,7 +9832,7 @@ function DialogModel(props, ref) {
|
|
9990
9832
|
|
9991
9833
|
var Dialog = /*#__PURE__*/React.forwardRef(DialogModel);
|
9992
9834
|
|
9993
|
-
var _excluded$
|
9835
|
+
var _excluded$e = ["visible", "width", "closeCb", "onClose", "className", "style"],
|
9994
9836
|
_excluded2$3 = ["visible"];
|
9995
9837
|
|
9996
9838
|
var Modal = /*#__PURE__*/function (_React$PureComponent) {
|
@@ -10107,7 +9949,7 @@ var Modal = /*#__PURE__*/function (_React$PureComponent) {
|
|
10107
9949
|
onClose = _this$props4.onClose,
|
10108
9950
|
className = _this$props4.className,
|
10109
9951
|
style = _this$props4.style,
|
10110
|
-
other = _objectWithoutProperties(_this$props4, _excluded$
|
9952
|
+
other = _objectWithoutProperties(_this$props4, _excluded$e);
|
10111
9953
|
|
10112
9954
|
return /*#__PURE__*/React.createElement(Dialog, _objectSpread2({
|
10113
9955
|
ref: this.containerRef,
|
@@ -10290,7 +10132,7 @@ function DialogModel$1(props) {
|
|
10290
10132
|
return renderChildren;
|
10291
10133
|
}
|
10292
10134
|
|
10293
|
-
var _excluded$
|
10135
|
+
var _excluded$f = ["visible"];
|
10294
10136
|
|
10295
10137
|
var Modal$1 = /*#__PURE__*/function (_React$PureComponent) {
|
10296
10138
|
_inherits(Modal, _React$PureComponent);
|
@@ -10430,7 +10272,7 @@ Modal$1.show = function (config) {
|
|
10430
10272
|
manager.setShow = setShow;
|
10431
10273
|
|
10432
10274
|
var visible = props.visible,
|
10433
|
-
trueProps = _objectWithoutProperties(props, _excluded$
|
10275
|
+
trueProps = _objectWithoutProperties(props, _excluded$f);
|
10434
10276
|
|
10435
10277
|
useEffect(function () {
|
10436
10278
|
manager.mounted = true;
|
@@ -10454,7 +10296,7 @@ Modal$1.hidden = function () {
|
|
10454
10296
|
ModalContainer[modelSysbol] && ModalContainer[modelSysbol].hidden();
|
10455
10297
|
};
|
10456
10298
|
|
10457
|
-
var _excluded$
|
10299
|
+
var _excluded$g = ["columns", "extraColumns", "search", "visible", "setVisible", "disabled", "submitMethod", "onSubmitSuccess", "title", "record", "onFormChange"];
|
10458
10300
|
|
10459
10301
|
var ModalForm = function ModalForm(props, ref) {
|
10460
10302
|
var columns = props.columns,
|
@@ -10468,7 +10310,7 @@ var ModalForm = function ModalForm(props, ref) {
|
|
10468
10310
|
title = props.title,
|
10469
10311
|
record = props.record,
|
10470
10312
|
onFormChange = props.onFormChange,
|
10471
|
-
extraProps = _objectWithoutProperties(props, _excluded$
|
10313
|
+
extraProps = _objectWithoutProperties(props, _excluded$g);
|
10472
10314
|
|
10473
10315
|
var formRef = useRef(null);
|
10474
10316
|
|
@@ -10599,7 +10441,7 @@ var ModalForm = function ModalForm(props, ref) {
|
|
10599
10441
|
|
10600
10442
|
var ModalForm$1 = /*#__PURE__*/React.forwardRef(ModalForm);
|
10601
10443
|
|
10602
|
-
var _excluded$
|
10444
|
+
var _excluded$h = ["columns", "extraColumns", "request", "modalFormSearch", "search", "tableAction", "renderTableBar", "className", "style", "onFormChange", "modalConfig", "optionColumnConfig", "pagination", "noBordered"];
|
10603
10445
|
|
10604
10446
|
var TabelCard = function TabelCard(props, ref) {
|
10605
10447
|
var columns = props.columns,
|
@@ -10616,7 +10458,7 @@ var TabelCard = function TabelCard(props, ref) {
|
|
10616
10458
|
optionColumnConfig = props.optionColumnConfig,
|
10617
10459
|
pagination = props.pagination,
|
10618
10460
|
noBordered = props.noBordered,
|
10619
|
-
extraProps = _objectWithoutProperties(props, _excluded$
|
10461
|
+
extraProps = _objectWithoutProperties(props, _excluded$h);
|
10620
10462
|
|
10621
10463
|
var actionRef = useRef();
|
10622
10464
|
var modalFormRef = useRef(null);
|
@@ -11331,12 +11173,12 @@ function Xgplay(_ref, fRef) {
|
|
11331
11173
|
}
|
11332
11174
|
|
11333
11175
|
return function () {
|
11334
|
-
var _playerRef$current
|
11176
|
+
var _playerRef$current;
|
11335
11177
|
|
11336
|
-
(_playerRef$current = playerRef.current) === null || _playerRef$current === void 0 ? void 0 :
|
11178
|
+
(_playerRef$current = playerRef.current) === null || _playerRef$current === void 0 ? void 0 : _playerRef$current.destroy(true);
|
11337
11179
|
setRef(null);
|
11338
11180
|
};
|
11339
|
-
});
|
11181
|
+
}, []);
|
11340
11182
|
useImperativeHandle(fRef, function () {
|
11341
11183
|
return {
|
11342
11184
|
player: playerRef.current
|
@@ -11541,4 +11383,234 @@ function VideoPlayer(_ref, ref) {
|
|
11541
11383
|
|
11542
11384
|
var index$3 = /*#__PURE__*/forwardRef(VideoPlayer);
|
11543
11385
|
|
11544
|
-
|
11386
|
+
var _excluded$i = ["id", "videoUrls", "definitionList", "isLoop", "muted", "currentIndex", "setCurrentIndex", "className", "style", "visible", "autoplay", "videoInit", "enableMemory", "lastPlayTimeHideDelay"];
|
11387
|
+
|
11388
|
+
var DEFAULT_PLAY_BACK_RATE = [0.5, 0.75, 1, 1.5, 2]; // 默认记忆提示文字展示时长(s)
|
11389
|
+
|
11390
|
+
var DEFAULT_LAST_PLAY_TIME_DELAY = 5; // 默认音量大小
|
11391
|
+
|
11392
|
+
var DEFAULT_VOLUME = 0.6;
|
11393
|
+
var index$4 = (function (_ref) {
|
11394
|
+
var id = _ref.id,
|
11395
|
+
_ref$videoUrls = _ref.videoUrls,
|
11396
|
+
videoUrls = _ref$videoUrls === void 0 ? [] : _ref$videoUrls,
|
11397
|
+
_ref$definitionList = _ref.definitionList,
|
11398
|
+
definitionList = _ref$definitionList === void 0 ? [] : _ref$definitionList,
|
11399
|
+
_ref$isLoop = _ref.isLoop,
|
11400
|
+
isLoop = _ref$isLoop === void 0 ? true : _ref$isLoop,
|
11401
|
+
_ref$muted = _ref.muted,
|
11402
|
+
muted = _ref$muted === void 0 ? false : _ref$muted,
|
11403
|
+
parentIndex = _ref.currentIndex,
|
11404
|
+
setParentIndex = _ref.setCurrentIndex,
|
11405
|
+
className = _ref.className,
|
11406
|
+
style = _ref.style,
|
11407
|
+
_ref$visible = _ref.visible,
|
11408
|
+
visible = _ref$visible === void 0 ? true : _ref$visible,
|
11409
|
+
_ref$autoplay = _ref.autoplay,
|
11410
|
+
autoplay = _ref$autoplay === void 0 ? false : _ref$autoplay,
|
11411
|
+
_ref$videoInit = _ref.videoInit,
|
11412
|
+
videoInit = _ref$videoInit === void 0 ? true : _ref$videoInit,
|
11413
|
+
_ref$enableMemory = _ref.enableMemory,
|
11414
|
+
enableMemory = _ref$enableMemory === void 0 ? false : _ref$enableMemory,
|
11415
|
+
_ref$lastPlayTimeHide = _ref.lastPlayTimeHideDelay,
|
11416
|
+
lastPlayTimeHideDelay = _ref$lastPlayTimeHide === void 0 ? DEFAULT_LAST_PLAY_TIME_DELAY : _ref$lastPlayTimeHide,
|
11417
|
+
props = _objectWithoutProperties(_ref, _excluded$i);
|
11418
|
+
|
11419
|
+
var player = useRef();
|
11420
|
+
var currentPlayerIndex = useRef(0); // 内置的 index 状态管理
|
11421
|
+
|
11422
|
+
var _useState = useState(0),
|
11423
|
+
_useState2 = _slicedToArray(_useState, 2),
|
11424
|
+
videoIndex = _useState2[0],
|
11425
|
+
setVideoIndex = _useState2[1];
|
11426
|
+
|
11427
|
+
var currentIndex = useMemo(function () {
|
11428
|
+
return parentIndex !== null && parentIndex !== void 0 ? parentIndex : videoIndex;
|
11429
|
+
}, [parentIndex, videoIndex]);
|
11430
|
+
var setCurrentIndex = useMemo(function () {
|
11431
|
+
return setParentIndex !== null && setParentIndex !== void 0 ? setParentIndex : setVideoIndex;
|
11432
|
+
}, [setParentIndex, setVideoIndex]);
|
11433
|
+
var config = useRef(_objectSpread2({
|
11434
|
+
url: videoUrls[0],
|
11435
|
+
playbackRate: DEFAULT_PLAY_BACK_RATE,
|
11436
|
+
playNext: {
|
11437
|
+
urlList: videoUrls.slice(1)
|
11438
|
+
},
|
11439
|
+
volume: muted ? 0 : DEFAULT_VOLUME,
|
11440
|
+
autoplay: autoplay,
|
11441
|
+
videoInit: videoInit,
|
11442
|
+
lastPlayTimeHideDelay: lastPlayTimeHideDelay
|
11443
|
+
}, props));
|
11444
|
+
/** 设置当前播放 index */
|
11445
|
+
|
11446
|
+
var handleSetCurrentIndex = useCallback(function (currentIdx) {
|
11447
|
+
var newIdx = currentIdx !== null && currentIdx !== void 0 ? currentIdx : currentPlayerIndex.current + 1;
|
11448
|
+
|
11449
|
+
if (newIdx >= videoUrls.length) {
|
11450
|
+
if (isLoop) {
|
11451
|
+
// 允许循环则播放起始视频
|
11452
|
+
newIdx = 0;
|
11453
|
+
} else if (player.current && player.current.video) {
|
11454
|
+
// 不允许循环则进度条快进到最后
|
11455
|
+
player.current.currentTime = player.current.video.duration;
|
11456
|
+
return;
|
11457
|
+
}
|
11458
|
+
}
|
11459
|
+
|
11460
|
+
setCurrentIndex(newIdx);
|
11461
|
+
}, [isLoop, setCurrentIndex, videoUrls.length]);
|
11462
|
+
/** 播放下一个 */
|
11463
|
+
|
11464
|
+
var handlePlayNext = useCallback(function (currentIdx) {
|
11465
|
+
if (!player.current) {
|
11466
|
+
return;
|
11467
|
+
}
|
11468
|
+
|
11469
|
+
player.current.src = videoUrls[currentIdx];
|
11470
|
+
player.current.emit('playerNext', currentIdx);
|
11471
|
+
player.current.play();
|
11472
|
+
currentPlayerIndex.current = currentIdx;
|
11473
|
+
|
11474
|
+
if (isLoop) {
|
11475
|
+
// 防止 next 按钮消失
|
11476
|
+
player.current.currentVideoIndex = -videoUrls.length;
|
11477
|
+
}
|
11478
|
+
}, [videoUrls, isLoop]);
|
11479
|
+
/** 重置视频 */
|
11480
|
+
|
11481
|
+
var handleReset = useCallback(function () {
|
11482
|
+
if (!player.current) {
|
11483
|
+
return;
|
11484
|
+
}
|
11485
|
+
|
11486
|
+
setCurrentIndex(0);
|
11487
|
+
currentPlayerIndex.current = -1;
|
11488
|
+
player.current.destroy();
|
11489
|
+
player.current = undefined;
|
11490
|
+
}, [setCurrentIndex]);
|
11491
|
+
/** 弹窗中的视频关闭以后重置 */
|
11492
|
+
|
11493
|
+
useEffect(function () {
|
11494
|
+
if (!visible) {
|
11495
|
+
handleReset();
|
11496
|
+
}
|
11497
|
+
}, [handleReset, visible]);
|
11498
|
+
/** 当 currentIndex 改变以后自动播放下一个 */
|
11499
|
+
|
11500
|
+
useEffect(function () {
|
11501
|
+
if (!player.current || !visible) {
|
11502
|
+
return;
|
11503
|
+
}
|
11504
|
+
|
11505
|
+
handlePlayNext(currentIndex !== null && currentIndex !== void 0 ? currentIndex : currentPlayerIndex.current);
|
11506
|
+
}, [currentIndex, handlePlayNext, visible]);
|
11507
|
+
/** 播放器初始化并绑定事件 */
|
11508
|
+
|
11509
|
+
useEffect(function () {
|
11510
|
+
if (!visible || isEmpty(videoUrls) || player.current) {
|
11511
|
+
return;
|
11512
|
+
}
|
11513
|
+
|
11514
|
+
player.current = new Player(config.current);
|
11515
|
+
player.current.currentVideoIndex = -videoUrls.length;
|
11516
|
+
player.current.on('ended', function () {
|
11517
|
+
// 如果是循环或有其他视频未播放完,继续播放下一个
|
11518
|
+
if (isLoop || !isLoop && currentPlayerIndex.current < videoUrls.length - 1) {
|
11519
|
+
handleSetCurrentIndex();
|
11520
|
+
setTimeout(function () {
|
11521
|
+
var _player$current;
|
11522
|
+
|
11523
|
+
return (_player$current = player.current) === null || _player$current === void 0 ? void 0 : _player$current.play();
|
11524
|
+
});
|
11525
|
+
} else {
|
11526
|
+
var _player$current2;
|
11527
|
+
|
11528
|
+
(_player$current2 = player.current) === null || _player$current2 === void 0 ? void 0 : _player$current2.pause();
|
11529
|
+
}
|
11530
|
+
}); // 播放记忆缓存
|
11531
|
+
|
11532
|
+
if (enableMemory) {
|
11533
|
+
var videoPlayedTimeObj = JSON.parse(localStorage.getItem('videoPlayedTime') || '{}');
|
11534
|
+
player.current.on('timeupdate', function () {
|
11535
|
+
var _player$current3;
|
11536
|
+
|
11537
|
+
if (currentPlayerIndex.current === -1) {
|
11538
|
+
return;
|
11539
|
+
}
|
11540
|
+
|
11541
|
+
localStorage.setItem('videoPlayedTime', JSON.stringify(_objectSpread2(_objectSpread2({}, videoPlayedTimeObj), {}, _defineProperty({}, id, {
|
11542
|
+
lastPlayTime: (_player$current3 = player.current) === null || _player$current3 === void 0 ? void 0 : _player$current3.currentTime,
|
11543
|
+
videoIndex: currentPlayerIndex.current
|
11544
|
+
}))));
|
11545
|
+
});
|
11546
|
+
}
|
11547
|
+
|
11548
|
+
player.current.on('playNextBtnClick', function () {
|
11549
|
+
if (!isLoop && player.current) {
|
11550
|
+
// 防止 next 按钮消失
|
11551
|
+
player.current.currentVideoIndex = videoUrls.length - 2;
|
11552
|
+
}
|
11553
|
+
|
11554
|
+
handleSetCurrentIndex();
|
11555
|
+
});
|
11556
|
+
}, [autoplay, enableMemory, handleSetCurrentIndex, id, isLoop, videoUrls, videoUrls.length, visible]);
|
11557
|
+
/** 读取缓存的播放记忆并跳转 */
|
11558
|
+
|
11559
|
+
useEffect(function () {
|
11560
|
+
if (enableMemory && visible) {
|
11561
|
+
var _JSON$parse;
|
11562
|
+
|
11563
|
+
var _ref2 = ((_JSON$parse = JSON.parse(localStorage.getItem('videoPlayedTime') || '{}')) === null || _JSON$parse === void 0 ? void 0 : _JSON$parse[id]) || {},
|
11564
|
+
lastPlayTime = _ref2.lastPlayTime,
|
11565
|
+
_videoIndex = _ref2.videoIndex;
|
11566
|
+
|
11567
|
+
setTimeout(function () {
|
11568
|
+
handleSetCurrentIndex(_videoIndex);
|
11569
|
+
setTimeout(function () {
|
11570
|
+
if (player.current) {
|
11571
|
+
player.current.currentTime = lastPlayTime;
|
11572
|
+
}
|
11573
|
+
});
|
11574
|
+
});
|
11575
|
+
}
|
11576
|
+
}, [visible, enableMemory, handleSetCurrentIndex, id]);
|
11577
|
+
/** 加载清晰度配置 */
|
11578
|
+
|
11579
|
+
useEffect(function () {
|
11580
|
+
if (!isEmpty(definitionList[currentIndex]) && player.current) {
|
11581
|
+
player.current.emit('resourceReady', definitionList[currentIndex]);
|
11582
|
+
}
|
11583
|
+
}, [currentIndex, definitionList]);
|
11584
|
+
var getRef = useCallback(function (ref) {
|
11585
|
+
if (ref && visible) {
|
11586
|
+
var newConfig = _objectSpread2(_objectSpread2({}, config.current), {}, {
|
11587
|
+
el: ref,
|
11588
|
+
url: videoUrls[0],
|
11589
|
+
playNext: {
|
11590
|
+
urlList: videoUrls.slice(1)
|
11591
|
+
}
|
11592
|
+
});
|
11593
|
+
|
11594
|
+
if (enableMemory) {
|
11595
|
+
var _JSON$parse2;
|
11596
|
+
|
11597
|
+
var _ref3 = ((_JSON$parse2 = JSON.parse(localStorage.getItem('videoPlayedTime') || '{}')) === null || _JSON$parse2 === void 0 ? void 0 : _JSON$parse2[id]) || {},
|
11598
|
+
lastPlayTime = _ref3.lastPlayTime;
|
11599
|
+
|
11600
|
+
Object.assign(newConfig, {
|
11601
|
+
lastPlayTime: lastPlayTime,
|
11602
|
+
lastPlayTimeHideDelay: lastPlayTimeHideDelay
|
11603
|
+
});
|
11604
|
+
}
|
11605
|
+
|
11606
|
+
config.current = newConfig;
|
11607
|
+
}
|
11608
|
+
}, [visible, id, videoUrls, lastPlayTimeHideDelay, enableMemory]);
|
11609
|
+
return /*#__PURE__*/React.createElement("div", {
|
11610
|
+
className: className,
|
11611
|
+
ref: getRef,
|
11612
|
+
style: style
|
11613
|
+
});
|
11614
|
+
});
|
11615
|
+
|
11616
|
+
export { Index$9 as AutoScroll, Index$b as Breadcrumb, WButton as Button, index$1 as Card, WCascader as Cascader, Index$3 as Checkbox, Index$8 as CountUp, Index$1 as DatePicker, index as IconFont, Index as Input, WInputNumber as InputNumber, Modal, ModalForm$1 as ModalForm, Modal$1 as ModalTips, Index$7 as Number, NumericInput, Index$2 as Radio, Select, Index$a as Swiper, WSwitch as Switch, index$2 as TabelCard, Table, Index$6 as TreeSelect, index$4 as Video, index$3 as VideoPlayer, Index$5 as WDatePicker, WForm$1 as WForm, WebsocketHeart };
|