@ray-js/ipc-player-integration 0.0.1-beta-21 → 0.0.1-beta-23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/lib/ctx/ctx.composition.js +19 -9
  2. package/lib/ctx/ctx.d.ts +5 -3
  3. package/lib/ctx/ctx.js +57 -28
  4. package/lib/ctx/store.d.ts +1 -1
  5. package/lib/ctx/store.js +1 -1
  6. package/lib/i18n/index.d.ts +28 -0
  7. package/lib/i18n/strings.d.ts +14 -0
  8. package/lib/i18n/strings.js +16 -2
  9. package/lib/interface.d.ts +18 -8
  10. package/lib/plugins/battery/battery.composition.d.ts +47 -5
  11. package/lib/plugins/battery/battery.composition.js +4 -0
  12. package/lib/plugins/battery/battery.js +9 -9
  13. package/lib/plugins/battery/battery.less +4 -14
  14. package/lib/plugins/battery/batteryFull.d.ts +13 -0
  15. package/lib/plugins/battery/batteryFull.js +46 -0
  16. package/lib/plugins/fullScreen/fullScreen.js +12 -10
  17. package/lib/plugins/fullScreen/fullScreen.less +9 -8
  18. package/lib/plugins/fullScreen/verticalScreen.d.ts +1 -1
  19. package/lib/plugins/fullScreen/verticalScreen.js +8 -5
  20. package/lib/plugins/fullScreen/verticalScreen.less +7 -12
  21. package/lib/plugins/fullScreen/voiceIntercom.js +2 -2
  22. package/lib/plugins/index.d.ts +3 -1
  23. package/lib/plugins/index.js +6 -2
  24. package/lib/plugins/muted/muted.js +4 -4
  25. package/lib/plugins/muted/muted.less +8 -1
  26. package/lib/plugins/ptz/ptz.js +13 -26
  27. package/lib/plugins/ptz/ptz.less +2 -7
  28. package/lib/plugins/ptz/ptzControl.d.ts +0 -1
  29. package/lib/plugins/ptz/ptzControl.js +76 -32
  30. package/lib/plugins/recordVideo/recordVideo.js +154 -26
  31. package/lib/plugins/recordVideo/recordVideo.less +63 -6
  32. package/lib/plugins/resolution/fullResolutionControl.js +2 -2
  33. package/lib/plugins/resolution/resolution.js +9 -3
  34. package/lib/plugins/resolution/resolution.less +5 -5
  35. package/lib/plugins/screenshot/screenshot.js +65 -14
  36. package/lib/plugins/screenshot/screenshot.less +25 -23
  37. package/lib/plugins/smallIntercom/index.d.ts +1 -0
  38. package/lib/plugins/smallIntercom/index.js +1 -0
  39. package/lib/plugins/smallIntercom/smallIntercom.d.ts +6 -0
  40. package/lib/plugins/smallIntercom/smallIntercom.js +49 -0
  41. package/lib/plugins/smallIntercom/smallIntercom.less +50 -0
  42. package/lib/plugins/tempHumidity/tempHumidity.d.ts +1 -1
  43. package/lib/plugins/tempHumidity/tempHumidity.js +12 -4
  44. package/lib/plugins/videoBitKBP/index.d.ts +1 -0
  45. package/lib/plugins/videoBitKBP/index.js +1 -0
  46. package/lib/plugins/{videoBitKbps/videoBitKbps.d.ts → videoBitKBP/videoBitKBP.d.ts} +2 -2
  47. package/lib/plugins/{videoBitKbps/videoBitKbps.js → videoBitKBP/videoBitKBP.js} +14 -7
  48. package/lib/plugins/{videoBitKbps/videoBitKbps.less → videoBitKBP/videoBitKBP.less} +4 -5
  49. package/lib/plugins/voiceIntercom/voiceIntercom.d.ts +1 -1
  50. package/lib/plugins/voiceIntercom/voiceIntercom.js +25 -18
  51. package/lib/ui/bottomLeftContent.d.ts +8 -0
  52. package/lib/ui/bottomLeftContent.js +33 -0
  53. package/lib/ui/bottomRightContent.d.ts +8 -0
  54. package/lib/ui/bottomRightContent.js +33 -0
  55. package/lib/ui/constant.d.ts +1 -0
  56. package/lib/ui/constant.js +2 -1
  57. package/lib/ui/hooks.d.ts +1 -1
  58. package/lib/ui/hooks.js +4 -3
  59. package/lib/ui/{bottomContent.d.ts → topLeftContent.d.ts} +2 -2
  60. package/lib/ui/{bottomContent.js → topLeftContent.js} +9 -8
  61. package/lib/ui/{topContent.d.ts → topRightContent.d.ts} +2 -2
  62. package/lib/ui/{topContent.js → topRightContent.js} +9 -8
  63. package/lib/ui/ui.d.ts +3 -0
  64. package/lib/ui/ui.js +115 -56
  65. package/lib/ui/ui.less +162 -25
  66. package/lib/utils/device/index.d.ts +6 -0
  67. package/lib/utils/device/index.js +52 -0
  68. package/lib/utils/index.d.ts +3 -0
  69. package/lib/utils/index.js +15 -0
  70. package/package.json +7 -9
  71. package/lib/plugins/videoBitKbps/index.d.ts +0 -1
  72. package/lib/plugins/videoBitKbps/index.js +0 -1
