@cloud-app-dev/vidc 4.0.17 → 4.1.0
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/.dumirc.ts +1 -1
- package/.eslintrc.js +3 -0
- package/.fatherrc.ts +0 -6
- package/es/AppContext/Sync.d.ts +7 -0
- package/es/AppContext/Sync.js +44 -0
- package/es/AppContext/index.d.ts +17 -0
- package/es/AppContext/index.js +154 -0
- package/es/AppContext/interface.d.ts +42 -0
- package/es/AppContext/static.d.ts +8 -0
- package/es/AppContext/static.js +9 -0
- package/es/CheckGroupFixed/demo.d.ts +2 -0
- package/es/CheckGroupFixed/demo.js +20 -0
- package/es/CheckGroupFixed/index.d.ts +22 -0
- package/es/CheckGroupFixed/index.js +150 -0
- package/es/CheckGroupFixed/style.d.ts +6 -0
- package/es/CheckGroupFixed/style.js +9 -0
- package/es/Config/index.d.ts +4 -0
- package/es/Config/index.js +77 -0
- package/es/Config/interface.d.ts +65 -0
- package/es/Config/utils.d.ts +4 -0
- package/es/Config/utils.js +33 -0
- package/es/CustomRenderSelect/index.d.ts +13 -0
- package/es/CustomRenderSelect/index.js +86 -0
- package/es/DBTools/index.d.ts +25 -0
- package/es/DBTools/index.js +336 -0
- package/es/DisableMark/index.d.ts +8 -0
- package/es/DisableMark/index.js +25 -0
- package/es/DomMove/demo.d.ts +1 -0
- package/es/DomMove/demo.js +19 -0
- package/es/DomMove/index.d.ts +16 -0
- package/es/DomMove/index.js +148 -0
- package/es/DomMove/utils.d.ts +8 -0
- package/es/DomMove/utils.js +33 -0
- package/es/Drag/DragAndDropItem.d.ts +4 -0
- package/es/Drag/DragAndDropItem.js +133 -0
- package/es/Drag/DropItem.d.ts +4 -0
- package/es/Drag/DropItem.js +50 -0
- package/es/Drag/index.d.ts +7 -0
- package/es/Drag/index.js +7 -0
- package/es/Drag/interface.d.ts +16 -0
- package/es/DynamicGridList/demo.d.ts +2 -0
- package/es/DynamicGridList/demo.js +86 -0
- package/es/DynamicGridList/index.d.ts +27 -0
- package/es/DynamicGridList/index.js +71 -0
- package/es/DynamicList/demo.d.ts +1 -0
- package/es/DynamicList/demo.js +45 -0
- package/es/DynamicList/index.d.ts +30 -0
- package/es/DynamicList/index.js +98 -0
- package/es/DynamicList/interface.d.ts +19 -0
- package/es/DynamicList/utils.d.ts +4 -0
- package/es/DynamicList/utils.js +6 -0
- package/es/ErrorFallback/index.d.ts +8 -0
- package/es/ErrorFallback/index.js +38 -0
- package/es/ErrorFallback/inerface.d.ts +48 -0
- package/es/EventTools/index.d.ts +3 -0
- package/es/EventTools/index.js +12 -0
- package/es/FrontendPlayer/index.d.ts +4 -0
- package/es/FrontendPlayer/index.js +2 -0
- package/es/GridList/data.d.ts +16 -0
- package/es/GridList/data.js +609 -0
- package/es/GridList/demo.d.ts +2 -0
- package/es/GridList/demo.js +89 -0
- package/es/GridList/hook.d.ts +13 -0
- package/es/GridList/hook.js +270 -0
- package/es/GridList/index.d.ts +14 -0
- package/es/GridList/index.js +51 -0
- package/es/GridList/interface.d.ts +59 -0
- package/es/GridList/utils.d.ts +9 -0
- package/es/GridList/utils.js +42 -0
- package/es/HightLevel/index.d.ts +8 -0
- package/es/HightLevel/index.js +20 -0
- package/es/IconFont/index.d.ts +12 -0
- package/es/IconFont/index.js +63 -0
- package/es/InstanceHistory/index.d.ts +3 -0
- package/es/InstanceHistory/index.js +7 -0
- package/es/LabelValue/index.d.ts +14 -0
- package/es/LabelValue/index.js +35 -0
- package/es/List/demo.d.ts +2 -0
- package/es/List/demo.js +25 -0
- package/es/List/index.d.ts +27 -0
- package/es/List/index.js +38 -0
- package/es/ListWithSizeAnimate/demo.d.ts +1 -0
- package/es/ListWithSizeAnimate/demo.js +128 -0
- package/es/ListWithSizeAnimate/index.d.ts +13 -0
- package/es/ListWithSizeAnimate/index.js +106 -0
- package/es/LoaderScript/index.d.ts +47 -0
- package/es/LoaderScript/index.js +38 -0
- package/es/LoaderScript/utils.d.ts +13 -0
- package/es/LoaderScript/utils.js +179 -0
- package/es/Picture/component/DefaultRects/RectInfo.d.ts +7 -0
- package/es/Picture/component/DefaultRects/RectInfo.js +90 -0
- package/es/Picture/component/DefaultRects/index.d.ts +11 -0
- package/es/Picture/component/DefaultRects/index.js +58 -0
- package/es/Picture/component/DefaultRects/style.d.ts +10 -0
- package/es/Picture/component/DefaultRects/style.js +28 -0
- package/es/Picture/component/DefaultRects/utils.d.ts +2 -0
- package/es/Picture/component/DefaultRects/utils.js +11 -0
- package/es/Picture/component/DrawRect/index.d.ts +11 -0
- package/es/Picture/component/DrawRect/index.js +54 -0
- package/es/Picture/component/RectMenu/index.d.ts +10 -0
- package/es/Picture/component/RectMenu/index.js +84 -0
- package/es/Picture/component/RectMenu/utils.d.ts +12 -0
- package/es/Picture/component/RectMenu/utils.js +19 -0
- package/es/Picture/component/Tools/index.d.ts +11 -0
- package/es/Picture/component/Tools/index.js +105 -0
- package/es/Picture/component/Tools/style.d.ts +2 -0
- package/es/Picture/component/Tools/style.js +5 -0
- package/es/Picture/component/WheelScale/index.d.ts +6 -0
- package/es/Picture/component/WheelScale/index.js +29 -0
- package/es/Picture/demo.d.ts +1 -0
- package/es/Picture/demo.js +114 -0
- package/es/Picture/index.d.ts +17 -0
- package/es/Picture/index.js +356 -0
- package/es/Picture/interface.d.ts +196 -0
- package/es/Picture/loadCaptureRectImage.d.ts +3 -0
- package/es/Picture/loadCaptureRectImage.js +99 -0
- package/es/Picture/useDraw.d.ts +1 -0
- package/es/Picture/useDraw.js +103 -0
- package/es/Picture/utils.d.ts +26 -0
- package/es/Picture/utils.js +143 -0
- package/es/Player/api/index.d.ts +68 -0
- package/es/Player/api/index.js +309 -0
- package/es/Player/context.d.ts +21 -0
- package/es/Player/context.js +25 -0
- package/es/Player/contraller_bar/bar.d.ts +8 -0
- package/es/Player/contraller_bar/bar.js +32 -0
- package/es/Player/contraller_bar/contraller_event.d.ts +6 -0
- package/es/Player/contraller_bar/contraller_event.js +52 -0
- package/es/Player/contraller_bar/index.d.ts +13 -0
- package/es/Player/contraller_bar/index.js +39 -0
- package/es/Player/contraller_bar/left_bar.d.ts +10 -0
- package/es/Player/contraller_bar/left_bar.js +97 -0
- package/es/Player/contraller_bar/right_bar.d.ts +8 -0
- package/es/Player/contraller_bar/right_bar.js +36 -0
- package/es/Player/contraller_bar/time.d.ts +2 -0
- package/es/Player/contraller_bar/time.js +24 -0
- package/es/Player/contraller_bar/useBarStatus.d.ts +2 -0
- package/es/Player/contraller_bar/useBarStatus.js +43 -0
- package/es/Player/contraller_bar/volume.d.ts +8 -0
- package/es/Player/contraller_bar/volume.js +70 -0
- package/es/Player/demo.d.ts +2 -0
- package/es/Player/demo.js +289 -0
- package/es/Player/empty.d.ts +1 -0
- package/es/Player/empty.js +5 -0
- package/es/Player/event/errorEvent.d.ts +14 -0
- package/es/Player/event/errorEvent.js +88 -0
- package/es/Player/event/eventName.d.ts +18 -0
- package/es/Player/event/eventName.js +30 -0
- package/es/Player/event/index.d.ts +24 -0
- package/es/Player/event/index.js +205 -0
- package/es/Player/fps_play.d.ts +10 -0
- package/es/Player/fps_play.js +88 -0
- package/es/Player/frontend_player.d.ts +7 -0
- package/es/Player/frontend_player.js +71 -0
- package/es/Player/frontend_timeline.d.ts +8 -0
- package/es/Player/frontend_timeline.js +153 -0
- package/es/Player/iconfont.d.ts +4 -0
- package/es/Player/iconfont.js +21 -0
- package/es/Player/index.d.ts +2 -0
- package/es/Player/index.js +2 -0
- package/es/Player/live_heart.d.ts +8 -0
- package/es/Player/live_heart.js +45 -0
- package/es/Player/message.d.ts +3 -0
- package/es/Player/message.js +147 -0
- package/es/Player/player.d.ts +233 -0
- package/es/Player/segment_player.d.ts +8 -0
- package/es/Player/segment_player.js +229 -0
- package/es/Player/segment_timeline.d.ts +10 -0
- package/es/Player/segment_timeline.js +200 -0
- package/es/Player/single_player.d.ts +4 -0
- package/es/Player/single_player.js +278 -0
- package/es/Player/style/iconfont.js +43 -0
- package/es/Player/timeline.d.ts +7 -0
- package/es/Player/timeline.js +104 -0
- package/es/Player/util.d.ts +43 -0
- package/es/Player/util.js +189 -0
- package/es/PlayerExt/demo.d.ts +2 -0
- package/es/PlayerExt/demo.js +170 -0
- package/es/PlayerExt/index.d.ts +47 -0
- package/es/PlayerExt/index.js +212 -0
- package/es/Progress/index.d.ts +10 -0
- package/es/Progress/index.js +60 -0
- package/es/ROI/demo.d.ts +2 -0
- package/es/ROI/demo.js +17 -0
- package/es/ROI/index.d.ts +32 -0
- package/es/ROI/index.js +67 -0
- package/es/RefDrawer/Footer.d.ts +9 -0
- package/es/RefDrawer/Footer.js +27 -0
- package/es/RefDrawer/demo.d.ts +3 -0
- package/es/RefDrawer/demo.js +32 -0
- package/es/RefDrawer/index.d.ts +26 -0
- package/es/RefDrawer/index.js +73 -0
- package/es/RefModal/demo.d.ts +2 -0
- package/es/RefModal/demo.js +32 -0
- package/es/RefModal/index.d.ts +17 -0
- package/es/RefModal/index.js +71 -0
- package/es/ScreenPlayer/Live.d.ts +8 -0
- package/es/ScreenPlayer/Live.js +219 -0
- package/es/ScreenPlayer/LiveTools.d.ts +33 -0
- package/es/ScreenPlayer/LiveTools.js +172 -0
- package/es/ScreenPlayer/PlayerWithExt.d.ts +34 -0
- package/es/ScreenPlayer/PlayerWithExt.js +241 -0
- package/es/ScreenPlayer/RatePick.d.ts +7 -0
- package/es/ScreenPlayer/RatePick.js +35 -0
- package/es/ScreenPlayer/Record.d.ts +8 -0
- package/es/ScreenPlayer/Record.js +452 -0
- package/es/ScreenPlayer/RecordTools.d.ts +38 -0
- package/es/ScreenPlayer/RecordTools.js +214 -0
- package/es/ScreenPlayer/ScreenSelect.d.ts +6 -0
- package/es/ScreenPlayer/ScreenSelect.js +59 -0
- package/es/ScreenPlayer/SegmentTimeLine.d.ts +16 -0
- package/es/ScreenPlayer/SegmentTimeLine.js +44 -0
- package/es/ScreenPlayer/TimeMode.d.ts +6 -0
- package/es/ScreenPlayer/TimeMode.js +34 -0
- package/es/ScreenPlayer/TimeSelect.d.ts +6 -0
- package/es/ScreenPlayer/TimeSelect.js +99 -0
- package/es/ScreenPlayer/containerStyle.d.ts +13 -0
- package/es/ScreenPlayer/containerStyle.js +32 -0
- package/es/ScreenPlayer/demo.d.ts +1 -0
- package/es/ScreenPlayer/demo.js +19 -0
- package/es/ScreenPlayer/demo2.d.ts +1 -0
- package/es/ScreenPlayer/demo2.js +196 -0
- package/es/ScreenPlayer/index.d.ts +6 -0
- package/es/ScreenPlayer/index.js +9 -0
- package/es/ScreenPlayer/interface.d.ts +216 -0
- package/es/ScreenPlayer/useTimeSlider.d.ts +25 -0
- package/es/ScreenPlayer/useTimeSlider.js +451 -0
- package/es/ScreenPlayer/useVideoFit.d.ts +5 -0
- package/es/ScreenPlayer/useVideoFit.js +35 -0
- package/es/ScreenPlayer/utils.d.ts +17 -0
- package/es/ScreenPlayer/utils.js +85 -0
- package/es/SegmentPlayer/index.d.ts +2 -0
- package/es/SegmentPlayer/index.js +2 -0
- package/es/Service/http.d.ts +6 -0
- package/es/Service/http.js +125 -0
- package/es/Service/index.d.ts +3 -0
- package/es/Service/index.js +10 -0
- package/es/Service/interface.d.ts +22 -0
- package/es/Service/middleware.d.ts +5 -0
- package/es/Service/middleware.js +15 -0
- package/es/SocketEmitter/eventEmitter.d.ts +27 -0
- package/es/SocketEmitter/eventEmitter.js +88 -0
- package/es/SocketEmitter/index.d.ts +24 -0
- package/es/SocketEmitter/index.js +125 -0
- package/es/SocketEmitter/interface.d.ts +4 -0
- package/es/TableLayout/index.d.ts +9 -0
- package/es/TableLayout/index.js +32 -0
- package/es/Timeout/index.d.ts +31 -0
- package/es/Timeout/index.js +69 -0
- package/es/cache/index.d.ts +34 -0
- package/es/cache/index.js +94 -0
- package/es/copy/index.d.ts +1 -0
- package/es/copy/index.js +9 -0
- package/es/core.d.ts +0 -0
- package/es/getThemeStyle/index.d.ts +2 -0
- package/es/getThemeStyle/index.js +5 -0
- package/es/index.d.ts +52 -0
- package/es/index.js +52 -0
- package/es/likeGo/index.d.ts +2 -0
- package/es/likeGo/index.js +31 -0
- package/es/likeGoSync/index.d.ts +2 -0
- package/es/likeGoSync/index.js +10 -0
- package/es/logger/index.d.ts +7 -0
- package/es/logger/index.js +30 -0
- package/es/nextTick/index.d.ts +1 -0
- package/es/nextTick/index.js +3 -0
- package/es/recorder/demo.d.ts +2 -0
- package/es/recorder/demo.js +200 -0
- package/es/recorder/index.d.ts +294 -0
- package/es/recorder/index.js +991 -0
- package/es/submidstr/index.d.ts +5 -0
- package/es/submidstr/index.js +14 -0
- package/es/treeHelper/index.d.ts +11 -0
- package/es/treeHelper/index.js +189 -0
- package/es/typings.d.ts +2 -0
- package/es/useDrawROI/index.d.ts +16 -0
- package/es/useDrawROI/index.js +318 -0
- package/es/useEventEmitterHandle/index.d.ts +2 -0
- package/es/useEventEmitterHandle/index.js +17 -0
- package/es/useHistory/index.d.ts +3 -0
- package/es/useHistory/index.js +9 -0
- package/es/useHistory/interface.d.ts +3 -0
- package/es/useInfiniteScroll/index.d.ts +16 -0
- package/es/useInfiniteScroll/index.js +102 -0
- package/es/useRafInterval/index.d.ts +5 -0
- package/es/useRafInterval/index.js +70 -0
- package/es/useSimpleState/index.d.ts +3 -0
- package/es/useSimpleState/index.js +35 -0
- package/es/useVirtualList/index.d.ts +13 -0
- package/es/useVirtualList/index.js +136 -0
- package/es/utils.d.ts +14 -0
- package/es/utils.js +46 -0
- package/es/uuid/index.d.ts +5 -0
- package/es/uuid/index.js +6 -0
- package/package.json +16 -21
- package/release-build.sh +2 -0
- package/scripts/{entry.js → entry.mjs} +4 -6
- package/{icon-fix.js → scripts/icon-fix.mjs} +4 -3
- package/tsconfig.json +1 -1
|
@@ -0,0 +1,125 @@
|
|
|
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
|
+
var _excluded = ["cancelHttp"];
|
|
3
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
5
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
7
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
8
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
9
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
10
|
+
import Axios from 'axios';
|
|
11
|
+
import * as Middleware from "./middleware";
|
|
12
|
+
var CancelToken = Axios.CancelToken;
|
|
13
|
+
var config = {
|
|
14
|
+
baseURL: '/',
|
|
15
|
+
timeout: 60 * 1000,
|
|
16
|
+
xhrMode: 'fetch',
|
|
17
|
+
headers: {
|
|
18
|
+
Accept: 'application/json; charset=utf-8',
|
|
19
|
+
'Content-Type': 'application/json; charset=utf-8'
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
var httpInstance = Axios.create(config);
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* 请求之前拦截动作
|
|
26
|
+
*/
|
|
27
|
+
httpInstance.interceptors.request.use(function (response) {
|
|
28
|
+
return response;
|
|
29
|
+
}, function (error) {
|
|
30
|
+
return console.error(error);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* 请求之后拦截动作
|
|
35
|
+
*/
|
|
36
|
+
httpInstance.interceptors.response.use(function (response) {
|
|
37
|
+
if (Middleware.responseMiddleware.length === 0) {
|
|
38
|
+
return response.data;
|
|
39
|
+
} else {
|
|
40
|
+
var resp = response;
|
|
41
|
+
Middleware.responseMiddleware.forEach(function (fn) {
|
|
42
|
+
resp = fn(response);
|
|
43
|
+
});
|
|
44
|
+
return resp;
|
|
45
|
+
}
|
|
46
|
+
}, function httpUtilErrorRequest(error) {
|
|
47
|
+
if (Middleware.responseErrorMiddleware.length !== 0) {
|
|
48
|
+
var err = error;
|
|
49
|
+
Middleware.responseErrorMiddleware.forEach(function (fn) {
|
|
50
|
+
err = fn(error);
|
|
51
|
+
});
|
|
52
|
+
return Promise.reject(err);
|
|
53
|
+
}
|
|
54
|
+
if (!error.response) {
|
|
55
|
+
console.error(error);
|
|
56
|
+
return Promise.reject(error);
|
|
57
|
+
}
|
|
58
|
+
return Promise.reject(error.response);
|
|
59
|
+
});
|
|
60
|
+
function http(_ref) {
|
|
61
|
+
var cancelHttp = _ref.cancelHttp,
|
|
62
|
+
newOptions = _objectWithoutProperties(_ref, _excluded);
|
|
63
|
+
var cancel;
|
|
64
|
+
var cancelToken = new CancelToken(function (c) {
|
|
65
|
+
cancel = c;
|
|
66
|
+
if (cancelHttp) {
|
|
67
|
+
cancelHttp(cancel);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
return httpInstance(_objectSpread(_objectSpread({}, newOptions), {}, {
|
|
71
|
+
cancelToken: cancelToken
|
|
72
|
+
}));
|
|
73
|
+
}
|
|
74
|
+
var httpMultiPartInstance = Axios.create({
|
|
75
|
+
timeout: 10 * 60 * 1000,
|
|
76
|
+
headers: {
|
|
77
|
+
'Content-Type': 'multipart/form-data'
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
httpMultiPartInstance.interceptors.response.use(function (response) {
|
|
81
|
+
return Promise.resolve(response.data);
|
|
82
|
+
}, function (error) {
|
|
83
|
+
return Promise.reject(error);
|
|
84
|
+
});
|
|
85
|
+
function httpXMLInstance(_ref2) {
|
|
86
|
+
var url = _ref2.url,
|
|
87
|
+
_ref2$method = _ref2.method,
|
|
88
|
+
method = _ref2$method === void 0 ? 'GET' : _ref2$method,
|
|
89
|
+
data = _ref2.data,
|
|
90
|
+
headers = _ref2.headers,
|
|
91
|
+
cancelHttp = _ref2.cancelHttp,
|
|
92
|
+
_ref2$isAsync = _ref2.isAsync,
|
|
93
|
+
isAsync = _ref2$isAsync === void 0 ? false : _ref2$isAsync;
|
|
94
|
+
return new Promise(function (resolve, reject) {
|
|
95
|
+
var xhr = new XMLHttpRequest();
|
|
96
|
+
var cancel = function cancel() {
|
|
97
|
+
return xhr.abort();
|
|
98
|
+
};
|
|
99
|
+
if (cancelHttp) {
|
|
100
|
+
cancelHttp(cancel);
|
|
101
|
+
}
|
|
102
|
+
xhr.open(method, url, !isAsync);
|
|
103
|
+
if (headers) {
|
|
104
|
+
Object.keys(headers).forEach(function (key) {
|
|
105
|
+
xhr.setRequestHeader(key, headers[key]);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
xhr.onreadystatechange = function () {
|
|
109
|
+
if (xhr.readyState === 4 && (xhr.status === 200 || xhr.status === 304)) {
|
|
110
|
+
var _data;
|
|
111
|
+
try {
|
|
112
|
+
_data = JSON.parse(xhr.response);
|
|
113
|
+
} catch (e) {
|
|
114
|
+
_data = xhr.response;
|
|
115
|
+
}
|
|
116
|
+
resolve(_data);
|
|
117
|
+
}
|
|
118
|
+
if (xhr.readyState === 4 && !(xhr.status === 200 || xhr.status === 304)) {
|
|
119
|
+
reject(xhr);
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
xhr.send(data ? JSON.stringify(data) : null);
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
export { http as default, http, httpMultiPartInstance, httpXMLInstance };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { http, httpMultiPartInstance, httpXMLInstance } from "./http";
|
|
2
|
+
import { registerResponseMiddleware, registerResponseErrorMiddleware } from "./middleware";
|
|
3
|
+
var Service = {
|
|
4
|
+
http: http,
|
|
5
|
+
httpXMLInstance: httpXMLInstance,
|
|
6
|
+
httpMultiPartInstance: httpMultiPartInstance,
|
|
7
|
+
registerResponseMiddleware: registerResponseMiddleware,
|
|
8
|
+
registerResponseErrorMiddleware: registerResponseErrorMiddleware
|
|
9
|
+
};
|
|
10
|
+
export default Service;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
|
|
2
|
+
export type RsponseType = AxiosRequestConfig & { requestId?: string; cancelHttp?: (cancel: (o?: any) => void) => void; loggerIndex?: number };
|
|
3
|
+
|
|
4
|
+
export type XHRResponse = {
|
|
5
|
+
url: string;
|
|
6
|
+
method: string;
|
|
7
|
+
data?: any;
|
|
8
|
+
headers?: any;
|
|
9
|
+
cancelHttp?: any;
|
|
10
|
+
isAsync?: boolean;
|
|
11
|
+
requestId?: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export type MiddleWareType = (config: AxiosResponse<any>) => any;
|
|
15
|
+
|
|
16
|
+
export type IServiceInterface = {
|
|
17
|
+
http(options: RsponseType): Promise<any>;
|
|
18
|
+
httpXMLInstance(options: XHRResponse): Promise<any>;
|
|
19
|
+
httpMultiPartInstance: AxiosInstance;
|
|
20
|
+
registerResponseMiddleware(fn: MiddleWareType): void;
|
|
21
|
+
registerResponseErrorMiddleware(fn: MiddleWareType): void;
|
|
22
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { MiddleWareType } from './interface';
|
|
2
|
+
export declare const responseMiddleware: Array<any>;
|
|
3
|
+
export declare const responseErrorMiddleware: Array<any>;
|
|
4
|
+
export declare function registerResponseMiddleware(fn: MiddleWareType): void;
|
|
5
|
+
export declare function registerResponseErrorMiddleware(fn: MiddleWareType): void;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
var _global = window;
|
|
2
|
+
export var responseMiddleware = _global.responseMiddleware || [];
|
|
3
|
+
export var responseErrorMiddleware = _global.responseErrorMiddleware || [];
|
|
4
|
+
export function registerResponseMiddleware(fn) {
|
|
5
|
+
if (!responseMiddleware.includes(fn)) {
|
|
6
|
+
responseMiddleware.push(fn);
|
|
7
|
+
_global.responseMiddleware = responseMiddleware;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export function registerResponseErrorMiddleware(fn) {
|
|
11
|
+
if (!responseErrorMiddleware.includes(fn)) {
|
|
12
|
+
responseErrorMiddleware.push(fn);
|
|
13
|
+
_global.responseErrorMiddleware = responseErrorMiddleware;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 自定义事件
|
|
3
|
+
* author hjj
|
|
4
|
+
*/
|
|
5
|
+
type EventItemType = {
|
|
6
|
+
[key: string]: {
|
|
7
|
+
listener: (data?: any) => void;
|
|
8
|
+
timer: number;
|
|
9
|
+
}[];
|
|
10
|
+
};
|
|
11
|
+
declare class EventEmitter {
|
|
12
|
+
events: EventItemType;
|
|
13
|
+
constructor();
|
|
14
|
+
getEvents(): EventItemType;
|
|
15
|
+
once(eventName: string, listener: (...args: any) => void): void;
|
|
16
|
+
on(eventName: string, listener: (...args: any) => void, timer?: number): void;
|
|
17
|
+
emit(eventName: string, ...args: any): void;
|
|
18
|
+
remove(eventName: string): void;
|
|
19
|
+
off(eventName: string, listener: (...args: any) => void): void;
|
|
20
|
+
clear(): void;
|
|
21
|
+
trigger(eventName: string, args: any): void;
|
|
22
|
+
getListeners(eventName: string): {
|
|
23
|
+
listener: (data?: any) => void;
|
|
24
|
+
timer: number;
|
|
25
|
+
}[];
|
|
26
|
+
}
|
|
27
|
+
export default EventEmitter;
|
|
@@ -0,0 +1,88 @@
|
|
|
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
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
3
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
4
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
5
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
7
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
8
|
+
/* eslint-disable @typescript-eslint/no-unused-expressions */
|
|
9
|
+
/**
|
|
10
|
+
* 自定义事件
|
|
11
|
+
* author hjj
|
|
12
|
+
*/
|
|
13
|
+
var EventEmitter = /*#__PURE__*/function () {
|
|
14
|
+
function EventEmitter() {
|
|
15
|
+
_classCallCheck(this, EventEmitter);
|
|
16
|
+
_defineProperty(this, "events", void 0);
|
|
17
|
+
this.events = {};
|
|
18
|
+
}
|
|
19
|
+
_createClass(EventEmitter, [{
|
|
20
|
+
key: "getEvents",
|
|
21
|
+
value: function getEvents() {
|
|
22
|
+
return this.events;
|
|
23
|
+
}
|
|
24
|
+
}, {
|
|
25
|
+
key: "once",
|
|
26
|
+
value: function once(eventName, listener) {
|
|
27
|
+
return this.on(eventName, listener, 0);
|
|
28
|
+
}
|
|
29
|
+
}, {
|
|
30
|
+
key: "on",
|
|
31
|
+
value: function on(eventName, listener) {
|
|
32
|
+
var timer = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : -1;
|
|
33
|
+
var listeners = this.getListeners(eventName);
|
|
34
|
+
listeners.push({
|
|
35
|
+
listener: listener,
|
|
36
|
+
timer: timer
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}, {
|
|
40
|
+
key: "emit",
|
|
41
|
+
value: function emit(eventName) {
|
|
42
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
43
|
+
args[_key - 1] = arguments[_key];
|
|
44
|
+
}
|
|
45
|
+
return this.trigger(eventName, args);
|
|
46
|
+
}
|
|
47
|
+
}, {
|
|
48
|
+
key: "remove",
|
|
49
|
+
value: function remove(eventName) {
|
|
50
|
+
this.events[eventName] && delete this.events[eventName];
|
|
51
|
+
}
|
|
52
|
+
}, {
|
|
53
|
+
key: "off",
|
|
54
|
+
value: function off(eventName, listener) {
|
|
55
|
+
var listeners = this.getListeners(eventName);
|
|
56
|
+
var index = listeners.findIndex(function (item) {
|
|
57
|
+
return item.listener === listener;
|
|
58
|
+
});
|
|
59
|
+
index !== -1 && listeners.splice(index, 1);
|
|
60
|
+
}
|
|
61
|
+
}, {
|
|
62
|
+
key: "clear",
|
|
63
|
+
value: function clear() {
|
|
64
|
+
this.events = {};
|
|
65
|
+
}
|
|
66
|
+
}, {
|
|
67
|
+
key: "trigger",
|
|
68
|
+
value: function trigger(eventName, args) {
|
|
69
|
+
var listeners = this.getListeners(eventName);
|
|
70
|
+
for (var i = 0; i < listeners.length; i++) {
|
|
71
|
+
var listener = listeners[i];
|
|
72
|
+
if (listener) {
|
|
73
|
+
listener.listener.apply(this, args || []);
|
|
74
|
+
listener.timer === 0 && listeners.splice(i, 1);
|
|
75
|
+
listeners.length === 0 && delete this.events[eventName];
|
|
76
|
+
listener.timer !== -1 && listener.timer--;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}, {
|
|
81
|
+
key: "getListeners",
|
|
82
|
+
value: function getListeners(eventName) {
|
|
83
|
+
return this.events[eventName] || (this.events[eventName] = []);
|
|
84
|
+
}
|
|
85
|
+
}]);
|
|
86
|
+
return EventEmitter;
|
|
87
|
+
}();
|
|
88
|
+
export default EventEmitter;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import EventEmitter from './eventEmitter';
|
|
2
|
+
declare class SocketEmitter extends EventEmitter {
|
|
3
|
+
sokect: any;
|
|
4
|
+
sokectEvents: string[];
|
|
5
|
+
subActions: {
|
|
6
|
+
[key: string]: (data?: any) => void;
|
|
7
|
+
};
|
|
8
|
+
constructor();
|
|
9
|
+
connect(url: string, options: any): void;
|
|
10
|
+
disconnect(): void;
|
|
11
|
+
/**
|
|
12
|
+
* 抽象socket监听方法
|
|
13
|
+
* @param {*} param0
|
|
14
|
+
*/
|
|
15
|
+
subscribe(eventName: string, listener: (...args: any) => void): void;
|
|
16
|
+
subAction(eventName: string): (data: any) => void;
|
|
17
|
+
/**
|
|
18
|
+
* 抽象socket监听方法
|
|
19
|
+
* @param {*} param0
|
|
20
|
+
*/
|
|
21
|
+
unsubscribe(eventName: string, listener: (...args: any) => void): void;
|
|
22
|
+
}
|
|
23
|
+
declare const LMEvent: SocketEmitter;
|
|
24
|
+
export default LMEvent;
|
|
@@ -0,0 +1,125 @@
|
|
|
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
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
5
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
6
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
7
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
8
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
9
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
10
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
11
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
12
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
13
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
14
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
15
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
16
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
17
|
+
/* eslint-disable @typescript-eslint/no-unused-expressions */
|
|
18
|
+
import io from 'socket.io-client';
|
|
19
|
+
import cache from "../cache";
|
|
20
|
+
import logger from "../logger";
|
|
21
|
+
import EventEmitter from "./eventEmitter";
|
|
22
|
+
var SocketEmitter = /*#__PURE__*/function (_EventEmitter) {
|
|
23
|
+
_inherits(SocketEmitter, _EventEmitter);
|
|
24
|
+
var _super = _createSuper(SocketEmitter);
|
|
25
|
+
function SocketEmitter() {
|
|
26
|
+
var _this;
|
|
27
|
+
_classCallCheck(this, SocketEmitter);
|
|
28
|
+
_this = _super.call(this);
|
|
29
|
+
_defineProperty(_assertThisInitialized(_this), "sokect", void 0);
|
|
30
|
+
_defineProperty(_assertThisInitialized(_this), "sokectEvents", void 0);
|
|
31
|
+
_defineProperty(_assertThisInitialized(_this), "subActions", void 0);
|
|
32
|
+
_this.sokectEvents = [];
|
|
33
|
+
_this.subActions = {};
|
|
34
|
+
return _this;
|
|
35
|
+
}
|
|
36
|
+
_createClass(SocketEmitter, [{
|
|
37
|
+
key: "connect",
|
|
38
|
+
value: function connect(url, options) {
|
|
39
|
+
if (this.sokect && this.sokect.connected) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
var token = cache.getCache('token', 'session');
|
|
43
|
+
logger.debug('第一次尝试连接socket');
|
|
44
|
+
this.sokect = io(url, _objectSpread({
|
|
45
|
+
path: '/socket.io',
|
|
46
|
+
query: {
|
|
47
|
+
token: token
|
|
48
|
+
},
|
|
49
|
+
transports: ['websocket']
|
|
50
|
+
}, options));
|
|
51
|
+
this.sokect.on('connect', function () {
|
|
52
|
+
logger.debug('socket连接成功');
|
|
53
|
+
});
|
|
54
|
+
this.sokect.on('disconnect', function () {
|
|
55
|
+
logger.debug('socket断开连接');
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}, {
|
|
59
|
+
key: "disconnect",
|
|
60
|
+
value: function disconnect() {
|
|
61
|
+
this.clear();
|
|
62
|
+
this.sokect && this.sokect.disconnect();
|
|
63
|
+
this.sokect = null;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* 抽象socket监听方法
|
|
68
|
+
* @param {*} param0
|
|
69
|
+
*/
|
|
70
|
+
}, {
|
|
71
|
+
key: "subscribe",
|
|
72
|
+
value: function subscribe(eventName, listener) {
|
|
73
|
+
this.on(eventName, listener);
|
|
74
|
+
if (this.sokectEvents.includes(eventName) || !this.sokect) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
this.sokectEvents.push(eventName);
|
|
78
|
+
this.subActions[eventName] = this.subAction(eventName);
|
|
79
|
+
this.sokect && this.sokect.on(eventName, this.subActions[eventName]);
|
|
80
|
+
logger.debug("socket.io listener event -> ".concat(eventName));
|
|
81
|
+
}
|
|
82
|
+
}, {
|
|
83
|
+
key: "subAction",
|
|
84
|
+
value: function subAction(eventName) {
|
|
85
|
+
var _this2 = this;
|
|
86
|
+
return function (data) {
|
|
87
|
+
var json;
|
|
88
|
+
try {
|
|
89
|
+
json = JSON.parse(data);
|
|
90
|
+
} catch (e) {
|
|
91
|
+
json = data;
|
|
92
|
+
}
|
|
93
|
+
_this2.emit(eventName, json);
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* 抽象socket监听方法
|
|
99
|
+
* @param {*} param0
|
|
100
|
+
*/
|
|
101
|
+
}, {
|
|
102
|
+
key: "unsubscribe",
|
|
103
|
+
value: function unsubscribe(eventName, listener) {
|
|
104
|
+
this.off(eventName, listener);
|
|
105
|
+
this.sokect && this.sokect.off(eventName, this.subActions[eventName]);
|
|
106
|
+
delete this.subActions[eventName];
|
|
107
|
+
this.sokectEvents = this.sokectEvents.filter(function (v) {
|
|
108
|
+
return v !== eventName;
|
|
109
|
+
});
|
|
110
|
+
logger.debug("socket.io unlistener event -> ".concat(eventName));
|
|
111
|
+
}
|
|
112
|
+
}]);
|
|
113
|
+
return SocketEmitter;
|
|
114
|
+
}(EventEmitter);
|
|
115
|
+
var _global = window;
|
|
116
|
+
var event = new SocketEmitter();
|
|
117
|
+
var LMEvent = function () {
|
|
118
|
+
if (_global._LM_EVENT_) {
|
|
119
|
+
return _global._LM_EVENT_;
|
|
120
|
+
} else {
|
|
121
|
+
_global._LM_EVENT_ = event;
|
|
122
|
+
return event;
|
|
123
|
+
}
|
|
124
|
+
}();
|
|
125
|
+
export default LMEvent;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface ITableLayoutProps {
|
|
3
|
+
className?: string;
|
|
4
|
+
children: React.ReactElement;
|
|
5
|
+
cutNum?: number;
|
|
6
|
+
x?: string | number;
|
|
7
|
+
}
|
|
8
|
+
declare function TableLayout({ className, children, cutNum, x }: ITableLayoutProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export default TableLayout;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
var _templateObject;
|
|
2
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
3
|
+
import { css } from '@emotion/css';
|
|
4
|
+
import { useSize } from 'ahooks';
|
|
5
|
+
import React, { useMemo, useRef } from 'react';
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
var classname = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n height: calc(100% - 32px);\n padding-top: 20px;\n"])));
|
|
8
|
+
function TableLayout(_ref) {
|
|
9
|
+
var _ref$className = _ref.className,
|
|
10
|
+
className = _ref$className === void 0 ? '' : _ref$className,
|
|
11
|
+
children = _ref.children,
|
|
12
|
+
_ref$cutNum = _ref.cutNum,
|
|
13
|
+
cutNum = _ref$cutNum === void 0 ? 0 : _ref$cutNum,
|
|
14
|
+
_ref$x = _ref.x,
|
|
15
|
+
x = _ref$x === void 0 ? 1200 : _ref$x;
|
|
16
|
+
var domRef = useRef(null);
|
|
17
|
+
var size = useSize(domRef);
|
|
18
|
+
var height = useMemo(function () {
|
|
19
|
+
return size !== null && size !== void 0 && size.height ? size.height - cutNum : 0;
|
|
20
|
+
}, [size === null || size === void 0 ? void 0 : size.height, cutNum]);
|
|
21
|
+
return /*#__PURE__*/_jsx("div", {
|
|
22
|
+
ref: domRef,
|
|
23
|
+
className: "".concat(classname, " ").concat(className),
|
|
24
|
+
children: /*#__PURE__*/React.cloneElement(children, {
|
|
25
|
+
scroll: {
|
|
26
|
+
x: x,
|
|
27
|
+
y: height
|
|
28
|
+
}
|
|
29
|
+
})
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
export default TableLayout;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { BasicTarget } from 'ahooks/es/utils/domTarget';
|
|
2
|
+
interface ITimeoutProps {
|
|
3
|
+
/**
|
|
4
|
+
* 容器
|
|
5
|
+
* @default `document.body`
|
|
6
|
+
*/
|
|
7
|
+
contianer?: BasicTarget;
|
|
8
|
+
/**
|
|
9
|
+
* 超时时长单位s
|
|
10
|
+
*/
|
|
11
|
+
time?: number;
|
|
12
|
+
/**
|
|
13
|
+
* 超时动作,默认退出登录
|
|
14
|
+
*/
|
|
15
|
+
onTimeout?: () => void;
|
|
16
|
+
/**
|
|
17
|
+
* 忽略的情况
|
|
18
|
+
*/
|
|
19
|
+
ignore?: () => boolean;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* @desc 用户创建界面超时回调
|
|
23
|
+
*/
|
|
24
|
+
declare function Timeout({ contianer, time, onTimeout, ignore }: ITimeoutProps): import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
declare namespace Timeout {
|
|
26
|
+
var defaultProps: {
|
|
27
|
+
time: number;
|
|
28
|
+
contianer: HTMLElement;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export default Timeout;
|
|
@@ -0,0 +1,69 @@
|
|
|
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
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
6
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
7
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
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
|
+
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); }
|
|
10
|
+
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; }
|
|
11
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
12
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
|
+
import { useEventListener, useRafInterval } from 'ahooks';
|
|
14
|
+
import { useEffect, useRef, useState } from 'react';
|
|
15
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
16
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
17
|
+
/**
|
|
18
|
+
* @desc 用户创建界面超时回调
|
|
19
|
+
*/
|
|
20
|
+
function Timeout(_ref) {
|
|
21
|
+
var contianer = _ref.contianer,
|
|
22
|
+
time = _ref.time,
|
|
23
|
+
onTimeout = _ref.onTimeout,
|
|
24
|
+
ignore = _ref.ignore;
|
|
25
|
+
var cuurentTimeRef = useRef(Date.now());
|
|
26
|
+
var lockstatusRef = useRef(false);
|
|
27
|
+
var _useState = useState({
|
|
28
|
+
timelock: Date.now()
|
|
29
|
+
}),
|
|
30
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
31
|
+
state = _useState2[0],
|
|
32
|
+
setState = _useState2[1];
|
|
33
|
+
useRafInterval(function () {
|
|
34
|
+
var now = Date.now();
|
|
35
|
+
setState(function (old) {
|
|
36
|
+
return _objectSpread(_objectSpread({}, old), {}, {
|
|
37
|
+
timelock: now
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
var isIgnore = ignore ? ignore() : false;
|
|
41
|
+
if (isIgnore) {
|
|
42
|
+
// 如果当前需要忽略,那么重置时间
|
|
43
|
+
cuurentTimeRef.current = now;
|
|
44
|
+
}
|
|
45
|
+
}, 1 * 1000);
|
|
46
|
+
useEffect(function () {
|
|
47
|
+
var isIgnore = ignore ? ignore() : false;
|
|
48
|
+
if (!lockstatusRef.current && state.timelock - cuurentTimeRef.current > time * 1000 && !isIgnore) {
|
|
49
|
+
lockstatusRef.current = true;
|
|
50
|
+
onTimeout === null || onTimeout === void 0 ? void 0 : onTimeout();
|
|
51
|
+
setTimeout(function () {
|
|
52
|
+
lockstatusRef.current = false;
|
|
53
|
+
}, 1000);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
57
|
+
}, [state.timelock, time]);
|
|
58
|
+
useEventListener('mousemove', function () {
|
|
59
|
+
return cuurentTimeRef.current = Date.now();
|
|
60
|
+
}, {
|
|
61
|
+
target: contianer
|
|
62
|
+
});
|
|
63
|
+
return /*#__PURE__*/_jsx(_Fragment, {});
|
|
64
|
+
}
|
|
65
|
+
Timeout.defaultProps = {
|
|
66
|
+
time: 15 * 60,
|
|
67
|
+
contianer: document.body
|
|
68
|
+
};
|
|
69
|
+
export default Timeout;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
type CacheType = 'local' | 'session' | 'cookie';
|
|
2
|
+
/**
|
|
3
|
+
* 获取缓存数据
|
|
4
|
+
* @param {string} key
|
|
5
|
+
* @param {string} type: 缓存类型 'local'(默认) / cookie / session;
|
|
6
|
+
*/
|
|
7
|
+
declare function getCache(key: string, type?: CacheType): any;
|
|
8
|
+
/**
|
|
9
|
+
* 获取缓存数据
|
|
10
|
+
* @param {string} key
|
|
11
|
+
* @param {any} value
|
|
12
|
+
* @param {string} type: 缓存类型 'local'(默认) / cookie / session;
|
|
13
|
+
*/
|
|
14
|
+
declare function setCache(key: string, value: any, type?: CacheType): void;
|
|
15
|
+
/**
|
|
16
|
+
* 获取用户缓存
|
|
17
|
+
* @param {*} key
|
|
18
|
+
* @param {*} type
|
|
19
|
+
*/
|
|
20
|
+
declare function getUserCache(key: string, type?: CacheType): any;
|
|
21
|
+
/**
|
|
22
|
+
* 设置用户缓存
|
|
23
|
+
* @param {*} key
|
|
24
|
+
* @param {*} value
|
|
25
|
+
* @param {*} type
|
|
26
|
+
*/
|
|
27
|
+
declare function setUserCache(key: string, value: any, type?: CacheType): void;
|
|
28
|
+
declare const _default: {
|
|
29
|
+
getCache: typeof getCache;
|
|
30
|
+
setCache: typeof setCache;
|
|
31
|
+
getUserCache: typeof getUserCache;
|
|
32
|
+
setUserCache: typeof setUserCache;
|
|
33
|
+
};
|
|
34
|
+
export default _default;
|