@cloud-app-dev/vidc 3.0.0 → 3.0.1
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/es/ErrorBoundary/index.d.ts +2 -2
- package/es/ErrorBoundary/index.js +2 -7
- package/es/Map/BasicMap/index.js +3 -8
- package/es/Modal/index.js +7 -5
- package/es/Picture/component/RectMenu/index.d.ts +1 -1
- package/es/Player/api/index.d.ts +0 -8
- package/es/Player/api/index.js +20 -34
- package/es/Player/contraller_bar/left_bar.js +2 -2
- package/es/Player/contraller_bar/right_bar.d.ts +1 -1
- package/es/Player/contraller_bar/right_bar.js +13 -27
- package/es/Player/frontend_timeline.js +6 -5
- package/es/Player/segment_timeline.js +8 -7
- package/es/Player/util.d.ts +2 -24
- package/es/Player/util.js +43 -54
- package/es/PlayerExt/index.d.ts +1 -1
- package/es/ScreenPlayer/PlayerWithExt.d.ts +2 -2
- package/es/ScreenPlayer/index.d.ts +2 -3
- package/es/ScreenPlayer/index.js +4 -3
- package/es/ScreenPlayer/useRecordList.d.ts +1 -1
- package/es/ScreenPlayer/utils.d.ts +1 -1
- package/es/Timeout/index.d.ts +33 -0
- package/es/Timeout/index.js +83 -0
- package/es/index.d.ts +1 -0
- package/es/index.js +1 -0
- package/es/withErrorBoundary/index.d.ts +2 -1
- package/es/withErrorBoundary/index.js +4 -2
- package/package.json +1 -1
- package/release-build.sh +19 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { Component, ErrorInfo } from 'react';
|
|
2
2
|
export declare type IErrorBoundaryProps = {
|
|
3
|
-
fallback?:
|
|
3
|
+
fallback?: React.ReactNode;
|
|
4
4
|
children?: React.ReactNode;
|
|
5
5
|
};
|
|
6
6
|
declare type State = {
|
|
@@ -13,6 +13,6 @@ declare class ErrorBoundary extends Component<IErrorBoundaryProps, State> {
|
|
|
13
13
|
};
|
|
14
14
|
static getDerivedStateFromError(error: Error): State;
|
|
15
15
|
componentDidCatch(error: Error, info: ErrorInfo): void;
|
|
16
|
-
render():
|
|
16
|
+
render(): React.ReactNode;
|
|
17
17
|
}
|
|
18
18
|
export default ErrorBoundary;
|
|
@@ -53,13 +53,7 @@ var ErrorBoundary = /*#__PURE__*/function (_Component) {
|
|
|
53
53
|
fallback = _this$props.fallback;
|
|
54
54
|
|
|
55
55
|
if (error) {
|
|
56
|
-
|
|
57
|
-
return fallback;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (typeof fallback === 'function') {
|
|
61
|
-
return fallback();
|
|
62
|
-
}
|
|
56
|
+
return fallback;
|
|
63
57
|
}
|
|
64
58
|
|
|
65
59
|
return children;
|
|
@@ -67,6 +61,7 @@ var ErrorBoundary = /*#__PURE__*/function (_Component) {
|
|
|
67
61
|
}], [{
|
|
68
62
|
key: "getDerivedStateFromError",
|
|
69
63
|
value: function getDerivedStateFromError(error) {
|
|
64
|
+
console.error(error);
|
|
70
65
|
return {
|
|
71
66
|
error: true
|
|
72
67
|
};
|
package/es/Map/BasicMap/index.js
CHANGED
|
@@ -34,12 +34,12 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
34
34
|
|
|
35
35
|
var _super = _createSuper(Map);
|
|
36
36
|
|
|
37
|
-
function Map(
|
|
37
|
+
function Map() {
|
|
38
38
|
var _this;
|
|
39
39
|
|
|
40
40
|
_classCallCheck(this, Map);
|
|
41
41
|
|
|
42
|
-
_this = _super.
|
|
42
|
+
_this = _super.apply(this, arguments);
|
|
43
43
|
_this.domRef = /*#__PURE__*/React.createRef();
|
|
44
44
|
return _this;
|
|
45
45
|
}
|
|
@@ -51,8 +51,8 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
51
51
|
return;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
var instance = this.props.isL ? LeafletInstance : AMapInstance;
|
|
55
54
|
var mapOptions = this.props.config;
|
|
55
|
+
var instance = this.props.isL ? LeafletInstance : AMapInstance;
|
|
56
56
|
this.mapInstance = new instance(this.domRef.current, mapOptions);
|
|
57
57
|
this.mapInstance.createMap();
|
|
58
58
|
this.forceUpdate();
|
|
@@ -62,11 +62,6 @@ var Map = /*#__PURE__*/function (_React$Component) {
|
|
|
62
62
|
value: function componentWillUnmount() {
|
|
63
63
|
this.mapInstance.destoryMap();
|
|
64
64
|
}
|
|
65
|
-
}, {
|
|
66
|
-
key: "componentDidCatch",
|
|
67
|
-
value: function componentDidCatch(error, errorInfo) {
|
|
68
|
-
console.log(error, errorInfo);
|
|
69
|
-
}
|
|
70
65
|
}, {
|
|
71
66
|
key: "render",
|
|
72
67
|
value: function render() {
|
package/es/Modal/index.js
CHANGED
|
@@ -19,8 +19,8 @@ import { __rest } from "tslib";
|
|
|
19
19
|
import React, { useContext, useEffect, useImperativeHandle, useMemo, useState } from 'react';
|
|
20
20
|
import * as ReactDOMClient from 'react-dom/client';
|
|
21
21
|
import CC from '../ConfigContext';
|
|
22
|
-
import "./index.css";
|
|
23
22
|
import ConfigContext from '../ConfigContext';
|
|
23
|
+
import "./index.css";
|
|
24
24
|
|
|
25
25
|
function Modal(_a) {
|
|
26
26
|
var children = _a.children,
|
|
@@ -69,15 +69,16 @@ function useModal() {
|
|
|
69
69
|
|
|
70
70
|
var root = useMemo(function () {
|
|
71
71
|
return ReactDOMClient.createRoot(div);
|
|
72
|
-
}, []);
|
|
72
|
+
}, [div]);
|
|
73
73
|
useEffect(function () {
|
|
74
74
|
container.appendChild(div);
|
|
75
75
|
return function () {
|
|
76
|
+
// eslint-disable-next-line no-sequences
|
|
76
77
|
setTimeout(function () {
|
|
77
78
|
return root.unmount(), div.remove();
|
|
78
79
|
}, 100);
|
|
79
80
|
};
|
|
80
|
-
}, []);
|
|
81
|
+
}, [container, div, root]);
|
|
81
82
|
useEffect(function () {
|
|
82
83
|
root.render( /*#__PURE__*/React.createElement(_ConfigProvider, {
|
|
83
84
|
prefixCls: prefixCls,
|
|
@@ -96,7 +97,7 @@ function useModal() {
|
|
|
96
97
|
className: state.className,
|
|
97
98
|
getContainer: false
|
|
98
99
|
}, state.content)));
|
|
99
|
-
}, [state.content, state.visible, state.title, state.onOk, state.width, state.className]);
|
|
100
|
+
}, [state.content, state.visible, state.title, state.onOk, state.width, state.className, root, prefixCls, container]);
|
|
100
101
|
|
|
101
102
|
var open = function open(options) {
|
|
102
103
|
setState(function (old) {
|
|
@@ -152,7 +153,8 @@ var RefModal = /*#__PURE__*/React.forwardRef(function RefModal(_, ref) {
|
|
|
152
153
|
visible: false
|
|
153
154
|
});
|
|
154
155
|
});
|
|
155
|
-
};
|
|
156
|
+
}; // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
157
|
+
|
|
156
158
|
|
|
157
159
|
useImperativeHandle(ref, function () {
|
|
158
160
|
return {
|
package/es/Player/api/index.d.ts
CHANGED
|
@@ -5,14 +5,6 @@ declare class Api {
|
|
|
5
5
|
container: HTMLElement;
|
|
6
6
|
constructor(container: HTMLElement);
|
|
7
7
|
get video(): HTMLVideoElement;
|
|
8
|
-
/**
|
|
9
|
-
* 全屏
|
|
10
|
-
*/
|
|
11
|
-
requestFullScreen: () => void;
|
|
12
|
-
/**
|
|
13
|
-
* 退出全屏
|
|
14
|
-
*/
|
|
15
|
-
cancelFullScreen: () => void;
|
|
16
8
|
play: () => void;
|
|
17
9
|
pause: () => void;
|
|
18
10
|
/**
|
package/es/Player/api/index.js
CHANGED
|
@@ -19,7 +19,7 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
|
|
|
19
19
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
20
20
|
|
|
21
21
|
import { useEffect, useState } from 'react';
|
|
22
|
-
import {
|
|
22
|
+
import { createFlvPlayer, createHlsPlayer, tryCatch } from '../util';
|
|
23
23
|
|
|
24
24
|
var Api = /*#__PURE__*/function () {
|
|
25
25
|
function Api(container) {
|
|
@@ -27,29 +27,10 @@ var Api = /*#__PURE__*/function () {
|
|
|
27
27
|
|
|
28
28
|
_classCallCheck(this, Api);
|
|
29
29
|
|
|
30
|
-
/**
|
|
31
|
-
* 全屏
|
|
32
|
-
*/
|
|
33
|
-
this.requestFullScreen = function () {
|
|
34
|
-
if (!isFullscreen(_this.container)) {
|
|
35
|
-
fullscreen(_this.container);
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
/**
|
|
39
|
-
* 退出全屏
|
|
40
|
-
*/
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
this.cancelFullScreen = function () {
|
|
44
|
-
if (isFullscreen(_this.container)) {
|
|
45
|
-
exitFullscreen();
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
|
|
49
30
|
this.play = function () {
|
|
50
|
-
|
|
51
|
-
_this.video.play();
|
|
52
|
-
}
|
|
31
|
+
tryCatch(function () {
|
|
32
|
+
return _this.video.play();
|
|
33
|
+
});
|
|
53
34
|
};
|
|
54
35
|
|
|
55
36
|
this.pause = function () {
|
|
@@ -243,24 +224,29 @@ export function useTypeAndPlay(url, type, isLive, container, segments, flvConfig
|
|
|
243
224
|
video.setAttribute('src', url);
|
|
244
225
|
}
|
|
245
226
|
|
|
246
|
-
|
|
247
|
-
video.play();
|
|
248
|
-
}
|
|
249
|
-
|
|
227
|
+
url && video.paused && tryCatch(function () {
|
|
228
|
+
return video.play();
|
|
229
|
+
});
|
|
250
230
|
setState(options);
|
|
251
231
|
return function () {
|
|
252
232
|
if (options.flv) {
|
|
253
|
-
options.flv.
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
233
|
+
options.flv.pause();
|
|
234
|
+
tryCatch(function () {
|
|
235
|
+
return options.flv.destroy();
|
|
236
|
+
});
|
|
237
|
+
} else if (options.hls) {
|
|
238
|
+
video.pause();
|
|
239
|
+
tryCatch(function () {
|
|
240
|
+
return options.hls.destroy();
|
|
241
|
+
});
|
|
242
|
+
} else {
|
|
243
|
+
video.pause();
|
|
244
|
+
video.removeAttribute('src');
|
|
258
245
|
}
|
|
259
246
|
|
|
260
|
-
video.removeAttribute('src');
|
|
261
247
|
setState({});
|
|
262
248
|
};
|
|
263
|
-
}, [url, container, segments, type]);
|
|
249
|
+
}, [url, container, segments, type, isLive, flvConfig, hlsConfig]);
|
|
264
250
|
return [state.type, state.flv, state.hls];
|
|
265
251
|
} //创建Api
|
|
266
252
|
|
|
@@ -46,6 +46,7 @@ function LeftBar(_ref) {
|
|
|
46
46
|
};
|
|
47
47
|
}, [event]);
|
|
48
48
|
var video = container.querySelector('video'); //缓存值
|
|
49
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
49
50
|
|
|
50
51
|
var paused = useMemo(function () {
|
|
51
52
|
return video === null || video === void 0 ? void 0 : video.paused;
|
|
@@ -60,7 +61,6 @@ function LeftBar(_ref) {
|
|
|
60
61
|
var _useTimes = useTimes(api, event, hideTimeProgress),
|
|
61
62
|
_useTimes2 = _slicedToArray(_useTimes, 3),
|
|
62
63
|
current = _useTimes2[0],
|
|
63
|
-
_ = _useTimes2[1],
|
|
64
64
|
duration = _useTimes2[2]; //TODO 方法
|
|
65
65
|
|
|
66
66
|
|
|
@@ -72,7 +72,7 @@ function LeftBar(_ref) {
|
|
|
72
72
|
} else {
|
|
73
73
|
api.pause();
|
|
74
74
|
}
|
|
75
|
-
}, [video, api
|
|
75
|
+
}, [video, api]);
|
|
76
76
|
return /*#__PURE__*/React.createElement("div", {
|
|
77
77
|
className: "contraller-left-bar"
|
|
78
78
|
}, leftExtContents, /*#__PURE__*/React.createElement(Bar, null, /*#__PURE__*/React.createElement(IconFont, {
|
|
@@ -9,5 +9,5 @@ interface IRightBarProps {
|
|
|
9
9
|
rightExtContents: React.ReactNode;
|
|
10
10
|
rightMidExtContents: React.ReactNode;
|
|
11
11
|
}
|
|
12
|
-
declare function RightBar({ container,
|
|
12
|
+
declare function RightBar({ container, rightExtContents, rightMidExtContents }: IRightBarProps): JSX.Element;
|
|
13
13
|
export default RightBar;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import _useFullscreen3 from "ahooks/es/useFullscreen";
|
|
2
|
+
|
|
1
3
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
4
|
|
|
3
5
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
@@ -10,45 +12,29 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
|
|
|
10
12
|
|
|
11
13
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
14
|
|
|
13
|
-
import React
|
|
15
|
+
import React from 'react';
|
|
14
16
|
import IconFont from '../iconfont';
|
|
15
17
|
import Bar from './bar';
|
|
16
|
-
import { isFullscreen } from '../util';
|
|
17
18
|
|
|
18
19
|
function RightBar(_ref) {
|
|
19
20
|
var container = _ref.container,
|
|
20
|
-
api = _ref.api,
|
|
21
21
|
rightExtContents = _ref.rightExtContents,
|
|
22
22
|
rightMidExtContents = _ref.rightMidExtContents;
|
|
23
23
|
|
|
24
|
-
var
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
document.addEventListener('fullscreenchange', update);
|
|
35
|
-
return function () {
|
|
36
|
-
return document.removeEventListener('fullscreenchange', update);
|
|
37
|
-
};
|
|
38
|
-
}, []);
|
|
39
|
-
var isfull = useMemo(function () {
|
|
40
|
-
return isFullscreen(container);
|
|
41
|
-
}, [dep, container]);
|
|
42
|
-
var fullscreen = useCallback(function () {
|
|
43
|
-
!isFullscreen(container) ? api.requestFullScreen() : api.cancelFullScreen();
|
|
44
|
-
setDep(Date.now());
|
|
45
|
-
}, [api, container]);
|
|
24
|
+
var _useFullscreen = _useFullscreen3(container),
|
|
25
|
+
_useFullscreen2 = _slicedToArray(_useFullscreen, 2),
|
|
26
|
+
isFullScreen = _useFullscreen2[0],
|
|
27
|
+
_useFullscreen2$ = _useFullscreen2[1],
|
|
28
|
+
enterFullscreen = _useFullscreen2$.enterFullscreen,
|
|
29
|
+
exitFullscreen = _useFullscreen2$.exitFullscreen;
|
|
30
|
+
|
|
31
|
+
var fullscreen = isFullScreen ? exitFullscreen : enterFullscreen;
|
|
46
32
|
return /*#__PURE__*/React.createElement("div", {
|
|
47
33
|
className: "contraller-right-bar"
|
|
48
34
|
}, rightMidExtContents, /*#__PURE__*/React.createElement(Bar, null, /*#__PURE__*/React.createElement(IconFont, {
|
|
49
|
-
title:
|
|
35
|
+
title: isFullScreen ? '窗口' : '全屏',
|
|
50
36
|
onClick: fullscreen,
|
|
51
|
-
type:
|
|
37
|
+
type: isFullScreen ? 'lm-player-ExitFull_Main' : 'lm-player-Full_Main'
|
|
52
38
|
})), rightExtContents);
|
|
53
39
|
}
|
|
54
40
|
|
|
@@ -13,7 +13,8 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
13
13
|
import React, { useCallback, useEffect, useMemo, useState, startTransition } from 'react';
|
|
14
14
|
import useBarStatus from './contraller_bar/useBarStatus';
|
|
15
15
|
import { useTimes } from './timeline';
|
|
16
|
-
import {
|
|
16
|
+
import { FMT } from './util';
|
|
17
|
+
import moment from 'moment';
|
|
17
18
|
import "./style/timeline.css";
|
|
18
19
|
|
|
19
20
|
function FrontendTimeLine(_ref) {
|
|
@@ -52,7 +53,7 @@ function FrontendTimeLine(_ref) {
|
|
|
52
53
|
}, [begin]);
|
|
53
54
|
var playPercent = useMemo(function () {
|
|
54
55
|
return rTime / duration * 100;
|
|
55
|
-
}, [rTime]);
|
|
56
|
+
}, [duration, rTime]);
|
|
56
57
|
var cTime = useMemo(function () {
|
|
57
58
|
return begin + rTime * 1000;
|
|
58
59
|
}, [begin, rTime]);
|
|
@@ -67,7 +68,7 @@ function FrontendTimeLine(_ref) {
|
|
|
67
68
|
time: cTime - currentTime
|
|
68
69
|
});
|
|
69
70
|
});
|
|
70
|
-
}, [
|
|
71
|
+
}, [duration, begin, onSeek, currentTime]);
|
|
71
72
|
var onLineMouseOver = useCallback(function (e) {
|
|
72
73
|
var rect = e.currentTarget.getBoundingClientRect();
|
|
73
74
|
var left = e.pageX - rect.left;
|
|
@@ -78,7 +79,7 @@ function FrontendTimeLine(_ref) {
|
|
|
78
79
|
markTime: begin + mTime * 1000
|
|
79
80
|
});
|
|
80
81
|
});
|
|
81
|
-
}, [begin]);
|
|
82
|
+
}, [begin, duration]);
|
|
82
83
|
var onLineMouseOut = useCallback(function (e) {
|
|
83
84
|
startTransition(function () {
|
|
84
85
|
return setState(function (old) {
|
|
@@ -132,7 +133,7 @@ function TipTitle(_ref2) {
|
|
|
132
133
|
style: {
|
|
133
134
|
fontWeight: 600
|
|
134
135
|
}
|
|
135
|
-
}, "\u5F55\u50CF\u4FE1\u606F"), /*#__PURE__*/React.createElement("div", null, "\u5F00\u59CB\uFF1A",
|
|
136
|
+
}, "\u5F55\u50CF\u4FE1\u606F"), /*#__PURE__*/React.createElement("div", null, "\u5F00\u59CB\uFF1A", moment(begin).format(FMT)), /*#__PURE__*/React.createElement("div", null, "\u7ED3\u675F\uFF1A", moment(end).format(FMT)), /*#__PURE__*/React.createElement("div", null, "\u523B\u5EA6\uFF1A", moment(markTime).format(FMT)), /*#__PURE__*/React.createElement("div", null, "\u5F53\u524D\uFF1A", moment(current).format(FMT)));
|
|
136
137
|
}
|
|
137
138
|
|
|
138
139
|
export default FrontendTimeLine;
|
|
@@ -16,7 +16,8 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
16
16
|
import React, { useCallback, useMemo } from 'react';
|
|
17
17
|
import { useTimes } from './timeline';
|
|
18
18
|
import useBarStatus from './contraller_bar/useBarStatus';
|
|
19
|
-
import
|
|
19
|
+
import moment from 'moment';
|
|
20
|
+
import { FMT } from './util';
|
|
20
21
|
import "./style/timeline.css";
|
|
21
22
|
|
|
22
23
|
function SegmentTimeLine(_ref) {
|
|
@@ -40,7 +41,7 @@ function SegmentTimeLine(_ref) {
|
|
|
40
41
|
}).reduce(function (a, b, i) {
|
|
41
42
|
return i >= index ? a : a + b;
|
|
42
43
|
}, 0);
|
|
43
|
-
}, [index]);
|
|
44
|
+
}, [index, segments]);
|
|
44
45
|
var playPercent = useMemo(function () {
|
|
45
46
|
return (currentTime + indexDuration) / duration * 100;
|
|
46
47
|
}, [currentTime, duration, indexDuration]);
|
|
@@ -66,7 +67,7 @@ function SegmentTimeLine(_ref) {
|
|
|
66
67
|
} else {
|
|
67
68
|
api.seekTo(currentTime);
|
|
68
69
|
}
|
|
69
|
-
}, [api,
|
|
70
|
+
}, [segments, api, index, setIndex]);
|
|
70
71
|
return /*#__PURE__*/React.createElement("div", {
|
|
71
72
|
className: "player-timeline-layout player-segment-timeline-layout ".concat(status === 0 ? 'hide-time-line' : '')
|
|
72
73
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -113,8 +114,8 @@ function TipTitle(_ref2) {
|
|
|
113
114
|
var _end = begin + (segments[0].endTime - segments[0].beginTime);
|
|
114
115
|
|
|
115
116
|
return {
|
|
116
|
-
start:
|
|
117
|
-
end:
|
|
117
|
+
start: moment(_start).format(FMT),
|
|
118
|
+
end: moment(_end).format(FMT)
|
|
118
119
|
};
|
|
119
120
|
}
|
|
120
121
|
|
|
@@ -126,8 +127,8 @@ function TipTitle(_ref2) {
|
|
|
126
127
|
var start = begin + indexDuration;
|
|
127
128
|
var end = start + (segments[index].endTime - segments[index].beginTime);
|
|
128
129
|
return {
|
|
129
|
-
start:
|
|
130
|
-
end:
|
|
130
|
+
start: moment(start).format(FMT),
|
|
131
|
+
end: moment(end).format(FMT)
|
|
131
132
|
};
|
|
132
133
|
}, [index, segments, begin]),
|
|
133
134
|
start = _useMemo.start,
|
package/es/Player/util.d.ts
CHANGED
|
@@ -22,28 +22,6 @@ export declare const playUnload: (video: HTMLVideoElement, flv?: Flvjs.Player, h
|
|
|
22
22
|
*/
|
|
23
23
|
export declare function getVideoType(url: string): "flv" | "native" | "m3u8";
|
|
24
24
|
export declare function timeStamp(second: number): string;
|
|
25
|
-
/**
|
|
26
|
-
* 日期格式化
|
|
27
|
-
* @param {*} timetemp
|
|
28
|
-
*/
|
|
29
|
-
export declare function dateFormat(timetemp: number): string;
|
|
30
|
-
/**
|
|
31
|
-
* 全屏
|
|
32
|
-
* @param {*} element
|
|
33
|
-
*/
|
|
34
|
-
export declare function fullscreen(element: HTMLElement): void;
|
|
35
|
-
/**
|
|
36
|
-
* exitFullscreen 退出全屏
|
|
37
|
-
* @param {Objct} element 选择器
|
|
38
|
-
*/
|
|
39
|
-
export declare function exitFullscreen(): void;
|
|
40
|
-
/**
|
|
41
|
-
* 判读是否支持全屏
|
|
42
|
-
*/
|
|
43
|
-
export declare function fullscreenEnabled(): boolean;
|
|
44
|
-
/**
|
|
45
|
-
* [isFullscreen 判断浏览器是否全屏]
|
|
46
|
-
* @return [全屏则返回当前调用全屏的元素,不全屏返回false]
|
|
47
|
-
*/
|
|
48
|
-
export declare function isFullscreen(ele: HTMLElement): boolean;
|
|
49
25
|
export declare function getRandom(): string;
|
|
26
|
+
export declare function tryCatch(fn: () => void | Promise<any>): Promise<void>;
|
|
27
|
+
export declare const FMT = "YYYY-MM-DD HH:mm:ss";
|
package/es/Player/util.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
|
|
3
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
4
|
+
|
|
5
|
+
import { __awaiter } from "tslib";
|
|
1
6
|
import Flvjs from 'flv.zv.js';
|
|
2
7
|
import Hls from 'hls.js';
|
|
3
8
|
import Events from './event/eventName';
|
|
@@ -62,7 +67,9 @@ export var playReload = function playReload(video, event, flv, hls, url) {
|
|
|
62
67
|
if (flv) {
|
|
63
68
|
flv.unload();
|
|
64
69
|
flv.load();
|
|
65
|
-
|
|
70
|
+
tryCatch(function () {
|
|
71
|
+
return flv.play();
|
|
72
|
+
});
|
|
66
73
|
}
|
|
67
74
|
|
|
68
75
|
if (hls) {
|
|
@@ -71,12 +78,16 @@ export var playReload = function playReload(video, event, flv, hls, url) {
|
|
|
71
78
|
hls.stopLoad();
|
|
72
79
|
hls.startLoad();
|
|
73
80
|
hls.loadSource(url);
|
|
74
|
-
|
|
81
|
+
tryCatch(function () {
|
|
82
|
+
return video.play();
|
|
83
|
+
});
|
|
75
84
|
}
|
|
76
85
|
|
|
77
86
|
if (!flv && !hls) {
|
|
78
87
|
video.setAttribute('src', url);
|
|
79
|
-
|
|
88
|
+
tryCatch(function () {
|
|
89
|
+
return video.play();
|
|
90
|
+
});
|
|
80
91
|
}
|
|
81
92
|
|
|
82
93
|
event.emit(Events.RELOAD);
|
|
@@ -120,56 +131,34 @@ export function timeStamp(second) {
|
|
|
120
131
|
|
|
121
132
|
return "".concat(h < 10 ? '0' + h : h, ":").concat(m < 10 ? '0' + m : m, ":").concat(s < 10 ? '0' + s : s);
|
|
122
133
|
}
|
|
123
|
-
/**
|
|
124
|
-
* 日期格式化
|
|
125
|
-
* @param {*} timetemp
|
|
126
|
-
*/
|
|
127
|
-
|
|
128
|
-
export function dateFormat(timetemp) {
|
|
129
|
-
var date = new Date(timetemp);
|
|
130
|
-
var YYYY = date.getFullYear();
|
|
131
|
-
var DD = date.getDate();
|
|
132
|
-
var MM = date.getMonth() + 1;
|
|
133
|
-
var hh = date.getHours();
|
|
134
|
-
var mm = date.getMinutes();
|
|
135
|
-
var ss = date.getSeconds();
|
|
136
|
-
return "".concat(YYYY, ".").concat(MM > 9 ? MM : '0' + MM, ".").concat(DD > 9 ? DD : '0' + DD, " ").concat(hh > 9 ? hh : '0' + hh, ".").concat(mm > 9 ? mm : '0' + mm, ".").concat(ss > 9 ? ss : '0' + ss);
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* 全屏
|
|
140
|
-
* @param {*} element
|
|
141
|
-
*/
|
|
142
|
-
|
|
143
|
-
export function fullscreen(element) {
|
|
144
|
-
element.requestFullscreen();
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* exitFullscreen 退出全屏
|
|
148
|
-
* @param {Objct} element 选择器
|
|
149
|
-
*/
|
|
150
|
-
|
|
151
|
-
export function exitFullscreen() {
|
|
152
|
-
document.exitFullscreen();
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* 判读是否支持全屏
|
|
156
|
-
*/
|
|
157
|
-
|
|
158
|
-
export function fullscreenEnabled() {
|
|
159
|
-
return document.fullscreenEnabled;
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* [isFullscreen 判断浏览器是否全屏]
|
|
163
|
-
* @return [全屏则返回当前调用全屏的元素,不全屏返回false]
|
|
164
|
-
*/
|
|
165
|
-
|
|
166
|
-
export function isFullscreen(ele) {
|
|
167
|
-
if (!ele) {
|
|
168
|
-
return false;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
return document.fullscreenElement === ele;
|
|
172
|
-
}
|
|
173
134
|
export function getRandom() {
|
|
174
135
|
return Math.random().toString(36).substr(2);
|
|
175
|
-
}
|
|
136
|
+
}
|
|
137
|
+
export function tryCatch(fn) {
|
|
138
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
139
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
140
|
+
while (1) {
|
|
141
|
+
switch (_context.prev = _context.next) {
|
|
142
|
+
case 0:
|
|
143
|
+
_context.prev = 0;
|
|
144
|
+
_context.next = 3;
|
|
145
|
+
return fn();
|
|
146
|
+
|
|
147
|
+
case 3:
|
|
148
|
+
_context.next = 8;
|
|
149
|
+
break;
|
|
150
|
+
|
|
151
|
+
case 5:
|
|
152
|
+
_context.prev = 5;
|
|
153
|
+
_context.t0 = _context["catch"](0);
|
|
154
|
+
console.debug(_context.t0);
|
|
155
|
+
|
|
156
|
+
case 8:
|
|
157
|
+
case "end":
|
|
158
|
+
return _context.stop();
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}, _callee, null, [[0, 5]]);
|
|
162
|
+
}));
|
|
163
|
+
}
|
|
164
|
+
export var FMT = 'YYYY-MM-DD HH:mm:ss';
|
package/es/PlayerExt/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type { ExportPlayerType, ISegmentType, ISinglePlayerProps } from '
|
|
3
|
-
import type { PlayModeType } from '
|
|
2
|
+
import type { ExportPlayerType, ISegmentType, ISinglePlayerProps } from '../Player/player';
|
|
3
|
+
import type { PlayModeType } from '../PlayerExt';
|
|
4
4
|
interface ILivePlayerWithExtProps extends ISinglePlayerProps {
|
|
5
5
|
mode?: PlayModeType;
|
|
6
6
|
style: React.CSSProperties;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
declare const _default: {
|
|
1
|
+
declare const Sceenplayer: {
|
|
3
2
|
LivePlayer: import("react").ComponentType<import("./interface").ILivePlayerProps>;
|
|
4
3
|
RecordPlayer: import("react").ComponentType<import("./interface").IRecordPlayerProps>;
|
|
5
4
|
};
|
|
6
|
-
export default
|
|
5
|
+
export default Sceenplayer;
|
package/es/ScreenPlayer/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import withErrorBoundary from '
|
|
1
|
+
import withErrorBoundary from '../withErrorBoundary';
|
|
2
2
|
import LivePlayer from './Live';
|
|
3
3
|
import RecordPlayer from './Record';
|
|
4
|
-
|
|
4
|
+
var Sceenplayer = {
|
|
5
5
|
LivePlayer: withErrorBoundary(LivePlayer),
|
|
6
6
|
RecordPlayer: withErrorBoundary(RecordPlayer)
|
|
7
|
-
};
|
|
7
|
+
};
|
|
8
|
+
export default Sceenplayer;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { ISegmentType } from '
|
|
1
|
+
import { ISegmentType } from '../Player/player';
|
|
2
2
|
import { RecordItem } from './interface';
|
|
3
3
|
export default function useRecordList(list: RecordItem[], queryRecord: (options: any) => Promise<ISegmentType[]>): RecordItem[];
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { BasicTarget } from 'ahooks/es/utils/domTarget';
|
|
3
|
+
import 'antd/es/modal/style/css';
|
|
4
|
+
interface ITimeoutProps {
|
|
5
|
+
/**
|
|
6
|
+
*ß
|
|
7
|
+
*/
|
|
8
|
+
contianer?: BasicTarget;
|
|
9
|
+
/**
|
|
10
|
+
* 超时时长单位s
|
|
11
|
+
*/
|
|
12
|
+
time?: number;
|
|
13
|
+
/**
|
|
14
|
+
* 超时动作,默认退出登录
|
|
15
|
+
*/
|
|
16
|
+
onTimeout?: () => void;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
*/
|
|
21
|
+
declare function Timeout({ contianer, time, onTimeout }: ITimeoutProps): JSX.Element;
|
|
22
|
+
declare namespace Timeout {
|
|
23
|
+
var defaultProps: {
|
|
24
|
+
time: number;
|
|
25
|
+
contianer: HTMLElement;
|
|
26
|
+
onTimeout: typeof defaultTimeoutAction;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
declare function defaultTimeoutAction(): {
|
|
30
|
+
destroy: () => void;
|
|
31
|
+
update: (configUpdate: import("antd").ModalFuncProps | ((prevConfig: import("antd").ModalFuncProps) => import("antd").ModalFuncProps)) => void;
|
|
32
|
+
};
|
|
33
|
+
export default Timeout;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import "antd/lib/modal/style";
|
|
2
|
+
import _Modal from "antd/lib/modal";
|
|
3
|
+
import _useEventListener from "ahooks/es/useEventListener";
|
|
4
|
+
import _useRafInterval from "ahooks/es/useRafInterval";
|
|
5
|
+
|
|
6
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
7
|
+
|
|
8
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
|
+
|
|
10
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
11
|
+
|
|
12
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
13
|
+
|
|
14
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
15
|
+
|
|
16
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
17
|
+
|
|
18
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
19
|
+
//此处antd有bug不能定制样式前缀
|
|
20
|
+
import 'antd/es/modal/style/css';
|
|
21
|
+
/**
|
|
22
|
+
*
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
function Timeout(_ref) {
|
|
26
|
+
var contianer = _ref.contianer,
|
|
27
|
+
time = _ref.time,
|
|
28
|
+
onTimeout = _ref.onTimeout;
|
|
29
|
+
var cuurentTimeRef = useRef(Date.now());
|
|
30
|
+
var lockstatusRef = useRef(false);
|
|
31
|
+
|
|
32
|
+
var _useState = useState({
|
|
33
|
+
timelock: Date.now()
|
|
34
|
+
}),
|
|
35
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
36
|
+
state = _useState2[0],
|
|
37
|
+
setState = _useState2[1];
|
|
38
|
+
|
|
39
|
+
_useRafInterval(function () {
|
|
40
|
+
return setState(function (old) {
|
|
41
|
+
return Object.assign(Object.assign({}, old), {
|
|
42
|
+
timelock: Date.now()
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
}, 1 * 1000);
|
|
46
|
+
|
|
47
|
+
useEffect(function () {
|
|
48
|
+
if (!lockstatusRef.current && state.timelock - cuurentTimeRef.current > time * 1000) {
|
|
49
|
+
lockstatusRef.current = true;
|
|
50
|
+
onTimeout && onTimeout();
|
|
51
|
+
setTimeout(function () {
|
|
52
|
+
return lockstatusRef.current = false;
|
|
53
|
+
}, 1000);
|
|
54
|
+
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
55
|
+
|
|
56
|
+
}, [state.timelock, time]);
|
|
57
|
+
|
|
58
|
+
_useEventListener('mousemove', function () {
|
|
59
|
+
return cuurentTimeRef.current = Date.now();
|
|
60
|
+
}, {
|
|
61
|
+
target: contianer
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function defaultTimeoutAction() {
|
|
68
|
+
return _Modal.warning({
|
|
69
|
+
title: '系统提示',
|
|
70
|
+
content: /*#__PURE__*/React.createElement("p", null, "\u60A8\u957F\u65F6\u95F4\u672A\u64CD\u4F5C\u7CFB\u7EDF\uFF0C\u8BF7\u91CD\u65B0\u767B\u5F55\uFF01"),
|
|
71
|
+
onOk: function onOk() {
|
|
72
|
+
sessionStorage.clear();
|
|
73
|
+
window.location.replace('/login');
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
Timeout.defaultProps = {
|
|
79
|
+
time: 15 * 60,
|
|
80
|
+
contianer: document.body,
|
|
81
|
+
onTimeout: defaultTimeoutAction
|
|
82
|
+
};
|
|
83
|
+
export default Timeout;
|
package/es/index.d.ts
CHANGED
|
@@ -32,6 +32,7 @@ export { default as SegmentPlayer } from './SegmentPlayer';
|
|
|
32
32
|
export { default as Service } from './Service';
|
|
33
33
|
export { default as TableLayout } from './TableLayout';
|
|
34
34
|
export { default as ThemeAntd } from './ThemeAntd';
|
|
35
|
+
export { default as Timeout } from './Timeout';
|
|
35
36
|
export { default as Tree } from './Tree';
|
|
36
37
|
export { default as useHistory } from './useHistory';
|
|
37
38
|
export { default as useInfiniteScroll } from './useInfiniteScroll';
|
package/es/index.js
CHANGED
|
@@ -32,6 +32,7 @@ export { default as SegmentPlayer } from './SegmentPlayer';
|
|
|
32
32
|
export { default as Service } from './Service';
|
|
33
33
|
export { default as TableLayout } from './TableLayout';
|
|
34
34
|
export { default as ThemeAntd } from './ThemeAntd';
|
|
35
|
+
export { default as Timeout } from './Timeout';
|
|
35
36
|
export { default as Tree } from './Tree';
|
|
36
37
|
export { default as useHistory } from './useHistory';
|
|
37
38
|
export { default as useInfiniteScroll } from './useInfiniteScroll';
|
|
@@ -5,4 +5,5 @@ import { IErrorBoundaryProps } from '../ErrorBoundary';
|
|
|
5
5
|
* @param Component 业务组件
|
|
6
6
|
* @param errorBoundaryProps error boundary的props
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
declare function withErrorBoundary<P>(Component: React.ComponentType<P>, errorBoundaryProps?: IErrorBoundaryProps): React.ComponentType<P>;
|
|
9
|
+
export default withErrorBoundary;
|
|
@@ -29,7 +29,7 @@ var Fallback = function Fallback() {
|
|
|
29
29
|
*/
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
function withErrorBoundary(Component, errorBoundaryProps) {
|
|
33
33
|
var Wrapped = function Wrapped(props) {
|
|
34
34
|
return /*#__PURE__*/React.createElement(ErrorBoundary, Object.assign({
|
|
35
35
|
fallback: /*#__PURE__*/React.createElement(Fallback, null)
|
|
@@ -40,4 +40,6 @@ export default function withErrorBoundary(Component, errorBoundaryProps) {
|
|
|
40
40
|
var name = Component.displayName || Component.name || 'Unknown';
|
|
41
41
|
Wrapped.displayName = "withErrorBoundary(".concat(name, ")");
|
|
42
42
|
return Wrapped;
|
|
43
|
-
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export default withErrorBoundary;
|
package/package.json
CHANGED