@@ -1,11 +1,16 @@
1
1
  import React, { useState, useEffect, useRef, useContext } from 'react';
2
- import { View } from '@ray-js/ray';
2
+ import { View, Text, Image } from '@ray-js/ray';
3
+ import { useSetState, useUpdateEffect } from 'ahooks';
3
4
  import clsx from 'clsx';
5
+ import IpcUtils from '@ray-js/ray-ipc-utils';
6
+ import Strings from '../../i18n';
4
7
  import { UIEventContext } from '../../ui/context';
5
- import { startTimeToHideAllComponent, pauseTimeToHideAllComponent } from '../../ui/constant';
6
8
  import { useStore, getDefaultStore } from '../../ctx/store';
7
9
  import './recordVideo.less';
8
- const RECORD_VIDEO_TOAST_ID = 'record_video_toast_id';
10
+ const CLOSE_TIME = 5000;
11
+ const RESET_TIMER = 3000;
12
+ const RECORD_VIDEO_SUCCESS_TOAST_ID = 'record_video_SUCCESS_toast_id';
13
+ const RECORD_VIDEO_TIMER_ID = 'record_video_timer_id';
9
14
  function formatTimeDiff(diff) {
10
15
  const padWithZero = true;
11
16
  const diffMs = Math.abs(diff);
@@ -49,11 +54,18 @@ function useTime() {
49
54
  };
50
55
  }
