@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,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface IToolsProps {
|
|
3
|
+
scale: number;
|
|
4
|
+
imgDownload?: () => void;
|
|
5
|
+
setScale: (scale: number) => void;
|
|
6
|
+
setRotate: (rotate: number) => void;
|
|
7
|
+
containerEle: HTMLDivElement;
|
|
8
|
+
resetPicture: (event: React.MouseEvent) => void;
|
|
9
|
+
}
|
|
10
|
+
declare function Tools({ scale, imgDownload, setScale, setRotate, containerEle, resetPicture }: IToolsProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export default Tools;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
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."); }
|
|
3
|
+
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); }
|
|
4
|
+
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; }
|
|
5
|
+
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; } }
|
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
import { useFullscreen } from 'ahooks';
|
|
8
|
+
import { Tooltip } from 'antd';
|
|
9
|
+
import React from 'react';
|
|
10
|
+
import IconFont from "../../../Player/iconfont";
|
|
11
|
+
import { pictureActionsCss, pictureToolsCss } from "./style";
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
15
|
+
function Tools(_ref) {
|
|
16
|
+
var scale = _ref.scale,
|
|
17
|
+
imgDownload = _ref.imgDownload,
|
|
18
|
+
setScale = _ref.setScale,
|
|
19
|
+
setRotate = _ref.setRotate,
|
|
20
|
+
containerEle = _ref.containerEle,
|
|
21
|
+
resetPicture = _ref.resetPicture;
|
|
22
|
+
var _useFullscreen = useFullscreen(containerEle),
|
|
23
|
+
_useFullscreen2 = _slicedToArray(_useFullscreen, 2),
|
|
24
|
+
isFullscreen = _useFullscreen2[0],
|
|
25
|
+
toggleFullscreen = _useFullscreen2[1].toggleFullscreen;
|
|
26
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
27
|
+
children: [/*#__PURE__*/_jsxs("div", {
|
|
28
|
+
className: pictureToolsCss,
|
|
29
|
+
children: [/*#__PURE__*/_jsx(Tooltip, {
|
|
30
|
+
placement: "left",
|
|
31
|
+
title: "\u590D\u4F4D",
|
|
32
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
33
|
+
onClick: resetPicture,
|
|
34
|
+
children: /*#__PURE__*/_jsx(IconFont, {
|
|
35
|
+
type: "lm-player-S_View_RotateMiddle"
|
|
36
|
+
})
|
|
37
|
+
})
|
|
38
|
+
}), /*#__PURE__*/_jsx(Tooltip, {
|
|
39
|
+
placement: "left",
|
|
40
|
+
title: "\u653E\u5927",
|
|
41
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
42
|
+
onClick: function onClick() {
|
|
43
|
+
return setScale(0.2);
|
|
44
|
+
},
|
|
45
|
+
className: scale === 3 ? 'disabled' : '',
|
|
46
|
+
children: /*#__PURE__*/_jsx(IconFont, {
|
|
47
|
+
type: "lm-player-S_View_ZoomIn"
|
|
48
|
+
})
|
|
49
|
+
})
|
|
50
|
+
}), /*#__PURE__*/_jsx(Tooltip, {
|
|
51
|
+
placement: "left",
|
|
52
|
+
title: "\u7F29\u5C0F",
|
|
53
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
54
|
+
onClick: function onClick() {
|
|
55
|
+
return setScale(-0.2);
|
|
56
|
+
},
|
|
57
|
+
className: scale === 1 ? 'disabled' : '',
|
|
58
|
+
children: /*#__PURE__*/_jsx(IconFont, {
|
|
59
|
+
type: "lm-player-S_View_ZoomOut"
|
|
60
|
+
})
|
|
61
|
+
})
|
|
62
|
+
}), /*#__PURE__*/_jsx(Tooltip, {
|
|
63
|
+
placement: "left",
|
|
64
|
+
title: "\u5411\u5DE6",
|
|
65
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
66
|
+
onClick: function onClick() {
|
|
67
|
+
return setRotate(-90);
|
|
68
|
+
},
|
|
69
|
+
children: /*#__PURE__*/_jsx(IconFont, {
|
|
70
|
+
type: "lm-player-S_View_RotateLeft"
|
|
71
|
+
})
|
|
72
|
+
})
|
|
73
|
+
}), /*#__PURE__*/_jsx(Tooltip, {
|
|
74
|
+
placement: "left",
|
|
75
|
+
title: "\u5411\u53F3",
|
|
76
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
77
|
+
onClick: function onClick() {
|
|
78
|
+
return setRotate(90);
|
|
79
|
+
},
|
|
80
|
+
children: /*#__PURE__*/_jsx(IconFont, {
|
|
81
|
+
type: "lm-player-S_View_RotateRight"
|
|
82
|
+
})
|
|
83
|
+
})
|
|
84
|
+
})]
|
|
85
|
+
}), /*#__PURE__*/_jsxs("div", {
|
|
86
|
+
className: pictureActionsCss,
|
|
87
|
+
children: [imgDownload && /*#__PURE__*/_jsx("div", {
|
|
88
|
+
onClick: imgDownload,
|
|
89
|
+
children: /*#__PURE__*/_jsx(IconFont, {
|
|
90
|
+
type: "lm-player-S_Edit_LoadDown"
|
|
91
|
+
})
|
|
92
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
93
|
+
children: /*#__PURE__*/_jsx("span", {
|
|
94
|
+
className: "className=\"footer_window",
|
|
95
|
+
onClick: toggleFullscreen,
|
|
96
|
+
children: /*#__PURE__*/_jsx(IconFont, {
|
|
97
|
+
className: "defualt-fullscreen-icon icon-primary",
|
|
98
|
+
type: !isFullscreen ? 'lm-player-S_View_ScreenViewFull' : 'lm-player-S_View_ScreenViewExit'
|
|
99
|
+
})
|
|
100
|
+
})
|
|
101
|
+
})]
|
|
102
|
+
})]
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
export default Tools;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
var _templateObject, _templateObject2;
|
|
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
|
+
export var pictureToolsCss = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: absolute;\n right: 10px;\n bottom: 10px;\n background: #fff;\n box-shadow: 0 2px 5px 0 rgb(0 0 0 / 30%);\n &.actions-change-rotate {\n bottom: 150px;\n }\n & > div {\n width: 30px;\n height: 25px;\n line-height: 25px;\n text-align: center;\n cursor: pointer;\n\n &.disabled {\n color: #999;\n cursor: not-allowed;\n\n .anticon {\n color: #999;\n }\n }\n }\n"])));
|
|
5
|
+
export var pictureActionsCss = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: absolute;\n top: 8px;\n right: 8px;\n & > div {\n float: left;\n width: 28px;\n height: 28px;\n margin-left: 4px;\n line-height: 28px;\n text-align: center;\n cursor: pointer;\n background: #fff;\n }\n\n .tools-screen-layer .anticon {\n padding-right: 0;\n }\n"])));
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React, { useCallback, useEffect } from 'react';
|
|
2
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
+
function WheelScale(_ref) {
|
|
5
|
+
var dom = _ref.dom,
|
|
6
|
+
setScale = _ref.setScale;
|
|
7
|
+
var onWheel = useCallback(function (e) {
|
|
8
|
+
if (e.ctrlKey || e.metaKey) {
|
|
9
|
+
e.preventDefault();
|
|
10
|
+
e.stopPropagation();
|
|
11
|
+
setScale(e.deltaY > 0 ? -0.2 : 0.2);
|
|
12
|
+
}
|
|
13
|
+
}, [setScale]);
|
|
14
|
+
|
|
15
|
+
//滚轮缩放
|
|
16
|
+
useEffect(function () {
|
|
17
|
+
if (!dom) {
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
dom.addEventListener('wheel', onWheel, {
|
|
21
|
+
passive: false
|
|
22
|
+
});
|
|
23
|
+
return function () {
|
|
24
|
+
return dom.removeEventListener('wheel', onWheel);
|
|
25
|
+
};
|
|
26
|
+
}, [dom, onWheel]);
|
|
27
|
+
return /*#__PURE__*/_jsx(_Fragment, {});
|
|
28
|
+
}
|
|
29
|
+
export default WheelScale;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function App(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
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."); }
|
|
3
|
+
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); }
|
|
4
|
+
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; }
|
|
5
|
+
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; } }
|
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
import { Button, ConfigProvider, Modal } from 'antd';
|
|
8
|
+
import Picture from '.';
|
|
9
|
+
import { useSimpleState } from '..';
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
|
+
export default function App() {
|
|
13
|
+
var _useSimpleState = useSimpleState({
|
|
14
|
+
open: false,
|
|
15
|
+
open2: false
|
|
16
|
+
}),
|
|
17
|
+
_useSimpleState2 = _slicedToArray(_useSimpleState, 2),
|
|
18
|
+
state = _useSimpleState2[0],
|
|
19
|
+
updateState = _useSimpleState2[1];
|
|
20
|
+
return /*#__PURE__*/_jsxs(ConfigProvider, {
|
|
21
|
+
prefixCls: "cloudapp",
|
|
22
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
23
|
+
style: {
|
|
24
|
+
width: 600,
|
|
25
|
+
height: 300,
|
|
26
|
+
background: '#000'
|
|
27
|
+
},
|
|
28
|
+
children: /*#__PURE__*/_jsx(Picture, {
|
|
29
|
+
onClickRect: console.log,
|
|
30
|
+
onMenuClick: console.log,
|
|
31
|
+
menus: [{
|
|
32
|
+
title: '菜单1',
|
|
33
|
+
pathname: '/',
|
|
34
|
+
icon: ''
|
|
35
|
+
}]
|
|
36
|
+
// imagePath="http://192.168.100.246:5463/oss/v1/100004008/objects/638da35805f5f0a8101021f9?client_token=100004008_0_1670313176_9a47a8459c120d977904c9feb2354a7e"
|
|
37
|
+
,
|
|
38
|
+
isOpenSelect: state.open,
|
|
39
|
+
imagePath: "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fc-ssl.duitang.com%2Fuploads%2Fitem%2F201503%2F16%2F20150316082631_YZ28f.jpeg&refer=http%3A%2F%2Fc-ssl.duitang.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1674876231&t=0824d5e8365bc9bcbe0484b5dbffff03"
|
|
40
|
+
// imagePath="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic1.win4000.com%2Fwallpaper%2F2018-08-07%2F5b69694c2e398.jpg&refer=http%3A%2F%2Fpic1.win4000.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1674875813&t=f1f2c44a50e5f3ddae91ba223f5eb99b"
|
|
41
|
+
,
|
|
42
|
+
rects: [{
|
|
43
|
+
type: 'face',
|
|
44
|
+
rect: [920.0, 843.0, 96.0, 94.0],
|
|
45
|
+
needExpand: true
|
|
46
|
+
}],
|
|
47
|
+
children: function children() {
|
|
48
|
+
return /*#__PURE__*/_jsx(Button, {
|
|
49
|
+
onClick: function onClick() {
|
|
50
|
+
return updateState({
|
|
51
|
+
open: true
|
|
52
|
+
});
|
|
53
|
+
},
|
|
54
|
+
children: "\u622A\u56FE"
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
})
|
|
58
|
+
}), /*#__PURE__*/_jsxs("div", {
|
|
59
|
+
style: {
|
|
60
|
+
width: 800,
|
|
61
|
+
height: 600,
|
|
62
|
+
background: '#000',
|
|
63
|
+
marginTop: 40
|
|
64
|
+
},
|
|
65
|
+
children: [/*#__PURE__*/_jsx(Button, {
|
|
66
|
+
onClick: function onClick() {
|
|
67
|
+
return updateState({
|
|
68
|
+
open2: true
|
|
69
|
+
});
|
|
70
|
+
},
|
|
71
|
+
children: "\u6253\u5F00"
|
|
72
|
+
}), /*#__PURE__*/_jsx(Modal, {
|
|
73
|
+
title: "modal",
|
|
74
|
+
open: state.open2,
|
|
75
|
+
onCancel: function onCancel() {
|
|
76
|
+
return updateState({
|
|
77
|
+
open2: false
|
|
78
|
+
});
|
|
79
|
+
},
|
|
80
|
+
width: 844,
|
|
81
|
+
destroyOnClose: true,
|
|
82
|
+
forceRender: true,
|
|
83
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
84
|
+
style: {
|
|
85
|
+
width: 800,
|
|
86
|
+
height: 600,
|
|
87
|
+
backgroundColor: '#000'
|
|
88
|
+
},
|
|
89
|
+
children: /*#__PURE__*/_jsx(Picture, {
|
|
90
|
+
imagePath: "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fc-ssl.duitang.com%2Fuploads%2Fblog%2F202106%2F09%2F20210609081952_51ef5.thumb.1000_0.jpg&refer=http%3A%2F%2Fc-ssl.duitang.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1673661389&t=906e24291130712565842eb7cf21e277",
|
|
91
|
+
isOpenSelect: false,
|
|
92
|
+
rects: [{
|
|
93
|
+
type: 'face',
|
|
94
|
+
rect: [698, 274, 23, 23],
|
|
95
|
+
needExpand: true
|
|
96
|
+
}, {
|
|
97
|
+
type: 'face',
|
|
98
|
+
rect: [754.0, 268.0, 23.0, 23.0],
|
|
99
|
+
needExpand: true
|
|
100
|
+
}, {
|
|
101
|
+
type: 'face',
|
|
102
|
+
rect: [430.0, 421.0, 49.0, 49.0],
|
|
103
|
+
needExpand: true
|
|
104
|
+
}, {
|
|
105
|
+
type: 'face',
|
|
106
|
+
rect: [240.0, 468.0, 41.0, 36.0],
|
|
107
|
+
needExpand: true
|
|
108
|
+
}]
|
|
109
|
+
})
|
|
110
|
+
})
|
|
111
|
+
})]
|
|
112
|
+
})]
|
|
113
|
+
});
|
|
114
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { IPictureProps } from './interface';
|
|
2
|
+
declare function Picture({ className, width, height, minHeight, disabledDrag, imagePath, rects, isOpenSelect, disabledDrawMenu, menus, hasTool, fullScreenEle, ...props }: IPictureProps): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
declare namespace Picture {
|
|
4
|
+
var defaultProps: {
|
|
5
|
+
width: string;
|
|
6
|
+
height: string;
|
|
7
|
+
className: string;
|
|
8
|
+
minHeight: number;
|
|
9
|
+
disabledDrag: boolean;
|
|
10
|
+
isOpenSelect: boolean;
|
|
11
|
+
disabledDrawMenu: boolean;
|
|
12
|
+
menus: never[];
|
|
13
|
+
rects: never[];
|
|
14
|
+
hasTool: boolean;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export default Picture;
|
|
@@ -0,0 +1,356 @@
|
|
|
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 = ["className", "width", "height", "minHeight", "disabledDrag", "imagePath", "rects", "isOpenSelect", "disabledDrawMenu", "menus", "hasTool", "fullScreenEle"];
|
|
3
|
+
var _templateObject, _templateObject2, _templateObject3;
|
|
4
|
+
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; }
|
|
5
|
+
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; }
|
|
6
|
+
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; }
|
|
7
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
8
|
+
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); }
|
|
9
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
10
|
+
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."); }
|
|
11
|
+
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); }
|
|
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
|
+
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; } }
|
|
14
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
15
|
+
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; }
|
|
16
|
+
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; }
|
|
17
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
18
|
+
import { css } from '@emotion/css';
|
|
19
|
+
import { useMemoizedFn, useSize, useUpdateEffect, useUpdateLayoutEffect } from 'ahooks';
|
|
20
|
+
import React, { useEffect, useMemo, useRef } from 'react';
|
|
21
|
+
import DomMove from "../DomMove";
|
|
22
|
+
import useSimpleState from "../useSimpleState";
|
|
23
|
+
import DefaultRects from "./component/DefaultRects";
|
|
24
|
+
import DrawRect from "./component/DrawRect";
|
|
25
|
+
import Tools from "./component/Tools";
|
|
26
|
+
import WheelScale from "./component/WheelScale";
|
|
27
|
+
import { getRectImagePath } from "./loadCaptureRectImage";
|
|
28
|
+
import useDraw from "./useDraw";
|
|
29
|
+
import { computedRectScale, customContextMenu, getImgSize } from "./utils";
|
|
30
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
31
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
32
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
33
|
+
var pictureViewLayout = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: relative;\n min-height: 300px;\n overflow: hidden;\n user-select: none;\n"])));
|
|
34
|
+
var pictureMoveLayoutDiv = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n width: max-content;\n height: max-content;\n transition: all 0.3s;\n overflow: hidden;\n"])));
|
|
35
|
+
var pictureMoveLayoutImg = css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n max-width: 100%;\n max-height: 100%;\n"])));
|
|
36
|
+
function Picture(_ref) {
|
|
37
|
+
var _layoutRef$current;
|
|
38
|
+
var className = _ref.className,
|
|
39
|
+
width = _ref.width,
|
|
40
|
+
height = _ref.height,
|
|
41
|
+
minHeight = _ref.minHeight,
|
|
42
|
+
disabledDrag = _ref.disabledDrag,
|
|
43
|
+
imagePath = _ref.imagePath,
|
|
44
|
+
rects = _ref.rects,
|
|
45
|
+
isOpenSelect = _ref.isOpenSelect,
|
|
46
|
+
disabledDrawMenu = _ref.disabledDrawMenu,
|
|
47
|
+
menus = _ref.menus,
|
|
48
|
+
hasTool = _ref.hasTool,
|
|
49
|
+
fullScreenEle = _ref.fullScreenEle,
|
|
50
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
51
|
+
var _useMemo = useMemo(function () {
|
|
52
|
+
return props;
|
|
53
|
+
}, [props]),
|
|
54
|
+
imgDownload = _useMemo.imgDownload,
|
|
55
|
+
onClickRect = _useMemo.onClickRect,
|
|
56
|
+
onMenuClick = _useMemo.onMenuClick,
|
|
57
|
+
children = _useMemo.children;
|
|
58
|
+
var _useSimpleState = useSimpleState({
|
|
59
|
+
x: 0,
|
|
60
|
+
y: 0,
|
|
61
|
+
rotate: 0,
|
|
62
|
+
scale: 1,
|
|
63
|
+
baseXOrY: 'x',
|
|
64
|
+
forceUpdateKey: Date.now(),
|
|
65
|
+
loadedTime: 0,
|
|
66
|
+
fullScreenStatus: false,
|
|
67
|
+
localUrl: '',
|
|
68
|
+
offset: [0, 0],
|
|
69
|
+
size: ['auto', 'auto']
|
|
70
|
+
}),
|
|
71
|
+
_useSimpleState2 = _slicedToArray(_useSimpleState, 3),
|
|
72
|
+
state = _useSimpleState2[0],
|
|
73
|
+
updateState = _useSimpleState2[1],
|
|
74
|
+
setState = _useSimpleState2[2];
|
|
75
|
+
var layoutRef = useRef(null);
|
|
76
|
+
var moveActionRef = useRef(null);
|
|
77
|
+
var domImgRef = useRef(null);
|
|
78
|
+
var size = useSize(layoutRef);
|
|
79
|
+
useEffect(function () {
|
|
80
|
+
if (!imagePath) {
|
|
81
|
+
return undefined;
|
|
82
|
+
}
|
|
83
|
+
var localUrl;
|
|
84
|
+
fetch(imagePath).then(function (res) {
|
|
85
|
+
return res.blob();
|
|
86
|
+
}).then(function (blob) {
|
|
87
|
+
localUrl = URL.createObjectURL(blob);
|
|
88
|
+
updateState({
|
|
89
|
+
localUrl: localUrl
|
|
90
|
+
});
|
|
91
|
+
}).catch(function (e) {
|
|
92
|
+
console.error(e);
|
|
93
|
+
});
|
|
94
|
+
return function () {
|
|
95
|
+
return URL.revokeObjectURL(localUrl);
|
|
96
|
+
};
|
|
97
|
+
}, [imagePath]);
|
|
98
|
+
|
|
99
|
+
// draw hooks
|
|
100
|
+
var _useDraw = useDraw((_layoutRef$current = layoutRef.current) === null || _layoutRef$current === void 0 ? void 0 : _layoutRef$current.querySelector('.picture-overlay'), isOpenSelect),
|
|
101
|
+
_useDraw2 = _slicedToArray(_useDraw, 2),
|
|
102
|
+
selectArea = _useDraw2[0],
|
|
103
|
+
isEnd = _useDraw2[1];
|
|
104
|
+
|
|
105
|
+
// init loaded
|
|
106
|
+
var loadImageSuccess = useMemoizedFn(function () {
|
|
107
|
+
if (!state.localUrl || !layoutRef.current || !domImgRef.current) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
var _getImgSize = getImgSize(layoutRef.current, domImgRef.current),
|
|
111
|
+
x = _getImgSize.x,
|
|
112
|
+
y = _getImgSize.y,
|
|
113
|
+
size = _getImgSize.size,
|
|
114
|
+
baseXOrY = _getImgSize.baseXOrY;
|
|
115
|
+
var moveObj = moveActionRef.current;
|
|
116
|
+
moveObj.updatePosition({
|
|
117
|
+
x: x,
|
|
118
|
+
y: y
|
|
119
|
+
});
|
|
120
|
+
setState(function (old) {
|
|
121
|
+
return _objectSpread(_objectSpread({}, old), {}, {
|
|
122
|
+
x: x,
|
|
123
|
+
y: y,
|
|
124
|
+
offset: [x, y],
|
|
125
|
+
baseXOrY: baseXOrY,
|
|
126
|
+
size: size,
|
|
127
|
+
loadedTime: Date.now()
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
// 更新重绘
|
|
133
|
+
useUpdateLayoutEffect(function () {
|
|
134
|
+
loadImageSuccess();
|
|
135
|
+
}, [size]);
|
|
136
|
+
|
|
137
|
+
// 更新重绘
|
|
138
|
+
useUpdateLayoutEffect(function () {
|
|
139
|
+
// Rects重新计算
|
|
140
|
+
updateState({
|
|
141
|
+
forceUpdateKey: Date.now()
|
|
142
|
+
});
|
|
143
|
+
}, [state.loadedTime]);
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* 设置图片缩放
|
|
147
|
+
*/
|
|
148
|
+
var setScale = useMemoizedFn(function (changeValue) {
|
|
149
|
+
var currentValue = state.scale;
|
|
150
|
+
if (currentValue === 3 && changeValue > 0) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
if (currentValue === 1 && changeValue < 0) {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
var scale = currentValue + changeValue;
|
|
157
|
+
if (scale > 3) {
|
|
158
|
+
scale = 3;
|
|
159
|
+
}
|
|
160
|
+
if (scale < 1) {
|
|
161
|
+
scale = 1;
|
|
162
|
+
}
|
|
163
|
+
setState(function (old) {
|
|
164
|
+
return _objectSpread(_objectSpread({}, old), {}, {
|
|
165
|
+
scale: scale
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* 设置图谱旋转
|
|
172
|
+
*/
|
|
173
|
+
var setRotate = useMemoizedFn(function (changeValue) {
|
|
174
|
+
var currentValue = state.rotate;
|
|
175
|
+
setState(function (old) {
|
|
176
|
+
return _objectSpread(_objectSpread({}, old), {}, {
|
|
177
|
+
rotate: currentValue + changeValue
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* 重置图片位置
|
|
184
|
+
*/
|
|
185
|
+
var resetPicture = useMemoizedFn(function (event) {
|
|
186
|
+
event.stopPropagation();
|
|
187
|
+
var moveObj = moveActionRef.current;
|
|
188
|
+
setState(function (old) {
|
|
189
|
+
return _objectSpread(_objectSpread({}, old), {}, {
|
|
190
|
+
scale: 1,
|
|
191
|
+
rotate: 0
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
moveObj.updatePosition({
|
|
195
|
+
x: state.offset[0],
|
|
196
|
+
y: state.offset[1]
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* 拖拽更新位置
|
|
202
|
+
*/
|
|
203
|
+
var onDragChange = useMemoizedFn(function (_ref2) {
|
|
204
|
+
var x = _ref2.x,
|
|
205
|
+
y = _ref2.y;
|
|
206
|
+
return setState(function (old) {
|
|
207
|
+
return _objectSpread(_objectSpread({}, old), {}, {
|
|
208
|
+
x: x,
|
|
209
|
+
y: y
|
|
210
|
+
});
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* 拖拽结束更新位置,计算边界
|
|
216
|
+
*/
|
|
217
|
+
var onDragEnd = useMemoizedFn(function (_, currrentPosition) {
|
|
218
|
+
if (!layoutRef.current || !domImgRef.current) {
|
|
219
|
+
return undefined;
|
|
220
|
+
}
|
|
221
|
+
var _ref3 = size || {
|
|
222
|
+
width: 0,
|
|
223
|
+
height: 0
|
|
224
|
+
},
|
|
225
|
+
width = _ref3.width,
|
|
226
|
+
height = _ref3.height;
|
|
227
|
+
var imgw = domImgRef.current.width * state.scale;
|
|
228
|
+
var imgh = domImgRef.current.height * state.scale;
|
|
229
|
+
var scaleW = imgw - domImgRef.current.width;
|
|
230
|
+
var scaleH = imgh - domImgRef.current.height;
|
|
231
|
+
|
|
232
|
+
// 校验x,y范围,超出回弹
|
|
233
|
+
var maxX = imgw < width ? width - imgw + scaleW / 2 : scaleW / 2;
|
|
234
|
+
var maxY = imgh < height ? height - imgh + scaleH / 2 : scaleH / 2;
|
|
235
|
+
var minX = imgw < width ? scaleW / 2 : -(imgw - width) / 2 + state.offset[0];
|
|
236
|
+
var minY = imgh < height ? scaleH / 2 : -(imgh - height) / 2 + state.offset[1];
|
|
237
|
+
var x = currrentPosition.x > maxX ? maxX : currrentPosition.x < minX ? minX : currrentPosition.x;
|
|
238
|
+
var y = currrentPosition.y > maxY ? maxY : currrentPosition.y < minY ? minY : currrentPosition.y;
|
|
239
|
+
var moveObj = moveActionRef.current;
|
|
240
|
+
moveObj.updatePosition({
|
|
241
|
+
x: x,
|
|
242
|
+
y: y
|
|
243
|
+
});
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* 获取结构化的小图(base64)
|
|
248
|
+
*/
|
|
249
|
+
var getRectImage = useMemoizedFn(function (rect) {
|
|
250
|
+
return getRectImagePath(domImgRef.current, rect);
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
254
|
+
var scaleRects = useMemo(function () {
|
|
255
|
+
return computedRectScale({
|
|
256
|
+
domImg: domImgRef.current,
|
|
257
|
+
rects: rects !== null && rects !== void 0 ? rects : []
|
|
258
|
+
});
|
|
259
|
+
}, [rects, state.forceUpdateKey]);
|
|
260
|
+
var isEmpty = useMemo(function () {
|
|
261
|
+
return selectArea.includes(0);
|
|
262
|
+
}, [selectArea]);
|
|
263
|
+
var renderOptions = {
|
|
264
|
+
isEnd: isEnd,
|
|
265
|
+
isOpenSelect: isOpenSelect,
|
|
266
|
+
selectArea: selectArea,
|
|
267
|
+
getRectImage: getRectImage,
|
|
268
|
+
containerEle: layoutRef.current
|
|
269
|
+
};
|
|
270
|
+
useUpdateEffect(function () {
|
|
271
|
+
if (isOpenSelect) {
|
|
272
|
+
var moveObj = moveActionRef.current;
|
|
273
|
+
moveObj.updatePosition({
|
|
274
|
+
x: state.offset[0],
|
|
275
|
+
y: state.offset[1]
|
|
276
|
+
});
|
|
277
|
+
updateState({
|
|
278
|
+
scale: 1,
|
|
279
|
+
rotate: 0,
|
|
280
|
+
x: state.offset[0],
|
|
281
|
+
y: state.offset[1]
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
}, [isOpenSelect]);
|
|
285
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
286
|
+
children: [/*#__PURE__*/_jsxs("div", {
|
|
287
|
+
className: "".concat(pictureViewLayout, " ").concat(className),
|
|
288
|
+
style: {
|
|
289
|
+
width: width,
|
|
290
|
+
height: height,
|
|
291
|
+
minHeight: minHeight
|
|
292
|
+
},
|
|
293
|
+
ref: layoutRef,
|
|
294
|
+
onContextMenu: customContextMenu,
|
|
295
|
+
children: [/*#__PURE__*/_jsx(DomMove, {
|
|
296
|
+
disabled: isOpenSelect || disabledDrag,
|
|
297
|
+
ref: moveActionRef,
|
|
298
|
+
onDragChange: onDragChange,
|
|
299
|
+
onDragEnd: onDragEnd,
|
|
300
|
+
children: /*#__PURE__*/_jsxs("div", {
|
|
301
|
+
className: "picture-overlay ".concat(pictureMoveLayoutDiv),
|
|
302
|
+
style: {
|
|
303
|
+
transform: "scale(".concat(state.scale, ") rotate(").concat(state.rotate, "deg)")
|
|
304
|
+
},
|
|
305
|
+
children: [/*#__PURE__*/_jsx("img", {
|
|
306
|
+
ref: domImgRef,
|
|
307
|
+
className: pictureMoveLayoutImg,
|
|
308
|
+
draggable: false,
|
|
309
|
+
src: state.localUrl,
|
|
310
|
+
style: {
|
|
311
|
+
width: state.size[0],
|
|
312
|
+
height: state.size[1]
|
|
313
|
+
},
|
|
314
|
+
"data-src": imagePath,
|
|
315
|
+
onLoad: loadImageSuccess
|
|
316
|
+
}), !isEmpty ? /*#__PURE__*/_jsx(DrawRect, {
|
|
317
|
+
rect: selectArea,
|
|
318
|
+
onMenuClick: onMenuClick,
|
|
319
|
+
getRectImage: getRectImage,
|
|
320
|
+
menus: menus !== null && menus !== void 0 ? menus : [],
|
|
321
|
+
canRenderMenu: isEnd && !disabledDrawMenu && menus && menus.length > 0,
|
|
322
|
+
containerDom: layoutRef.current
|
|
323
|
+
}) : !isOpenSelect ? /*#__PURE__*/_jsx(DefaultRects, {
|
|
324
|
+
rects: scaleRects,
|
|
325
|
+
onClickRect: onClickRect,
|
|
326
|
+
getRectImage: getRectImage,
|
|
327
|
+
containerDom: layoutRef.current
|
|
328
|
+
}) : null]
|
|
329
|
+
})
|
|
330
|
+
}), hasTool && /*#__PURE__*/_jsx(Tools, {
|
|
331
|
+
setScale: setScale,
|
|
332
|
+
setRotate: setRotate,
|
|
333
|
+
scale: state.scale,
|
|
334
|
+
containerEle: fullScreenEle !== null && fullScreenEle !== void 0 ? fullScreenEle : layoutRef.current,
|
|
335
|
+
resetPicture: resetPicture,
|
|
336
|
+
imgDownload: imgDownload
|
|
337
|
+
}), /*#__PURE__*/_jsx(WheelScale, {
|
|
338
|
+
setScale: setScale,
|
|
339
|
+
dom: layoutRef.current
|
|
340
|
+
})]
|
|
341
|
+
}), children === null || children === void 0 ? void 0 : children(renderOptions)]
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
Picture.defaultProps = {
|
|
345
|
+
width: '100%',
|
|
346
|
+
height: '100%',
|
|
347
|
+
className: '',
|
|
348
|
+
minHeight: 300,
|
|
349
|
+
disabledDrag: false,
|
|
350
|
+
isOpenSelect: false,
|
|
351
|
+
disabledDrawMenu: false,
|
|
352
|
+
menus: [],
|
|
353
|
+
rects: [],
|
|
354
|
+
hasTool: true
|
|
355
|
+
};
|
|
356
|
+
export default Picture;
|