wargerm 0.7.31 → 0.7.33
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/Modal/dialog.d.ts +2 -1
- package/dist/components/Modal/index.d.ts +7 -1
- package/dist/components/Swiper/index.d.ts +1 -0
- package/dist/components/Upload/example/UploadBigFile/api.d.ts +0 -0
- package/dist/components/Upload/example/UploadBigFile/index.d.ts +0 -0
- package/dist/components/Upload/example/UploadBigFile/utils/hash.d.ts +0 -0
- package/dist/components/Video/index.d.ts +5 -14
- package/dist/components/WForm/example/demo4.d.ts +3 -0
- package/dist/components/WForm/example/demo5.d.ts +3 -0
- package/dist/index.esm.js +166 -181
- package/dist/index.js +165 -180
- package/package.json +92 -92
package/dist/index.esm.js
CHANGED
@@ -3,7 +3,7 @@ import React, { useRef, useEffect, useMemo, useState, useCallback, useImperative
|
|
3
3
|
import { cloneDeep, uniqBy, chunk, isEmpty } from 'lodash-es';
|
4
4
|
import { useSyncExternalStore } from 'use-sync-external-store/shim';
|
5
5
|
import { Menu, Dropdown, Button, Input, Upload as Upload$1, Modal as Modal$2, message, InputNumber, DatePicker, Radio, Space, Checkbox, Select, Switch, Tooltip, TreeSelect as TreeSelect$1, Cascader, Form, Row, Col, Spin, Pagination, Breadcrumb, ConfigProvider, notification } from 'antd';
|
6
|
-
import { createFromIconfontCN, PlusOutlined, CloseCircleOutlined, SearchOutlined, ReloadOutlined, EllipsisOutlined, ExclamationCircleOutlined, EyeOutlined, EditOutlined, DeleteOutlined, LeftOutlined, RightOutlined, CloseOutlined } from '@ant-design/icons';
|
6
|
+
import { createFromIconfontCN, PlusOutlined, CloseCircleOutlined, SearchOutlined, ReloadOutlined, MinusOutlined, FullscreenOutlined, EllipsisOutlined, ExclamationCircleOutlined, EyeOutlined, EditOutlined, DeleteOutlined, LeftOutlined, RightOutlined, CloseOutlined } from '@ant-design/icons';
|
7
7
|
import FileViewer from 'react-file-viewer';
|
8
8
|
import classnames from 'classnames';
|
9
9
|
import zhCN from 'antd/es/date-picker/locale/zh_CN';
|
@@ -5316,7 +5316,7 @@ var Index$b = function Index(_ref) {
|
|
5316
5316
|
}, none || '暂无数据');
|
5317
5317
|
};
|
5318
5318
|
|
5319
|
-
var _excluded$f = ["data", "onClick", "slidesPerView", "rowKey", "onSwiperChange", "renderItem"];
|
5319
|
+
var _excluded$f = ["data", "onClick", "slidesPerView", "rowKey", "onSwiperChange", "renderItem", "noMove"];
|
5320
5320
|
|
5321
5321
|
SwiperCore.use([Pagination$1, Navigation, Autoplay, Virtual]);
|
5322
5322
|
var Index$c = /*#__PURE__*/forwardRef(function (props, ref) {
|
@@ -5327,6 +5327,7 @@ var Index$c = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
5327
5327
|
rowKey = props.rowKey,
|
5328
5328
|
onSwiperChange = props.onSwiperChange,
|
5329
5329
|
renderItem = props.renderItem,
|
5330
|
+
noMove = props.noMove,
|
5330
5331
|
extraProps = _objectWithoutProperties(props, _excluded$f);
|
5331
5332
|
|
5332
5333
|
var _useState = useState(null),
|
@@ -5372,7 +5373,7 @@ var Index$c = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
5372
5373
|
height: '100%'
|
5373
5374
|
},
|
5374
5375
|
onClick: function onClick(event) {
|
5375
|
-
if (controlledSwiper) {
|
5376
|
+
if (controlledSwiper && !noMove) {
|
5376
5377
|
if (controlledSwiper.clickedIndex - slidesPerView > data.length) {
|
5377
5378
|
controlledSwiper.slideNext();
|
5378
5379
|
} else {
|
@@ -6084,6 +6085,7 @@ function DialogModel(props, ref) {
|
|
6084
6085
|
_props$className = props.className,
|
6085
6086
|
className = _props$className === void 0 ? 'default-dialog' : _props$className,
|
6086
6087
|
wrapClassName = props.wrapClassName,
|
6088
|
+
fullScreenStyle = props.fullScreenStyle,
|
6087
6089
|
style = props.style;
|
6088
6090
|
|
6089
6091
|
var _useState = useState(open),
|
@@ -6103,13 +6105,8 @@ function DialogModel(props, ref) {
|
|
6103
6105
|
|
6104
6106
|
var _useState7 = useState(false),
|
6105
6107
|
_useState8 = _slicedToArray(_useState7, 2),
|
6106
|
-
|
6107
|
-
|
6108
|
-
|
6109
|
-
var _useState9 = useState(false),
|
6110
|
-
_useState10 = _slicedToArray(_useState9, 2),
|
6111
|
-
isDesChild = _useState10[0],
|
6112
|
-
setIsDesChild = _useState10[1];
|
6108
|
+
isDesChild = _useState8[0],
|
6109
|
+
setIsDesChild = _useState8[1];
|
6113
6110
|
|
6114
6111
|
var containerRef = useRef();
|
6115
6112
|
var ltRef = useRef();
|
@@ -6136,11 +6133,12 @@ function DialogModel(props, ref) {
|
|
6136
6133
|
}, /*#__PURE__*/React.createElement("div", {
|
6137
6134
|
ref: containerRef,
|
6138
6135
|
className: classnames((_classNames = {}, _defineProperty(_classNames, className, true), _defineProperty(_classNames, 'model_container', true), _defineProperty(_classNames, "animate__animated", true), _defineProperty(_classNames, flag ? 'animate__bounceInDown' : 'animate__fadeOutRightBig', true), _classNames)),
|
6139
|
-
style: _objectSpread2({
|
6136
|
+
style: _objectSpread2(_objectSpread2({
|
6140
6137
|
opacity: modelShowAync ? 1 : 0,
|
6141
6138
|
width: typeof width == 'number' ? width + 'px' : width,
|
6139
|
+
// transition: "width,height,left,top ease-in-out 0.3s",
|
6142
6140
|
pointerEvents: 'all'
|
6143
|
-
}, style)
|
6141
|
+
}, style), fullScreenStyle)
|
6144
6142
|
}, /*#__PURE__*/React.createElement("div", {
|
6145
6143
|
className: 'model_wrap'
|
6146
6144
|
}, isResize && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
@@ -6167,14 +6165,14 @@ function DialogModel(props, ref) {
|
|
6167
6165
|
opacity: modelShowAync ? 0.6 : 0
|
6168
6166
|
}
|
6169
6167
|
})), document.body);
|
6170
|
-
}, [modelShowAync, modelShow, props, isDesChild]);
|
6168
|
+
}, [modelShowAync, modelShow, props, isDesChild, fullScreenStyle]);
|
6171
6169
|
useEffect(function () {
|
6172
6170
|
var containerEl = containerRef.current;
|
6173
6171
|
var containerElWidth = containerEl.offsetWidth;
|
6174
6172
|
var containerElHeight = containerEl.offsetHeight;
|
6175
6173
|
containerEl.style.left = "calc(50% - ".concat(containerElWidth / 2, "px)");
|
6176
6174
|
containerEl.style.top = "calc(50% - ".concat(containerElHeight / 2, "px)");
|
6177
|
-
}, [modelShow]);
|
6175
|
+
}, [modelShow, fullScreenStyle]);
|
6178
6176
|
useEffect(function () {
|
6179
6177
|
var containerEl = containerRef.current;
|
6180
6178
|
var rEl = rRef.current;
|
@@ -6250,20 +6248,14 @@ function DialogModel(props, ref) {
|
|
6250
6248
|
};
|
6251
6249
|
}, [open]);
|
6252
6250
|
useEffect(function () {
|
6253
|
-
if (
|
6254
|
-
|
6255
|
-
}
|
6256
|
-
|
6257
|
-
if (destroyOnClose && hasVisit) {
|
6258
|
-
if (!modelShow) {
|
6259
|
-
setIsDesChild(true);
|
6260
|
-
} else {
|
6261
|
-
setIsDesChild(false);
|
6262
|
-
}
|
6251
|
+
if (destroyOnClose) {
|
6252
|
+
setIsDesChild(!modelShow);
|
6253
|
+
} else {
|
6254
|
+
setIsDesChild(false);
|
6263
6255
|
}
|
6264
6256
|
|
6265
6257
|
!modelShow && typeof closeCb === 'function' && closeCb();
|
6266
|
-
}, [modelShow,
|
6258
|
+
}, [modelShow, destroyOnClose]);
|
6267
6259
|
return renderChildren;
|
6268
6260
|
}
|
6269
6261
|
|
@@ -6287,6 +6279,9 @@ var Modal = /*#__PURE__*/function (_React$PureComponent) {
|
|
6287
6279
|
}
|
6288
6280
|
|
6289
6281
|
_this = _super.call.apply(_super, [this].concat(args));
|
6282
|
+
_this.state = {
|
6283
|
+
isFullScreen: false
|
6284
|
+
};
|
6290
6285
|
|
6291
6286
|
_this.renderFooter = function () {
|
6292
6287
|
var _this$props = _this.props,
|
@@ -6323,19 +6318,61 @@ var Modal = /*#__PURE__*/function (_React$PureComponent) {
|
|
6323
6318
|
onClose = _this$props2.onClose,
|
6324
6319
|
closeCb = _this$props2.closeCb,
|
6325
6320
|
renderClose = _this$props2.renderClose,
|
6326
|
-
isDrag = _this$props2.isDrag
|
6321
|
+
isDrag = _this$props2.isDrag,
|
6322
|
+
showFullscreen = _this$props2.showFullscreen,
|
6323
|
+
renderMin = _this$props2.renderMin,
|
6324
|
+
renderFullScreen = _this$props2.renderFullScreen;
|
6325
|
+
|
6326
|
+
var onMouseDown = function onMouseDown(eventDown) {
|
6327
|
+
if (!isDrag) return;
|
6328
|
+
if (!_this.containerRef.current) return;
|
6329
|
+
var containerEl = _this.containerRef.current.containerRef;
|
6330
|
+
var left = containerEl.offsetLeft;
|
6331
|
+
var top = containerEl.offsetTop;
|
6332
|
+
console.log(left, top);
|
6333
|
+
var downX = eventDown.clientX;
|
6334
|
+
var downY = eventDown.clientY;
|
6335
|
+
|
6336
|
+
document.onmousemove = function (eventMove) {
|
6337
|
+
eventMove.stopPropagation();
|
6338
|
+
eventMove.preventDefault();
|
6339
|
+
var moveX = eventMove.clientX - downX;
|
6340
|
+
var moveY = eventMove.clientY - downY;
|
6341
|
+
containerEl.style.left = "".concat(left + moveX, "px");
|
6342
|
+
containerEl.style.top = "".concat(top + moveY, "px");
|
6343
|
+
};
|
6344
|
+
};
|
6345
|
+
|
6346
|
+
var onMouseUp = function onMouseUp(event) {
|
6347
|
+
document.onmousemove = null;
|
6348
|
+
};
|
6349
|
+
|
6327
6350
|
return /*#__PURE__*/React.createElement("div", {
|
6328
6351
|
className: "model-header"
|
6329
6352
|
}, /*#__PURE__*/React.createElement("div", {
|
6330
6353
|
ref: _this.titleRef,
|
6354
|
+
onMouseDown: onMouseDown,
|
6355
|
+
onMouseUp: onMouseUp,
|
6331
6356
|
className: "model-title ".concat(isDrag ? 'move' : '')
|
6332
6357
|
}, title), /*#__PURE__*/React.createElement("div", {
|
6333
|
-
|
6358
|
+
style: {
|
6359
|
+
display: 'flex',
|
6360
|
+
alignItems: 'center'
|
6361
|
+
},
|
6362
|
+
className: "model-closeIcon"
|
6363
|
+
}, showFullscreen && /*#__PURE__*/React.createElement("span", {
|
6364
|
+
className: 'mr5 cp',
|
6365
|
+
onClick: function onClick() {
|
6366
|
+
_this.setState({
|
6367
|
+
isFullScreen: !_this.state.isFullScreen
|
6368
|
+
});
|
6369
|
+
}
|
6370
|
+
}, _this.state.isFullScreen ? renderMin || /*#__PURE__*/React.createElement(MinusOutlined, null) : renderFullScreen || /*#__PURE__*/React.createElement(FullscreenOutlined, null)), /*#__PURE__*/React.createElement("span", {
|
6334
6371
|
onClick: function onClick() {
|
6335
6372
|
onClose && onClose();
|
6336
6373
|
closeCb && closeCb();
|
6337
6374
|
}
|
6338
|
-
}, renderClose ? renderClose : /*#__PURE__*/React.createElement(CloseCircleOutlined, null)));
|
6375
|
+
}, renderClose ? renderClose : /*#__PURE__*/React.createElement(CloseCircleOutlined, null))));
|
6339
6376
|
};
|
6340
6377
|
|
6341
6378
|
_this.renderContent = function () {
|
@@ -6349,33 +6386,15 @@ var Modal = /*#__PURE__*/function (_React$PureComponent) {
|
|
6349
6386
|
}
|
6350
6387
|
|
6351
6388
|
_createClass(Modal, [{
|
6352
|
-
key: "
|
6353
|
-
value: function
|
6354
|
-
var
|
6355
|
-
if (!isDrag) return;
|
6356
|
-
var tltleEl = this.titleRef.current;
|
6357
|
-
var containerEl = this.containerRef.current.containerRef;
|
6358
|
-
|
6359
|
-
tltleEl.onmousedown = function (eventDown) {
|
6360
|
-
var left = containerEl.offsetLeft;
|
6361
|
-
var top = containerEl.offsetTop;
|
6362
|
-
console.log(left, top);
|
6363
|
-
var downX = eventDown.clientX;
|
6364
|
-
var downY = eventDown.clientY;
|
6365
|
-
|
6366
|
-
document.onmousemove = function (eventMove) {
|
6367
|
-
eventMove.stopPropagation();
|
6368
|
-
eventMove.preventDefault();
|
6369
|
-
var moveX = eventMove.clientX - downX;
|
6370
|
-
var moveY = eventMove.clientY - downY;
|
6371
|
-
containerEl.style.left = "".concat(left + moveX, "px");
|
6372
|
-
containerEl.style.top = "".concat(top + moveY, "px");
|
6373
|
-
};
|
6374
|
-
};
|
6389
|
+
key: "componentDidUpdate",
|
6390
|
+
value: function componentDidUpdate(prevProps, prevState, snapshot) {
|
6391
|
+
var open = prevProps.open;
|
6375
6392
|
|
6376
|
-
|
6377
|
-
|
6378
|
-
|
6393
|
+
if (!open) {
|
6394
|
+
this.setState({
|
6395
|
+
isFullScreen: false
|
6396
|
+
});
|
6397
|
+
}
|
6379
6398
|
}
|
6380
6399
|
}, {
|
6381
6400
|
key: "render",
|
@@ -6400,6 +6419,12 @@ var Modal = /*#__PURE__*/function (_React$PureComponent) {
|
|
6400
6419
|
className: className,
|
6401
6420
|
isDrag: isDrag,
|
6402
6421
|
wrapClassName: wrapClassName,
|
6422
|
+
fullScreenStyle: this.state.isFullScreen ? {
|
6423
|
+
width: '100%',
|
6424
|
+
height: '100%',
|
6425
|
+
left: 0,
|
6426
|
+
top: 0
|
6427
|
+
} : {},
|
6403
6428
|
style: style
|
6404
6429
|
}, other), this.renderTop(), /*#__PURE__*/React.createElement("div", {
|
6405
6430
|
className: "model-content"
|
@@ -7559,22 +7584,32 @@ var TabelCard = function TabelCard(props, ref) {
|
|
7559
7584
|
actionRef === null || actionRef === void 0 ? void 0 : (_actionRef$current6 = actionRef.current) === null || _actionRef$current6 === void 0 ? void 0 : _actionRef$current6.reload(true);
|
7560
7585
|
};
|
7561
7586
|
|
7587
|
+
var onKeyUpSubmit = function onKeyUpSubmit(values) {
|
7588
|
+
if (values.keyCode === 13) {
|
7589
|
+
var _searchFormRef$curren, _searchFormRef$curren2, _actionRef$current7;
|
7590
|
+
|
7591
|
+
(searchFormConfig === null || searchFormConfig === void 0 ? void 0 : searchFormConfig.handleSubmit) && searchFormConfig.handleSubmit((_searchFormRef$curren = searchFormRef.current) === null || _searchFormRef$curren === void 0 ? void 0 : _searchFormRef$curren.getFormValues());
|
7592
|
+
formSearchRef.current = (_searchFormRef$curren2 = searchFormRef.current) === null || _searchFormRef$curren2 === void 0 ? void 0 : _searchFormRef$curren2.getFormValues();
|
7593
|
+
actionRef === null || actionRef === void 0 ? void 0 : (_actionRef$current7 = actionRef.current) === null || _actionRef$current7 === void 0 ? void 0 : _actionRef$current7.reload(true);
|
7594
|
+
}
|
7595
|
+
};
|
7596
|
+
|
7562
7597
|
var onReset = function onReset(values) {
|
7563
|
-
var _actionRef$
|
7598
|
+
var _actionRef$current8;
|
7564
7599
|
|
7565
7600
|
(searchFormConfig === null || searchFormConfig === void 0 ? void 0 : searchFormConfig.onReset) && searchFormConfig.onReset();
|
7566
7601
|
formSearchRef.current = _objectSpread2({}, values);
|
7567
|
-
actionRef === null || actionRef === void 0 ? void 0 : (_actionRef$
|
7602
|
+
actionRef === null || actionRef === void 0 ? void 0 : (_actionRef$current8 = actionRef.current) === null || _actionRef$current8 === void 0 ? void 0 : _actionRef$current8.reload(true);
|
7568
7603
|
};
|
7569
7604
|
|
7570
7605
|
useEffect(function () {
|
7571
|
-
var _searchFormRef$
|
7606
|
+
var _searchFormRef$curren3, _searchFormRef$curren4;
|
7572
7607
|
|
7573
|
-
if ((_searchFormRef$
|
7574
|
-
var _searchFormRef$
|
7608
|
+
if ((_searchFormRef$curren3 = searchFormRef.current) === null || _searchFormRef$curren3 === void 0 ? void 0 : (_searchFormRef$curren4 = _searchFormRef$curren3.form) === null || _searchFormRef$curren4 === void 0 ? void 0 : _searchFormRef$curren4.getFieldsValue) {
|
7609
|
+
var _searchFormRef$curren5;
|
7575
7610
|
|
7576
7611
|
var obj = // filterObj(searchFormRef.current?.form?.getFieldsValue()) || {};
|
7577
|
-
filterObj((_searchFormRef$
|
7612
|
+
filterObj((_searchFormRef$curren5 = searchFormRef.current) === null || _searchFormRef$curren5 === void 0 ? void 0 : _searchFormRef$curren5.handleSearch(true)) || {};
|
7578
7613
|
(columns || []).filter(function (c) {
|
7579
7614
|
return c.notInitialValueInSearch;
|
7580
7615
|
}).forEach(function (item) {
|
@@ -7720,6 +7755,7 @@ var TabelCard = function TabelCard(props, ref) {
|
|
7720
7755
|
}),
|
7721
7756
|
onSubmit: onSubmit,
|
7722
7757
|
onReset: onReset,
|
7758
|
+
onKeyUp: onKeyUpSubmit,
|
7723
7759
|
columns: formSearchColumn.reduce(function (pre, column) {
|
7724
7760
|
if (column.type == 'group') {
|
7725
7761
|
return [].concat(_toConsumableArray(pre), _toConsumableArray(column.children));
|
@@ -11484,14 +11520,14 @@ function DhPlayer(_ref, ref) {
|
|
11484
11520
|
|
11485
11521
|
var index$7 = /*#__PURE__*/forwardRef(DhPlayer);
|
11486
11522
|
|
11487
|
-
var _excluded$m = ["id", "videoUrls", "definitionList", "isLoop", "muted", "currentIndex", "setCurrentIndex", "className", "style", "
|
11523
|
+
var _excluded$m = ["id", "videoUrls", "definitionList", "isLoop", "muted", "currentIndex", "setCurrentIndex", "className", "style", "open", "autoplay", "videoInit", "enableMemory", "lastPlayTimeHideDelay"];
|
11488
11524
|
|
11489
11525
|
var DEFAULT_PLAY_BACK_RATE = [0.5, 0.75, 1, 1.5, 2]; // 默认记忆提示文字展示时长(s)
|
11490
11526
|
|
11491
11527
|
var DEFAULT_LAST_PLAY_TIME_DELAY = 5; // 默认音量大小
|
11492
11528
|
|
11493
11529
|
var DEFAULT_VOLUME = 0.6;
|
11494
|
-
var index$8 =
|
11530
|
+
var index$8 = (function (_ref) {
|
11495
11531
|
var id = _ref.id,
|
11496
11532
|
_ref$videoUrls = _ref.videoUrls,
|
11497
11533
|
videoUrls = _ref$videoUrls === void 0 ? [] : _ref$videoUrls,
|
@@ -11505,8 +11541,8 @@ var index$8 = /*#__PURE__*/forwardRef(function (_ref, playerRef) {
|
|
11505
11541
|
setParentIndex = _ref.setCurrentIndex,
|
11506
11542
|
className = _ref.className,
|
11507
11543
|
style = _ref.style,
|
11508
|
-
_ref$
|
11509
|
-
|
11544
|
+
_ref$open = _ref.open,
|
11545
|
+
open = _ref$open === void 0 ? true : _ref$open,
|
11510
11546
|
_ref$autoplay = _ref.autoplay,
|
11511
11547
|
autoplay = _ref$autoplay === void 0 ? false : _ref$autoplay,
|
11512
11548
|
_ref$videoInit = _ref.videoInit,
|
@@ -11518,26 +11554,19 @@ var index$8 = /*#__PURE__*/forwardRef(function (_ref, playerRef) {
|
|
11518
11554
|
props = _objectWithoutProperties(_ref, _excluded$m);
|
11519
11555
|
|
11520
11556
|
var player = useRef();
|
11521
|
-
|
11522
|
-
var _useState = useState(true),
|
11523
|
-
_useState2 = _slicedToArray(_useState, 2),
|
11524
|
-
firstRender = _useState2[0],
|
11525
|
-
setFirstRender = _useState2[1];
|
11526
|
-
|
11527
|
-
var _useState3 = useState(false),
|
11528
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
11529
|
-
ready = _useState4[0],
|
11530
|
-
setReady = _useState4[1];
|
11531
|
-
|
11532
11557
|
var currentPlayerIndex = useRef(0); // 内置的 index 状态管理
|
11533
11558
|
|
11534
|
-
var
|
11535
|
-
|
11536
|
-
videoIndex =
|
11537
|
-
setVideoIndex =
|
11538
|
-
|
11539
|
-
var currentIndex =
|
11540
|
-
|
11559
|
+
var _useState = useState(0),
|
11560
|
+
_useState2 = _slicedToArray(_useState, 2),
|
11561
|
+
videoIndex = _useState2[0],
|
11562
|
+
setVideoIndex = _useState2[1];
|
11563
|
+
|
11564
|
+
var currentIndex = useMemo(function () {
|
11565
|
+
return parentIndex !== null && parentIndex !== void 0 ? parentIndex : videoIndex;
|
11566
|
+
}, [parentIndex, videoIndex]);
|
11567
|
+
var setCurrentIndex = useMemo(function () {
|
11568
|
+
return setParentIndex !== null && setParentIndex !== void 0 ? setParentIndex : setVideoIndex;
|
11569
|
+
}, [setParentIndex, setVideoIndex]);
|
11541
11570
|
var config = useRef(_objectSpread2({
|
11542
11571
|
url: videoUrls[0],
|
11543
11572
|
playbackRate: DEFAULT_PLAY_BACK_RATE,
|
@@ -11551,52 +11580,25 @@ var index$8 = /*#__PURE__*/forwardRef(function (_ref, playerRef) {
|
|
11551
11580
|
}, props));
|
11552
11581
|
/** 设置当前播放 index */
|
11553
11582
|
|
11554
|
-
var handleSetCurrentIndex = useCallback(function (
|
11555
|
-
var currentIdx = _ref2.currentIdx,
|
11556
|
-
videoUrls = _ref2.videoUrls;
|
11583
|
+
var handleSetCurrentIndex = useCallback(function (currentIdx) {
|
11557
11584
|
var newIdx = currentIdx !== null && currentIdx !== void 0 ? currentIdx : currentPlayerIndex.current + 1;
|
11558
11585
|
|
11559
11586
|
if (newIdx >= videoUrls.length) {
|
11560
|
-
|
11587
|
+
if (isLoop) {
|
11588
|
+
// 允许循环则播放起始视频
|
11589
|
+
newIdx = 0;
|
11590
|
+
} else if (player.current && player.current.video) {
|
11591
|
+
// 不允许循环则进度条快进到最后
|
11592
|
+
player.current.currentTime = player.current.video.duration;
|
11593
|
+
return;
|
11594
|
+
}
|
11561
11595
|
}
|
11562
11596
|
|
11563
11597
|
setCurrentIndex(newIdx);
|
11564
|
-
}, [setCurrentIndex]);
|
11565
|
-
/** 结束事件 */
|
11566
|
-
|
11567
|
-
var onEnd = useCallback(function (isLoop, videoUrls) {
|
11568
|
-
return function () {
|
11569
|
-
// 如果是循环或有其他视频未播放完,继续播放下一个
|
11570
|
-
if (isLoop || !isLoop && currentPlayerIndex.current < videoUrls.length - 1) {
|
11571
|
-
setTimeout(function () {
|
11572
|
-
var _player$current;
|
11573
|
-
|
11574
|
-
return (_player$current = player.current) === null || _player$current === void 0 ? void 0 : _player$current.play();
|
11575
|
-
});
|
11576
|
-
}
|
11577
|
-
|
11578
|
-
handleSetCurrentIndex({
|
11579
|
-
videoUrls: videoUrls
|
11580
|
-
});
|
11581
|
-
};
|
11582
|
-
}, [handleSetCurrentIndex]);
|
11583
|
-
/** 点击下一个事件 */
|
11584
|
-
|
11585
|
-
var onPlayNextBtnClick = useCallback(function (videoUrls) {
|
11586
|
-
return function () {
|
11587
|
-
if (player.current) {
|
11588
|
-
// 防止 next 按钮消失
|
11589
|
-
player.current.currentVideoIndex = videoUrls.length - 2;
|
11590
|
-
}
|
11591
|
-
|
11592
|
-
handleSetCurrentIndex({
|
11593
|
-
videoUrls: videoUrls
|
11594
|
-
});
|
11595
|
-
};
|
11596
|
-
}, [handleSetCurrentIndex]);
|
11598
|
+
}, [isLoop, setCurrentIndex, videoUrls.length]);
|
11597
11599
|
/** 播放下一个 */
|
11598
11600
|
|
11599
|
-
var handlePlayNext = useCallback(function (currentIdx
|
11601
|
+
var handlePlayNext = useCallback(function (currentIdx) {
|
11600
11602
|
if (!player.current) {
|
11601
11603
|
return;
|
11602
11604
|
}
|
@@ -11610,7 +11612,7 @@ var index$8 = /*#__PURE__*/forwardRef(function (_ref, playerRef) {
|
|
11610
11612
|
// 防止 next 按钮消失
|
11611
11613
|
player.current.currentVideoIndex = -videoUrls.length;
|
11612
11614
|
}
|
11613
|
-
}, [videoUrls]);
|
11615
|
+
}, [videoUrls, isLoop]);
|
11614
11616
|
/** 重置视频 */
|
11615
11617
|
|
11616
11618
|
var handleReset = useCallback(function () {
|
@@ -11626,47 +11628,47 @@ var index$8 = /*#__PURE__*/forwardRef(function (_ref, playerRef) {
|
|
11626
11628
|
/** 弹窗中的视频关闭以后重置 */
|
11627
11629
|
|
11628
11630
|
useEffect(function () {
|
11629
|
-
if (!
|
11631
|
+
if (!open) {
|
11630
11632
|
handleReset();
|
11631
11633
|
}
|
11632
|
-
}, [handleReset,
|
11634
|
+
}, [handleReset, open]);
|
11633
11635
|
/** 当 currentIndex 改变以后自动播放下一个 */
|
11634
11636
|
|
11635
11637
|
useEffect(function () {
|
11636
|
-
if (!player.current || !
|
11638
|
+
if (!player.current || !open) {
|
11637
11639
|
return;
|
11638
11640
|
}
|
11639
11641
|
|
11640
|
-
handlePlayNext(currentIndex !== null && currentIndex !== void 0 ? currentIndex : currentPlayerIndex.current
|
11641
|
-
}, [currentIndex, handlePlayNext,
|
11642
|
+
handlePlayNext(currentIndex !== null && currentIndex !== void 0 ? currentIndex : currentPlayerIndex.current);
|
11643
|
+
}, [currentIndex, handlePlayNext, open]);
|
11642
11644
|
/** 播放器初始化并绑定事件 */
|
11643
11645
|
|
11644
11646
|
useEffect(function () {
|
11645
|
-
|
11646
|
-
|
11647
|
-
if (!visible || isEmpty(videoUrls) || player.current) {
|
11647
|
+
if (!open || isEmpty(videoUrls) || player.current) {
|
11648
11648
|
return;
|
11649
11649
|
}
|
11650
11650
|
|
11651
|
-
|
11652
|
-
|
11653
|
-
|
11654
|
-
|
11655
|
-
|
11656
|
-
|
11651
|
+
player.current = new Player(config.current);
|
11652
|
+
player.current.currentVideoIndex = -videoUrls.length;
|
11653
|
+
player.current.on('ended', function () {
|
11654
|
+
// 如果是循环或有其他视频未播放完,继续播放下一个
|
11655
|
+
if (isLoop || !isLoop && currentPlayerIndex.current < videoUrls.length - 1) {
|
11656
|
+
handleSetCurrentIndex();
|
11657
|
+
setTimeout(function () {
|
11658
|
+
var _player$current;
|
11657
11659
|
|
11658
|
-
|
11659
|
-
|
11660
|
+
return (_player$current = player.current) === null || _player$current === void 0 ? void 0 : _player$current.play();
|
11661
|
+
});
|
11662
|
+
} else {
|
11663
|
+
var _player$current2;
|
11660
11664
|
|
11661
|
-
|
11662
|
-
|
11663
|
-
|
11665
|
+
(_player$current2 = player.current) === null || _player$current2 === void 0 ? void 0 : _player$current2.pause();
|
11666
|
+
}
|
11667
|
+
}); // 播放记忆缓存
|
11664
11668
|
|
11665
11669
|
if (enableMemory) {
|
11666
|
-
var _player$current2;
|
11667
|
-
|
11668
11670
|
var videoPlayedTimeObj = JSON.parse(localStorage.getItem('videoPlayedTime') || '{}');
|
11669
|
-
|
11671
|
+
player.current.on('timeupdate', function () {
|
11670
11672
|
var _player$current3;
|
11671
11673
|
|
11672
11674
|
if (currentPlayerIndex.current === -1) {
|
@@ -11680,23 +11682,27 @@ var index$8 = /*#__PURE__*/forwardRef(function (_ref, playerRef) {
|
|
11680
11682
|
});
|
11681
11683
|
}
|
11682
11684
|
|
11683
|
-
|
11684
|
-
|
11685
|
+
player.current.on('playNextBtnClick', function () {
|
11686
|
+
if (!isLoop && player.current) {
|
11687
|
+
// 防止 next 按钮消失
|
11688
|
+
player.current.currentVideoIndex = videoUrls.length - 2;
|
11689
|
+
}
|
11690
|
+
|
11691
|
+
handleSetCurrentIndex();
|
11692
|
+
});
|
11693
|
+
}, [autoplay, enableMemory, handleSetCurrentIndex, id, isLoop, videoUrls, videoUrls.length, open]);
|
11685
11694
|
/** 读取缓存的播放记忆并跳转 */
|
11686
11695
|
|
11687
11696
|
useEffect(function () {
|
11688
|
-
if (enableMemory &&
|
11697
|
+
if (enableMemory && open) {
|
11689
11698
|
var _JSON$parse;
|
11690
11699
|
|
11691
|
-
var
|
11692
|
-
lastPlayTime =
|
11693
|
-
_videoIndex =
|
11700
|
+
var _ref2 = ((_JSON$parse = JSON.parse(localStorage.getItem('videoPlayedTime') || '{}')) === null || _JSON$parse === void 0 ? void 0 : _JSON$parse[id]) || {},
|
11701
|
+
lastPlayTime = _ref2.lastPlayTime,
|
11702
|
+
_videoIndex = _ref2.videoIndex;
|
11694
11703
|
|
11695
11704
|
setTimeout(function () {
|
11696
|
-
handleSetCurrentIndex(
|
11697
|
-
currentIdx: _videoIndex,
|
11698
|
-
videoUrls: videoUrls
|
11699
|
-
});
|
11705
|
+
handleSetCurrentIndex(_videoIndex);
|
11700
11706
|
setTimeout(function () {
|
11701
11707
|
if (player.current) {
|
11702
11708
|
player.current.currentTime = lastPlayTime;
|
@@ -11704,7 +11710,7 @@ var index$8 = /*#__PURE__*/forwardRef(function (_ref, playerRef) {
|
|
11704
11710
|
});
|
11705
11711
|
});
|
11706
11712
|
}
|
11707
|
-
}, [
|
11713
|
+
}, [open, enableMemory, handleSetCurrentIndex, id]);
|
11708
11714
|
/** 加载清晰度配置 */
|
11709
11715
|
|
11710
11716
|
useEffect(function () {
|
@@ -11712,23 +11718,10 @@ var index$8 = /*#__PURE__*/forwardRef(function (_ref, playerRef) {
|
|
11712
11718
|
player.current.emit('resourceReady', definitionList[currentIndex]);
|
11713
11719
|
}
|
11714
11720
|
}, [currentIndex, definitionList]);
|
11715
|
-
|
11716
|
-
|
11717
|
-
|
11718
|
-
if (firstRender) {
|
11719
|
-
return;
|
11720
|
-
}
|
11721
|
-
|
11722
|
-
(_player$current5 = player.current) === null || _player$current5 === void 0 ? void 0 : _player$current5.off('ended', onEnd(isLoop, videoUrls));
|
11723
|
-
(_player$current6 = player.current) === null || _player$current6 === void 0 ? void 0 : _player$current6.off('playNextBtnClick', onPlayNextBtnClick(videoUrls));
|
11724
|
-
(_player$current7 = player.current) === null || _player$current7 === void 0 ? void 0 : _player$current7.destroy();
|
11725
|
-
player.current = undefined;
|
11726
|
-
setReady(true); // eslint-disable-next-line react-hooks/exhaustive-deps
|
11727
|
-
}, [muted, isLoop, videoUrls, autoplay, videoInit, onEnd, onPlayNextBtnClick]);
|
11728
|
-
var getRef = useCallback(function (r) {
|
11729
|
-
if (r && visible) {
|
11721
|
+
var getRef = useCallback(function (ref) {
|
11722
|
+
if (ref && open) {
|
11730
11723
|
var newConfig = _objectSpread2(_objectSpread2({}, config.current), {}, {
|
11731
|
-
el:
|
11724
|
+
el: ref,
|
11732
11725
|
url: videoUrls[0],
|
11733
11726
|
playNext: {
|
11734
11727
|
urlList: videoUrls.slice(1)
|
@@ -11738,8 +11731,8 @@ var index$8 = /*#__PURE__*/forwardRef(function (_ref, playerRef) {
|
|
11738
11731
|
if (enableMemory) {
|
11739
11732
|
var _JSON$parse2;
|
11740
11733
|
|
11741
|
-
var
|
11742
|
-
lastPlayTime =
|
11734
|
+
var _ref3 = ((_JSON$parse2 = JSON.parse(localStorage.getItem('videoPlayedTime') || '{}')) === null || _JSON$parse2 === void 0 ? void 0 : _JSON$parse2[id]) || {},
|
11735
|
+
lastPlayTime = _ref3.lastPlayTime;
|
11743
11736
|
|
11744
11737
|
Object.assign(newConfig, {
|
11745
11738
|
lastPlayTime: lastPlayTime,
|
@@ -11749,15 +11742,7 @@ var index$8 = /*#__PURE__*/forwardRef(function (_ref, playerRef) {
|
|
11749
11742
|
|
11750
11743
|
config.current = newConfig;
|
11751
11744
|
}
|
11752
|
-
|
11753
|
-
if (playerRef) {
|
11754
|
-
if (typeof playerRef === 'function') {
|
11755
|
-
playerRef(player.current);
|
11756
|
-
} else {
|
11757
|
-
playerRef.current = player.current;
|
11758
|
-
}
|
11759
|
-
}
|
11760
|
-
}, [visible, playerRef, videoUrls, enableMemory, id, lastPlayTimeHideDelay]);
|
11745
|
+
}, [open, id, videoUrls, lastPlayTimeHideDelay, enableMemory]);
|
11761
11746
|
return /*#__PURE__*/React.createElement("div", {
|
11762
11747
|
className: className,
|
11763
11748
|
ref: getRef,
|