51
56
  function TimeRecord() {
57
+ // const { showTimer } = props;
52
58
  const {
53
59
  min,
54
60
  sec,
55
61
  cancel
56
62
  } = useTime();
63
+ // useEffect(() => {
64
+ // console.log('____________', showTimer);
65
+ // if (!showTimer) {
66
+ // cancel();
67
+ // }
68
+ // }, [showTimer]);
57
69
  return /*#__PURE__*/React.createElement(View, {
58
70
  className: "ipc-player-plugin-record-video-toast-time"
59
71
  }, /*#__PURE__*/React.createElement(View, {
@@ -70,46 +82,162 @@ export function RecordVideo(props) {
70
82
  } = useContext(UIEventContext);
71
83
  const {
72
84
  addContent,
73
- deleteContent
74
- } = props;
75
- const {
85
+ deleteContent,
76
86
  recording: recordingAtom,
77
- setRecording
87
+ setRecording,
88
+ setRecordingDisabled,
89
+ devId,
90
+ className
78
91
  } = props;
79
92
  const {
80
- recording
93
+ recording,
94
+ brandColor,
95
+ screenType,
96
+ recordingDisabled
81
97
  } = useStore({
82
- recording: recordingAtom
98
+ recording: recordingAtom,
99
+ brandColor: props.brandColor,
100
+ screenType: props.screenType,
101
+ recordingDisabled: props.recordingDisabled
83
102
  });
103
+ const [state, setState] = useSetState({
104
+ showTimer: false,
105
+ showShot: false,
106
+ shotUrl: ''
107
+ });
108
+
109
+ /** 设置5秒后关闭录制成功弹窗 */
110
+ const timer = useRef();
111
+ const timeToCloseRecordToast = () => {
112
+ clearTimeout(timer.current);
113
+ // @ts-ignore
114
+ timer.current = setTimeout(() => {
115
+ setState({
116
+ showShot: false,
117
+ shotUrl: ''
118
+ });
119
+ deleteContent('absolute', RECORD_VIDEO_SUCCESS_TOAST_ID);
120
+ }, CLOSE_TIME);
121
+ };
122
+
123
+ /** 设置3秒后还原禁止结束录像状态 */
124
+ const recordDisabledTimer = useRef();
125
+ const timeToResetRecordDisabled = () => {
126
+ clearTimeout(recordDisabledTimer.current);
127
+ // @ts-ignore
128
+ recordDisabledTimer.current = setTimeout(() => {
129
+ setRecordingDisabled(false);
130
+ }, RESET_TIMER);
131
+ };
132
+ useUpdateEffect(() => {
133
+ if (state.showShot && screenType) {
134
+ showRecordToast();
135
+ }
136
+ }, [state.showShot, screenType]);
137
+
138
+ /** 根据showTimer的显示定时器 */
139
+ useUpdateEffect(() => {
140
+ if (state.showTimer) {
141
+ showRecordTimer();
142
+ } else {
143
+ deleteContent('absolute', RECORD_VIDEO_TIMER_ID);
144
+ // 清除定时器,元素移除
145
+ }
146
+ }, [state.showTimer]);
147
+
148
+ /** 跳转相册 */
149
+ const handCheck = () => {
150
+ IpcUtils.goToIpcPageNativeRoute('ipc_album_panel', devId);
151
+ };
152
+
153
+ /** 添加录制成功弹窗 */
154
+ const showRecordToast = () => {
155
+ deleteContent('absolute', RECORD_VIDEO_SUCCESS_TOAST_ID);
156
+ addContent('absolute', {
157
+ id: RECORD_VIDEO_SUCCESS_TOAST_ID,
158
+ absoluteContentClassName: 'ipc-player-plugin-record-success-toast-wrap',
159
+ absolutePosition: {
160
+ top: screenType === 'vertical' ? '12px' : '60px',
161
+ left: screenType === 'vertical' ? '16px' : '50%',
162
+ right: screenType === 'vertical' ? '16px' : 'unset',
163
+ display: 'flex',
164
+ width: screenType === 'vertical' ? 'auto' : '400px',
165
+ marginLeft: screenType === 'vertical' ? '0' : '-200px'
166
+ },
167
+ content: () => {
168
+ return /*#__PURE__*/React.createElement(View, {
169
+ className: "ipc-player-plugin-record-success-toast"
170
+ }, /*#__PURE__*/React.createElement(View, {
171
+ className: "ipc-player-plugin-record-success-toast-image-box"
172
+ }, /*#__PURE__*/React.createElement(Image, {
173
+ className: "ipc-player-plugin-record-success-toast-image",
174
+ src: state.shotUrl
175
+ })), /*#__PURE__*/React.createElement(View, {
176
+ className: "ipc-player-plugin-record-success-toast-title"
177
+ }, Strings.getLang('ipc_player_record_success_tip')), /*#__PURE__*/React.createElement(View, {
178
+ onClick: handCheck,
179
+ className: "ipc-player-plugin-record-success-toast-bottom",
180
+ style: {
181
+ color: brandColor,
182
+ borderColor: brandColor
183
+ }
184
+ }, Strings.getLang('ipc_player_record_success_check')));
185
+ }
186
+ });
187
+ timeToCloseRecordToast();
188
+ };
189
+ const showRecordTimer = () => {
190
+ deleteContent('absolute', RECORD_VIDEO_TIMER_ID);
191
+ addContent('absolute', {
192
+ id: RECORD_VIDEO_TIMER_ID,
193
+ absoluteContentClassName: 'ipc-player-plugin-record-video-toast-wrap',
194
+ content: () => /*#__PURE__*/React.createElement(View, {
195
+ className: clsx('ipc-player-plugin-record-video-toast', {
196
+ 'ipc-player-plugin-record-video-toast-show': state.showTimer,
197
+ 'ipc-player-plugin-record-video-toast-hide': !state.showTimer
198
+ })
199
+ }, /*#__PURE__*/React.createElement(View, {
200
+ className: "ipc-player-plugin-record-video-toast-point",
201
+ style: {
202
+ backgroundColor: brandColor
203
+ }
204
+ }), /*#__PURE__*/React.createElement(TimeRecord, null))
205
+ });
206
+ };
84
207
  const handRecordVideo = async () => {
85
208
  const store = getDefaultStore();
86
209
  const _recording = store.get(recordingAtom);
87
210
  const target = !_recording;
88
- if (target) {
89
- event.emit(pauseTimeToHideAllComponent);
90
- } else {
91
- event.emit(startTimeToHideAllComponent);
211
+ if (recordingDisabled) {
212
+ return false;
92
213
  }
93
- await setRecording(target);
214
+ const recordInfo = await setRecording(target);
94
215
  if (target) {
95
- addContent('absolute', {
96
- id: RECORD_VIDEO_TOAST_ID,
97
- absoluteContentClassName: 'ipc-player-plugin-record-video-toast-wrap',
98
- content: () => /*#__PURE__*/React.createElement(View, {
99
- className: "ipc-player-plugin-record-video-toast"
100
- }, /*#__PURE__*/React.createElement(View, {
101
- className: "ipc-player-plugin-record-video-toast-point"
102
- }), /*#__PURE__*/React.createElement(TimeRecord, null))
216
+ setRecordingDisabled(true);
217
+ setState({
218
+ showTimer: true
103
219
  });
220
+ /** 录制开始后3秒后才可结束 */
221
+ timeToResetRecordDisabled();
104
222
  } else {
105
- deleteContent('absolute', RECORD_VIDEO_TOAST_ID);
223
+ setState({
224
+ showTimer: false,
225
+ showShot: true,
226
+ shotUrl: recordInfo.tempImagePath
227
+ });
106
228
  }
229
+ return true;
107
230
  };
108
231
  return /*#__PURE__*/React.createElement(View, {
109
232
  onClick: () => handRecordVideo(),
110
- className: clsx('ipc-player-plugin-record-video-icon', 'icon-panel', recording ? 'icon-panel-record-stop' : 'icon-panel-record'),
233
+ className: clsx(className, ''),
111
234
  style: {
112
- color: recording ? 'rgba(255, 56, 56, 1)' : undefined
235
+ opacity: recordingDisabled ? 0.5 : 1
113
236
  }
114
- });
237
+ }, /*#__PURE__*/React.createElement(Text, {
238
+ className: clsx('icon-panel', 'ipc-player-plugin-record-video-icon', recording ? 'icon-panel-record-stop' : 'icon-panel-record'),
239
+ style: {
240
+ color: recording ? brandColor : undefined
241
+ }
242
+ }));
115
243
  }
@@ -1,19 +1,32 @@
1
1
  .ipc-player-plugin-record-video-icon {
2
- font-size: calc(var(--iconFontSize) * var(--ipc-player-size-scale, 1));
2
+ font-size: calc(var(--iconPlayerSize) * var(--ipc-player-size-scale, 1)) !important;
3
3
  color: var(--iconColor);
4
4
  }
5
5
  .ipc-player-plugin-record-video-toast-wrap {
6
- z-index: 110;
6
+ z-index: 400;
7
7
  position: absolute;
8
8
  top: calc(7px * var(--ipc-player-size-scale, 1));
9
9
  left: 50%;
10
10
  transform: translateX(-50%);
11
11
  }
12
+
13
+ // 计时器显示
14
+ .ipc-player-plugin-record-video-toast-show {
15
+ transform: translate(0, 0) !important;
16
+ transition: transform ease-in 3s;
17
+ }
18
+ // 计时器隐藏
19
+ .ipc-player-plugin-record-video-toast-hide {
20
+ transform: translate(0, -110%) !important;
21
+ transition: transform 0.3s ease-in-out;
22
+ }
23
+
12
24
  .ipc-player-plugin-record-video-toast {
25
+ transform: translate(0, -110%);
13
26
  display: flex;
14
27
  padding: calc(12px * var(--ipc-player-size-scale, 1));
15
28
  align-items: center;
16
- background-color: var(--bg-color);
29
+ background-color: var(--shot-card-bg-color);
17
30
  border-radius: calc(8px * var(--ipc-player-size-scale, 1));
18
31
  // background-color: #fff;
19
32
  background: linear-gradient(0deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.15)), #000000;
@@ -21,21 +34,65 @@
21
34
  width: calc(6px * var(--ipc-player-size-scale, 1));
22
35
  height: calc(6px * var(--ipc-player-size-scale, 1));
23
36
  border-radius: calc(6px * var(--ipc-player-size-scale, 1));
24
- background-color: #FF3838;
25
37
  }
26
38
  .ipc-player-plugin-record-video-toast-time {
27
39
  font-size: calc(12px * var(--ipc-player-size-scale, 1));;
28
- font-weight: 600;
40
+ font-weight: 700;
29
41
  color: var(--fontColor);
30
42
  margin-left: calc(8px * var(--ipc-player-size-scale, 1));;
31
43
  display: flex;
32
44
  align-items: center;
45
+ font-family: Manrope !important;
33
46
  .ipc-player-plugin-record-video-toast-time-warp {
34
- width: calc(17px * var(--ipc-player-size-scale, 1));;
35
47
  text-align: center;
36
48
  }
37
49
  .ipc-player-plugin-record-video-toast-time-delimiter {
38
50
  margin: 0 calc(2px * var(--ipc-player-size-scale, 1));;
39
51
  }
40
52
  }
53
+ }
54
+
55
+ /** 录制成功弹窗 */
56
+ .ipc-player-plugin-record-success-toast-wrap {
57
+ position: absolute;
58
+ }
59
+ .ipc-player-plugin-record-success-toast {
60
+ flex: 1;
61
+ border-radius: calc(8px * var(--ipc-player-size-scale, 1));;
62
+ background-color: var(--shot-card-bg-color);
63
+ display: flex;
64
+ align-items: center;
65
+ padding: calc(8px * var(--ipc-player-size-scale, 1)) calc(12px * var(--ipc-player-size-scale, 1));
66
+ z-index: 100;
67
+ .ipc-player-plugin-record-success-toast-image-box {
68
+ border-radius: calc(4px * var(--ipc-player-size-scale, 1));
69
+ overflow: hidden;
70
+ width: calc(66px * var(--ipc-player-size-scale, 1));
71
+ height: calc(66px * 0.57 * var(--ipc-player-size-scale, 1));
72
+ }
73
+ .ipc-player-plugin-record-success-toast-image {
74
+ width: 100%;
75
+ height: 100%;
76
+ object-fit: cover;
77
+ }
78
+ .ipc-player-plugin-record-success-toast-title {
79
+ flex: 1;
80
+ margin-left: calc(12px * var(--ipc-player-size-scale, 1));
81
+ font-size: calc(14px * var(--ipc-player-size-scale, 1));
82
+ color: var(--fontColor);
83
+ margin-right: calc(12px * var(--ipc-player-size-scale, 1));
84
+ word-break: break-word;
85
+
86
+ }
87
+ .ipc-player-plugin-record-success-toast-bottom {
88
+ border: 1px solid #1989FA;
89
+ min-width: calc(52px * var(--ipc-player-size-scale, 1));
90
+ max-width: calc(100px * var(--ipc-player-size-scale, 1));
91
+ border-radius: calc(4px * var(--ipc-player-size-scale, 1));
92
+ padding: calc(5px * var(--ipc-player-size-scale, 1)) calc(11px * var(--ipc-player-size-scale, 1));
93
+ font-size: calc(14px * var(--ipc-player-size-scale, 1));
94
+ white-space: nowrap;
95
+ overflow: hidden;
96
+ text-overflow: ellipsis;
97
+ }
41
98
  }
@@ -12,6 +12,7 @@ export const FullResolutionControl = props => {
12
12
  setResolution,
13
13
  setFullResolutionActive
14
14
  } = props;
15
+ console.log(props, 'props========');
15
16
  const {
16
17
  screenType,
17
18
  fullResolutionActive,
@@ -25,7 +26,6 @@ export const FullResolutionControl = props => {
25
26
  brandColor: props.brandColor,
26
27
  resolution: props.resolution
27
28
  });
28
- console.log(resolutionList, 'resolutionList');
29
29
  const [shouldHide] = useComponentHideState(screenType);
30
30
  const {
31
31
  event
@@ -52,5 +52,5 @@ export const FullResolutionControl = props => {
52
52
  style: item === resolution && {
53
53
  color: brandColor
54
54
  }
55
- }, I18n.t(`ipc_player_resolution_${item}`))));
55
+ }, Strings.getLang(`ipc_player_resolution_${item}`))));
56
56
  };
@@ -13,7 +13,9 @@ export const Resolution = props => {
13
13
  IPCPlayerContext,
14
14
  setResolution,
15
15
  addContent,
16
- setFullResolutionActive
16
+ deleteContent,
17
+ setFullResolutionActive,
18
+ className
17
19
  } = props;
18
20
  const {
19
21
  resolution,
@@ -29,6 +31,8 @@ export const Resolution = props => {
29
31
  return /*#__PURE__*/React.createElement(View, {
30
32
  onClick: () => {
31
33
  if (screenType === 'full') {
34
+ // 移除全屏清晰度空间
35
+ deleteContent('absolute', fullResolutionId);
32
36
  // 添加全屏清晰度空间
33
37
  addContent('absolute', {
34
38
  id: fullResolutionId,
@@ -45,8 +49,10 @@ export const Resolution = props => {
45
49
  setResolution(resolution === 'HD' ? 'SD' : 'HD');
46
50
  return true;
47
51
  },
48
- className: clsx('ipc-player-plugin-resolution', screenType === 'vertical' ? 'ipc-player-plugin-resolution-vertical' : 'ipc-player-plugin-resolution-full')
52
+ className: clsx(className, screenType === 'vertical' ? 'ipc-player-plugin-resolution-vertical' : 'ipc-player-plugin-resolution-full')
53
+ }, /*#__PURE__*/React.createElement(View, {
54
+ className: "ipc-player-plugin-resolution"
49
55
  }, /*#__PURE__*/React.createElement(Text, {
50
56
  className: "resolutionText"
51
- }, Strings.getLang(`ipc_player_resolution_${resolution}`)));
57
+ }, Strings.getLang(`ipc_player_resolution_${resolution}`))));
52
58
  };
@@ -1,15 +1,16 @@
1
1
  .ipc-player-plugin-resolution {
2
2
  background-color: rgba(255,255,255,0.2);
3
- padding: calc(2px * var(--ipc-player-size-scale, 1)) calc(4px * var(--ipc-player-size-scale, 1));
3
+ padding: calc(4px * var(--ipc-player-size-scale, 1)) calc(5px * var(--ipc-player-size-scale, 1)) !important;
4
4
  display: flex;
5
5
  justify-content: center;
6
6
  align-items: center;
7
7
  border-radius: calc(8px * var(--ipc-player-size-scale, 1));
8
- backdrop-filter: blur(8rpx);
8
+ background-color: rgba(255, 255, 255, 0.3);
9
+ box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
9
10
  .resolutionText {
10
11
  color: var(--iconColor);
11
12
  font-weight: 600;
12
- font-size: calc(12px * var(--ipc-player-size-scale, 1));
13
+ font-size: calc(14px * var(--ipc-player-size-scale, 1));
13
14
  }
14
15
  }
15
16
 
@@ -39,8 +40,7 @@
39
40
  justify-content: center;
40
41
  align-items: center;
41
42
  background-color: transparent;
42
- // transform: translate(200%, 0);
43
- z-index: 3;
43
+ z-index: 345;
44
44
  }
45
45
 
46
46
  .ipc-player-plugin-full-resolution-control-text {
@@ -1,6 +1,10 @@
1
1
  import React, { useRef } from 'react';
2
- import { View, Image } from '@ray-js/ray';
2
+ import { View, Image, Text } from '@ray-js/ray';
3
+ import { useSetState, useUpdateEffect } from 'ahooks';
4
+ import clsx from 'clsx';
3
5
  import IpcUtils from '@ray-js/ray-ipc-utils';
6
+ import Strings from '../../i18n';
7
+ import { useStore } from '../../ctx/store';
4
8
  import './screenshot.less';
5
9
  const CLOSE_TIME = 5000;
6
10
  export function Screenshot(props) {
@@ -10,58 +14,105 @@ export function Screenshot(props) {
10
14
  saveToAlbum,
11
15
  deleteContent,
12
16
  devId,
13
- toast
17
+ toast,
18
+ className
14
19
  } = props;
20
+ const {
21
+ screenType,
22
+ brandColor
23
+ } = useStore({
24
+ screenType: props.screenType,
25
+ brandColor: props.brandColor
26
+ });
27
+
28
+ /** 记录截屏url */
29
+ const [state, setState] = useSetState({
30
+ showShot: false,
31
+ shotUrl: ''
32
+ });
33
+ useUpdateEffect(() => {
34
+ if (state.showShot && screenType) {
35
+ showShotToast();
36
+ }
37
+ }, [state.showShot, screenType]);
15
38
  const timer = useRef();
16
39
  const timeToCloseToast = () => {
17
40
  clearInterval(timer.current);
18
41
  // @ts-ignore
19
42
  timer.current = setTimeout(() => {
43
+ setState({
44
+ showShot: false,
45
+ shotUrl: ''
46
+ });
20
47
  deleteContent('absolute', 'plugin-screenshot-toast');
21
48
  }, CLOSE_TIME);
22
49
  };
50
+
51
+ /** 跳转相册 */
23
52
  const handCheck = () => {
24
53
  IpcUtils.goToIpcPageNativeRoute('ipc_album_panel', devId);
25
54
  };
26
- const showToast = str => {
55
+
56
+ /** 添加截屏成功弹窗 */
57
+ const showShotToast = () => {
27
58
  deleteContent('absolute', 'plugin-screenshot-toast');
28
59
  addContent('absolute', {
29
60
  id: 'plugin-screenshot-toast',
30
- absoluteContentClassName: 'ipc-player-plugin-screenshot-toast-warp',
61
+ absoluteContentClassName: 'ipc-player-plugin-screenshot-toast-wrap',
62
+ absolutePosition: {
63
+ top: screenType === 'vertical' ? '12px' : '60px',
64
+ left: screenType === 'vertical' ? '16px' : '50%',
65
+ right: screenType === 'vertical' ? '16px' : 'unset',
66
+ display: 'flex',
67
+ width: screenType === 'vertical' ? 'auto' : '400px',
68
+ marginLeft: screenType === 'vertical' ? '0' : '-200px'
69
+ },
31
70
  content: () => {
32
71
  return /*#__PURE__*/React.createElement(View, {
33
72
  className: "ipc-player-plugin-screenshot-toast"
73
+ }, /*#__PURE__*/React.createElement(View, {
74
+ className: "ipc-player-plugin-screenshot-toast-image-box"
34
75
  }, /*#__PURE__*/React.createElement(Image, {
35
76
  className: "ipc-player-plugin-screenshot-toast-image",
36
- src: str
37
- }), /*#__PURE__*/React.createElement(View, {
77
+ src: state.shotUrl
78
+ })), /*#__PURE__*/React.createElement(View, {
38
79
  className: "ipc-player-plugin-screenshot-toast-title"
39
- }, I18n.t('screenshot_success_tip')), /*#__PURE__*/React.createElement(View, {
80
+ }, Strings.getLang('ipc_player_screenshot_success_tip')), /*#__PURE__*/React.createElement(View, {
40
81
  onClick: handCheck,
41
- className: "ipc-player-plugin-screenshot-toast-bottom"
42
- }, I18n.t('check')));
82
+ className: "ipc-player-plugin-screenshot-toast-bottom",
83
+ style: {
84
+ color: brandColor,
85
+ borderColor: brandColor
86
+ }
87
+ }, Strings.getLang('ipc_player_shot_success_check')));
43
88
  }
44
89
  });
45
90
  timeToCloseToast();
46
91
  };
47
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(View, {
92
+ return /*#__PURE__*/React.createElement(View, {
93
+ className: clsx(className),
48
94
  onClick: () => {
49
95
  console.log('截屏!!!');
50
96
  IPCPlayerContext.snapshot({
51
97
  saveToAlbum,
52
98
  // 保存到 IPC 相册
53
99
  success: res => {
54
- showToast(res.tempImagePath);
100
+ console.log(res, 'res');
101
+ setState({
102
+ showShot: true,
103
+ shotUrl: res.tempImagePath
104
+ });
55
105
  },
56
106
  fail: err => {
57
107
  const errObj = err.innerError || err || {};
58
- const errMsg = errObj.errorMsg || I18n.t('error_screenshot');
108
+ const errMsg = errObj.errorMsg || Strings.getLang('ipc_player_error_screenshot_error_tip');
59
109
  toast({
60
110
  title: errMsg
61
111
  });
62
112
  }
63
113
  });
64
- },
65
- className: "icon-panel icon-panel-screenshot ipc-player-plugin-screenshot-icon"
114
+ }
115
+ }, /*#__PURE__*/React.createElement(Text, {
116
+ className: clsx('icon-panel', 'icon-panel-screenshot', 'ipc-player-plugin-screenshot-icon')
66
117
  }));
67
118
  }
@@ -1,45 +1,47 @@
1
1
  .ipc-player-plugin-screenshot-icon {
2
2
  color: var(--iconColor);
3
- font-size: calc(var(--iconFontSize) * var(--ipc-player-size-scale, 1));
3
+ font-size: calc(var(--iconPlayerSize) * var(--ipc-player-size-scale, 1)) !important;
4
4
  }
5
- .ipc-player-plugin-screenshot-toast-warp {
5
+ .ipc-player-plugin-screenshot-toast-wrap {
6
6
  position: absolute;
7
- width: 90%;
8
- max-width: 750rpx;
9
- left: 50%;
10
- transform: translateX(-50%);
11
- top: calc(16px * var(--ipc-player-size-scale, 1));
12
7
  }
13
8
  .ipc-player-plugin-screenshot-toast {
9
+ flex: 1;
14
10
  border-radius: calc(8px * var(--ipc-player-size-scale, 1));;
15
- background-color: var(--bg-color);
11
+ background-color: var(--shot-card-bg-color);
16
12
  display: flex;
17
13
  align-items: center;
18
- padding: calc(8px * var(--ipc-player-size-scale, 1)) calc(16px * var(--ipc-player-size-scale, 1));
19
- z-index: 3;
20
- .ipc-player-plugin-screenshot-toast-image {
21
- width: calc(66px * var(--ipc-player-size-scale, 1));
22
- height: calc(37px * var(--ipc-player-size-scale, 1));
14
+ padding: calc(8px * var(--ipc-player-size-scale, 1)) calc(12px * var(--ipc-player-size-scale, 1));
15
+ z-index: 100;
16
+ .ipc-player-plugin-screenshot-toast-image-box {
23
17
  border-radius: calc(4px * var(--ipc-player-size-scale, 1));
18
+ overflow: hidden;
19
+ width: calc(66px * var(--ipc-player-size-scale, 1));
20
+ height: calc(66px * 0.57 * var(--ipc-player-size-scale, 1));
21
+ }
22
+ .ipc-player-plugin-screenshot-toast-image {
23
+ width: 100%;
24
+ height: 100%;
25
+ object-fit: cover;
24
26
  }
25
27
  .ipc-player-plugin-screenshot-toast-title {
28
+ flex: 1;
26
29
  margin-left: calc(12px * var(--ipc-player-size-scale, 1));
27
30
  font-size: calc(14px * var(--ipc-player-size-scale, 1));
28
31
  color: var(--fontColor);
29
- line-height: calc(20px * var(--ipc-player-size-scale, 1));
30
- max-width: 60%;
32
+ margin-right: calc(12px * var(--ipc-player-size-scale, 1));
33
+ word-break: break-word;
34
+
31
35
  }
32
36
  .ipc-player-plugin-screenshot-toast-bottom {
33
- position: absolute;
34
- // right: 32rpx;
35
- right: calc(16px * var(--ipc-player-size-scale, 1));
36
- border: 1rpx solid #1989FA;
37
- // border-radius: 8rpx;
37
+ border: 1px solid #1989FA;
38
+ min-width: calc(52px * var(--ipc-player-size-scale, 1));
39
+ max-width: calc(100px * var(--ipc-player-size-scale, 1));
38
40
  border-radius: calc(4px * var(--ipc-player-size-scale, 1));
39
- // padding: 10rpx 22rpx;
40
41
  padding: calc(5px * var(--ipc-player-size-scale, 1)) calc(11px * var(--ipc-player-size-scale, 1));
41
- color: #1989FA;
42
- // font-size: 28rpx;
43
42
  font-size: calc(14px * var(--ipc-player-size-scale, 1));
43
+ white-space: nowrap;
44
+ overflow: hidden;
45
+ text-overflow: ellipsis;
44
46
  }
45
47
  }
@@ -0,0 +1 @@
1
+ export * from './smallIntercom';
@@ -0,0 +1 @@
1
+ export * from './smallIntercom';
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import { ComponentConfigProps } from '../../interface';
3
+ import './smallIntercom.less';
4
+ type Props = ComponentConfigProps;
5
+ export declare function SmallIntercom(props: Props): React.JSX.Element | null;
6
+ export {};
@@ -0,0 +1,49 @@
1
+ import React from 'react';
2
+ import { View, Text } from '@ray-js/ray';
3
+ import clsx from 'clsx';
4
+ import { useStore } from '../../ctx/store';
5
+ import './smallIntercom.less';
6
+ export function SmallIntercom(props) {
7
+ const {
8
+ IPCPlayerContext,
9
+ addContent,
10
+ saveToAlbum,
11
+ deleteContent,
12
+ devId,
13
+ toast,
14
+ className
15
+ } = props;
16
+ const {
17
+ screenType,
18
+ ptzActive
19
+ } = useStore({
20
+ screenType: props.screenType,
21
+ ptzActive: props.ptzActive
22
+ });
23
+ const handClick = () => {
24
+ console.log('截屏!!!');
25
+ // IPCPlayerContext.snapshot({
26
+ // saveToAlbum, // 保存到 IPC 相册
27
+ // success: res => {
28
+ // showToast(res.tempImagePath);
29
+ // },
30
+ // fail: err => {
31
+ // const errObj = err.innerError || err || {};
32
+ // const errMsg = errObj.errorMsg || I18n.t('error_screenshot');
33
+ // toast({ title: errMsg });
34
+ // },
35
+ // });
36
+ };
37
+ if (screenType === 'vertical' && !ptzActive) {
38
+ return null;
39
+ }
40
+ if (screenType === 'full' && ptzActive) {
41
+ return /*#__PURE__*/React.createElement(View, {
42
+ className: clsx(className),
43
+ onClick: handClick
44
+ }, /*#__PURE__*/React.createElement(Text, {
45
+ className: clsx('icon-panel', 'icon-panel-one-way-intercom', 'ipc-player-plugin-small-intercom-icon')
46
+ }));
47
+ }
48
+ return null;
49
+ }