@ray-js/ipc-player-integration 0.0.55 → 0.0.56-beta.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/lib/ctx/ctx.album.test.d.ts +1 -0
- package/lib/ctx/ctx.album.test.js +197 -0
- package/lib/ctx/ctx.composition.js +13 -3
- package/lib/ctx/ctx.js +43 -35
- package/lib/i18n/index.d.ts +12 -0
- package/lib/i18n/strings.d.ts +6 -0
- package/lib/i18n/strings.js +6 -0
- package/lib/interface.d.ts +16 -3
- package/lib/ui/absoluteContent.d.ts +2 -0
- package/lib/ui/absoluteContent.js +3 -0
- package/lib/ui/ui.js +26 -22
- package/lib/utils/captureResult.d.ts +14 -0
- package/lib/utils/captureResult.js +70 -0
- package/lib/utils/captureResult.test.d.ts +1 -0
- package/lib/utils/captureResult.test.js +117 -0
- package/lib/widgets/captureResult/captureResult.d.ts +16 -0
- package/lib/widgets/captureResult/captureResult.js +85 -0
- package/lib/widgets/captureResult/captureResult.less +144 -0
- package/lib/widgets/captureResult/captureResult.test.d.ts +1 -0
- package/lib/widgets/captureResult/captureResult.test.js +80 -0
- package/lib/widgets/captureResult/index.d.ts +2 -0
- package/lib/widgets/captureResult/index.js +2 -0
- package/lib/widgets/index.d.ts +1 -0
- package/lib/widgets/index.js +2 -1
- package/lib/widgets/muted/muted.js +12 -3
- package/lib/widgets/muted/muted.less +5 -1
- package/lib/widgets/muted/muted.test.d.ts +1 -0
- package/lib/widgets/muted/muted.test.js +78 -0
- package/lib/widgets/recordVideo/recordVideo.js +50 -35
- package/lib/widgets/recordVideo/recordVideo.less +17 -74
- package/lib/widgets/recordVideo/recordVideo.test.js +1 -0
- package/lib/widgets/screenshot/screenshot.js +66 -44
- package/lib/widgets/screenshot/screenshot.less +1 -40
- package/lib/widgets/screenshot/screenshot.test.d.ts +1 -0
- package/lib/widgets/screenshot/screenshot.test.js +120 -0
- package/package.json +2 -2
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import React, { useState, useEffect, useRef, useContext } from 'react';
|
|
2
|
-
import { View, Text,
|
|
2
|
+
import { View, Text, getSystemInfoSync } from '@ray-js/ray';
|
|
3
3
|
import { useSetState, useUpdateEffect } from 'ahooks';
|
|
4
4
|
import clsx from 'clsx';
|
|
5
5
|
import { goToIpcPageNativeRoute } from '@ray-js/ray-ipc-utils';
|
|
6
6
|
import Strings from '../../i18n';
|
|
7
7
|
import { PlayState } from '../../interface';
|
|
8
|
+
import { getCaptureResultSummary } from '../../utils/captureResult';
|
|
9
|
+
import { CaptureResultToast } from '../captureResult/captureResult';
|
|
8
10
|
import { UIEventContext } from '../../ui/context';
|
|
9
11
|
import { pauseTimeToHideAllComponent, changeIgnoreHideStopPreview, widgetLabs, widgetClick } from '../../ui/constant';
|
|
10
12
|
import { useStore, getDefaultStore } from '../../ctx/store';
|
|
@@ -102,20 +104,48 @@ export function RecordVideo(props) {
|
|
|
102
104
|
const [state, setState] = useSetState({
|
|
103
105
|
showTimer: false,
|
|
104
106
|
showShot: false,
|
|
105
|
-
shotUrl: ''
|
|
107
|
+
shotUrl: '',
|
|
108
|
+
shotCount: 0
|
|
106
109
|
});
|
|
110
|
+
const recordResultRequestIdRef = useRef(0);
|
|
111
|
+
useEffect(() => {
|
|
112
|
+
return () => {
|
|
113
|
+
recordResultRequestIdRef.current += 1;
|
|
114
|
+
};
|
|
115
|
+
}, []);
|
|
116
|
+
const showRecordResult = async recordInfo => {
|
|
117
|
+
var _props$multiCameraCtx;
|
|
118
|
+
const requestId = ++recordResultRequestIdRef.current;
|
|
119
|
+
const splitNum = (_props$multiCameraCtx = props.multiCameraCtx) === null || _props$multiCameraCtx === void 0 || (_props$multiCameraCtx = _props$multiCameraCtx.protocol) === null || _props$multiCameraCtx === void 0 ? void 0 : _props$multiCameraCtx.total_split_num;
|
|
120
|
+
const summary = await getCaptureResultSummary(recordInfo, {
|
|
121
|
+
multiLens: props.multiLens,
|
|
122
|
+
protocolCount: splitNum,
|
|
123
|
+
devId
|
|
124
|
+
});
|
|
125
|
+
if (requestId !== recordResultRequestIdRef.current) return;
|
|
126
|
+
if (!summary) return;
|
|
127
|
+
setState({
|
|
128
|
+
showTimer: false,
|
|
129
|
+
showShot: true,
|
|
130
|
+
shotUrl: summary.thumbnailPath,
|
|
131
|
+
shotCount: summary.isMultiLens ? summary.count : 0
|
|
132
|
+
});
|
|
133
|
+
};
|
|
107
134
|
|
|
108
135
|
/**
|
|
109
136
|
* 针对 playState为非连接中状态时,如果处于录制中, 结束录制
|
|
110
137
|
*/
|
|
111
138
|
useEffect(() => {
|
|
112
139
|
(async () => {
|
|
113
|
-
if (playState !== PlayState.PLAYING) {
|
|
114
|
-
|
|
140
|
+
if (playState !== PlayState.PLAYING && recording) {
|
|
141
|
+
try {
|
|
115
142
|
setState({
|
|
116
143
|
showTimer: false
|
|
117
144
|
});
|
|
118
|
-
await setRecording(false);
|
|
145
|
+
const recordInfo = await setRecording(false);
|
|
146
|
+
await showRecordResult(recordInfo);
|
|
147
|
+
} catch {
|
|
148
|
+
// setRecording reports the native failure through the configured toast.
|
|
119
149
|
}
|
|
120
150
|
}
|
|
121
151
|
})();
|
|
@@ -129,7 +159,8 @@ export function RecordVideo(props) {
|
|
|
129
159
|
timer.current = setTimeout(() => {
|
|
130
160
|
setState({
|
|
131
161
|
showShot: false,
|
|
132
|
-
shotUrl: ''
|
|
162
|
+
shotUrl: '',
|
|
163
|
+
shotCount: 0
|
|
133
164
|
});
|
|
134
165
|
deleteContent('absolute', RECORD_VIDEO_SUCCESS_TOAST_ID);
|
|
135
166
|
}, CLOSE_TIME);
|
|
@@ -164,7 +195,8 @@ export function RecordVideo(props) {
|
|
|
164
195
|
const handCheck = () => {
|
|
165
196
|
setState({
|
|
166
197
|
showShot: false,
|
|
167
|
-
shotUrl: ''
|
|
198
|
+
shotUrl: '',
|
|
199
|
+
shotCount: 0
|
|
168
200
|
});
|
|
169
201
|
deleteContent('absolute', RECORD_VIDEO_SUCCESS_TOAST_ID);
|
|
170
202
|
clearInterval(timer.current);
|
|
@@ -186,27 +218,13 @@ export function RecordVideo(props) {
|
|
|
186
218
|
marginLeft: screenType === 'vertical' ? '0' : '-200px'
|
|
187
219
|
},
|
|
188
220
|
content: () => {
|
|
189
|
-
return /*#__PURE__*/React.createElement(
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
}), /*#__PURE__*/React.createElement(View, {
|
|
197
|
-
className: "ipc-player-plugin-record-success-play-icon-box"
|
|
198
|
-
}, /*#__PURE__*/React.createElement(Text, {
|
|
199
|
-
className: clsx('icon-panel', 'icon-panel-record-play', 'ipc-player-plugin-record-success-play-icon')
|
|
200
|
-
}))), /*#__PURE__*/React.createElement(View, {
|
|
201
|
-
className: "ipc-player-plugin-record-success-toast-title"
|
|
202
|
-
}, Strings.getLang('ipc_player_record_success_tip')), /*#__PURE__*/React.createElement(View, {
|
|
203
|
-
onClick: handCheck,
|
|
204
|
-
className: "ipc-player-plugin-record-success-toast-bottom",
|
|
205
|
-
style: {
|
|
206
|
-
color: brandColor,
|
|
207
|
-
borderColor: brandColor
|
|
208
|
-
}
|
|
209
|
-
}, Strings.getLang('ipc_player_record_success_check')));
|
|
221
|
+
return /*#__PURE__*/React.createElement(CaptureResultToast, {
|
|
222
|
+
brandColor: brandColor,
|
|
223
|
+
count: state.shotCount,
|
|
224
|
+
kind: "record",
|
|
225
|
+
onCheck: handCheck,
|
|
226
|
+
thumbnailPath: state.shotUrl
|
|
227
|
+
});
|
|
210
228
|
}
|
|
211
229
|
});
|
|
212
230
|
timeToCloseRecordToast();
|
|
@@ -230,9 +248,9 @@ export function RecordVideo(props) {
|
|
|
230
248
|
});
|
|
231
249
|
};
|
|
232
250
|
const handRecordVideo = async () => {
|
|
233
|
-
var _props$event
|
|
251
|
+
var _props$event;
|
|
234
252
|
const ev = (_props$event = props.event) !== null && _props$event !== void 0 ? _props$event : event;
|
|
235
|
-
|
|
253
|
+
ev.emit(widgetClick, {
|
|
236
254
|
widgetId: widgetLabs.RECORD_VIDEO
|
|
237
255
|
});
|
|
238
256
|
event.emit(pauseTimeToHideAllComponent);
|
|
@@ -242,6 +260,7 @@ export function RecordVideo(props) {
|
|
|
242
260
|
if (recordingDisabled) {
|
|
243
261
|
return false;
|
|
244
262
|
}
|
|
263
|
+
recordResultRequestIdRef.current += 1;
|
|
245
264
|
if (state.showShot && _recording) {
|
|
246
265
|
setState({
|
|
247
266
|
showShot: false
|
|
@@ -269,11 +288,7 @@ export function RecordVideo(props) {
|
|
|
269
288
|
timeToResetRecordDisabled();
|
|
270
289
|
} else {
|
|
271
290
|
props.event ? props.event.emit(changeIgnoreHideStopPreview, false) : event.emit(changeIgnoreHideStopPreview, false);
|
|
272
|
-
|
|
273
|
-
showTimer: false,
|
|
274
|
-
showShot: true,
|
|
275
|
-
shotUrl: recordInfo.tempImagePath
|
|
276
|
-
});
|
|
291
|
+
await showRecordResult(recordInfo);
|
|
277
292
|
}
|
|
278
293
|
} catch (err) {
|
|
279
294
|
props.event ? props.event.emit(changeIgnoreHideStopPreview, false) : event.emit(changeIgnoreHideStopPreview, false);
|
|
@@ -1,116 +1,59 @@
|
|
|
1
1
|
.ipc-player-plugin-record-video-icon {
|
|
2
|
-
font-size: calc(var(--iconPlayerSize) * var(--ipc-player-size-scale, 1)) !important;
|
|
3
2
|
color: var(--iconColor);
|
|
3
|
+
font-size: calc(var(--iconPlayerSize) * var(--ipc-player-size-scale, 1)) !important;
|
|
4
4
|
}
|
|
5
|
+
|
|
5
6
|
.ipc-player-plugin-record-video-toast-wrap {
|
|
6
|
-
z-index: 400;
|
|
7
7
|
position: absolute;
|
|
8
8
|
top: calc(7px * var(--ipc-player-size-scale, 1));
|
|
9
9
|
left: 50%;
|
|
10
|
+
z-index: 400;
|
|
10
11
|
transform: translateX(-50%);
|
|
11
12
|
}
|
|
12
13
|
|
|
13
|
-
// 计时器显示
|
|
14
14
|
.ipc-player-plugin-record-video-toast-show {
|
|
15
15
|
transform: translate(0, 0) !important;
|
|
16
16
|
transition: transform ease-in 3s;
|
|
17
17
|
}
|
|
18
|
-
|
|
18
|
+
|
|
19
19
|
.ipc-player-plugin-record-video-toast-hide {
|
|
20
20
|
transform: translate(0, -110%) !important;
|
|
21
21
|
transition: transform 0.3s ease-in-out;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
.ipc-player-plugin-record-video-toast {
|
|
25
|
-
transform: translate(0, -110%);
|
|
26
25
|
display: flex;
|
|
27
|
-
padding: calc(12px * var(--ipc-player-size-scale, 1));
|
|
28
26
|
align-items: center;
|
|
29
|
-
|
|
27
|
+
padding: calc(12px * var(--ipc-player-size-scale, 1));
|
|
28
|
+
background: linear-gradient(0deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.15)),
|
|
29
|
+
#000000;
|
|
30
30
|
border-radius: calc(8px * var(--ipc-player-size-scale, 1));
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
transform: translate(0, -110%);
|
|
32
|
+
|
|
33
33
|
.ipc-player-plugin-record-video-toast-point {
|
|
34
34
|
width: calc(6px * var(--ipc-player-size-scale, 1));
|
|
35
35
|
height: calc(6px * var(--ipc-player-size-scale, 1));
|
|
36
36
|
border-radius: calc(6px * var(--ipc-player-size-scale, 1));
|
|
37
37
|
}
|
|
38
|
+
|
|
38
39
|
.ipc-player-plugin-record-video-toast-time {
|
|
39
|
-
font-size: calc(12px * var(--ipc-player-size-scale, 1));;
|
|
40
|
-
font-weight: 700;
|
|
41
|
-
color: var(--fontColor);
|
|
42
|
-
margin-left: calc(8px * var(--ipc-player-size-scale, 1));;
|
|
43
40
|
display: flex;
|
|
44
41
|
align-items: center;
|
|
42
|
+
margin-left: calc(8px * var(--ipc-player-size-scale, 1));
|
|
43
|
+
color: var(--fontColor);
|
|
44
|
+
font-weight: 700;
|
|
45
|
+
font-size: calc(12px * var(--ipc-player-size-scale, 1));
|
|
46
|
+
|
|
45
47
|
.ipc-player-plugin-record-video-toast-time-warp {
|
|
46
48
|
text-align: center;
|
|
47
49
|
}
|
|
50
|
+
|
|
48
51
|
.ipc-player-plugin-record-video-toast-time-delimiter {
|
|
49
|
-
margin: 0 calc(2px * var(--ipc-player-size-scale, 1))
|
|
52
|
+
margin: 0 calc(2px * var(--ipc-player-size-scale, 1));
|
|
50
53
|
}
|
|
51
54
|
}
|
|
52
55
|
}
|
|
53
56
|
|
|
54
|
-
/** 录制成功弹窗 */
|
|
55
57
|
.ipc-player-plugin-record-success-toast-wrap {
|
|
56
58
|
position: absolute;
|
|
57
59
|
}
|
|
58
|
-
.ipc-player-plugin-record-success-toast {
|
|
59
|
-
flex: 1;
|
|
60
|
-
border-radius: calc(8px * var(--ipc-player-size-scale, 1));;
|
|
61
|
-
background-color: var(--shot-card-bg-color);
|
|
62
|
-
display: flex;
|
|
63
|
-
align-items: center;
|
|
64
|
-
padding: calc(8px * var(--ipc-player-size-scale, 1)) calc(12px * var(--ipc-player-size-scale, 1));
|
|
65
|
-
z-index: 100;
|
|
66
|
-
.ipc-player-plugin-record-success-toast-image-box {
|
|
67
|
-
border-radius: calc(4px * var(--ipc-player-size-scale, 1));
|
|
68
|
-
overflow: hidden;
|
|
69
|
-
width: calc(66px * var(--ipc-player-size-scale, 1));
|
|
70
|
-
height: calc(66px * 0.57 * var(--ipc-player-size-scale, 1));
|
|
71
|
-
position: relative;
|
|
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-play-icon-box {
|
|
79
|
-
width: 30px;
|
|
80
|
-
height: 30px;
|
|
81
|
-
background-color: rgba(0, 0, 0, 0.2);
|
|
82
|
-
border-radius: 50%;
|
|
83
|
-
overflow: hidden;
|
|
84
|
-
position: absolute;
|
|
85
|
-
top: 50%;
|
|
86
|
-
left: 50%;
|
|
87
|
-
transform: translate(-50%, -50%);
|
|
88
|
-
display: flex;
|
|
89
|
-
align-items: center;
|
|
90
|
-
justify-content: center;
|
|
91
|
-
}
|
|
92
|
-
.ipc-player-plugin-record-success-play-icon {
|
|
93
|
-
font-size: calc(18px * var(--ipc-player-size-scale, 1)) !important;
|
|
94
|
-
color: #ffffff;
|
|
95
|
-
}
|
|
96
|
-
.ipc-player-plugin-record-success-toast-title {
|
|
97
|
-
flex: 1;
|
|
98
|
-
margin-left: calc(12px * var(--ipc-player-size-scale, 1));
|
|
99
|
-
font-size: calc(14px * var(--ipc-player-size-scale, 1));
|
|
100
|
-
color: var(--fontColor);
|
|
101
|
-
margin-right: calc(12px * var(--ipc-player-size-scale, 1));
|
|
102
|
-
word-break: break-word;
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
.ipc-player-plugin-record-success-toast-bottom {
|
|
106
|
-
border: 1px solid #1989FA;
|
|
107
|
-
min-width: calc(52px * var(--ipc-player-size-scale, 1));
|
|
108
|
-
max-width: calc(100px * var(--ipc-player-size-scale, 1));
|
|
109
|
-
border-radius: calc(4px * var(--ipc-player-size-scale, 1));
|
|
110
|
-
padding: calc(5px * var(--ipc-player-size-scale, 1)) calc(11px * var(--ipc-player-size-scale, 1));
|
|
111
|
-
font-size: calc(14px * var(--ipc-player-size-scale, 1));
|
|
112
|
-
white-space: nowrap;
|
|
113
|
-
overflow: hidden;
|
|
114
|
-
text-overflow: ellipsis;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
@@ -22,6 +22,7 @@ jest.mock('../../i18n', () => ({
|
|
|
22
22
|
}
|
|
23
23
|
}));
|
|
24
24
|
jest.mock('./recordVideo.less', () => ({}));
|
|
25
|
+
jest.mock('../captureResult/captureResult.less', () => ({}));
|
|
25
26
|
it('keeps the record control idle when starting is declined', async () => {
|
|
26
27
|
const addContent = jest.fn();
|
|
27
28
|
const setRecordingDisabled = jest.fn();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React, { useContext, useRef } from 'react';
|
|
2
|
-
import { View,
|
|
1
|
+
import React, { useContext, useEffect, useRef } from 'react';
|
|
2
|
+
import { View, Text, getSystemInfoSync } from '@ray-js/ray';
|
|
3
3
|
import { useSetState, useUpdateEffect, useMemoizedFn } from 'ahooks';
|
|
4
4
|
import clsx from 'clsx';
|
|
5
5
|
import { goToIpcPageNativeRoute } from '@ray-js/ray-ipc-utils';
|
|
@@ -7,7 +7,9 @@ import Strings from '../../i18n';
|
|
|
7
7
|
import { useStore } from '../../ctx/store';
|
|
8
8
|
import { UIEventContext } from '../../ui/context';
|
|
9
9
|
import { pauseTimeToHideAllComponent, changeIgnoreHideStopPreview, widgetLabs, widgetClick } from '../../ui/constant';
|
|
10
|
+
import { getCaptureResultSummary } from '../../utils/captureResult';
|
|
10
11
|
import { ensureAlbumPermission } from '../../utils/authorize/album';
|
|
12
|
+
import { CaptureResultToast } from '../captureResult/captureResult';
|
|
11
13
|
import './screenshot.less';
|
|
12
14
|
const CLOSE_TIME = 5000;
|
|
13
15
|
export function Screenshot(props) {
|
|
@@ -35,8 +37,15 @@ export function Screenshot(props) {
|
|
|
35
37
|
/** 记录截屏url */
|
|
36
38
|
const [state, setState] = useSetState({
|
|
37
39
|
showShot: false,
|
|
38
|
-
shotUrl: ''
|
|
40
|
+
shotUrl: '',
|
|
41
|
+
shotCount: 0
|
|
39
42
|
});
|
|
43
|
+
const snapshotRequestIdRef = useRef(0);
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
return () => {
|
|
46
|
+
snapshotRequestIdRef.current += 1;
|
|
47
|
+
};
|
|
48
|
+
}, []);
|
|
40
49
|
useUpdateEffect(() => {
|
|
41
50
|
if (state.showShot && screenType) {
|
|
42
51
|
showShotToast();
|
|
@@ -49,7 +58,8 @@ export function Screenshot(props) {
|
|
|
49
58
|
timer.current = setTimeout(() => {
|
|
50
59
|
setState({
|
|
51
60
|
showShot: false,
|
|
52
|
-
shotUrl: ''
|
|
61
|
+
shotUrl: '',
|
|
62
|
+
shotCount: 0
|
|
53
63
|
});
|
|
54
64
|
deleteContent('absolute', 'plugin-screenshot-toast');
|
|
55
65
|
}, CLOSE_TIME);
|
|
@@ -59,7 +69,8 @@ export function Screenshot(props) {
|
|
|
59
69
|
const handCheck = () => {
|
|
60
70
|
setState({
|
|
61
71
|
showShot: false,
|
|
62
|
-
shotUrl: ''
|
|
72
|
+
shotUrl: '',
|
|
73
|
+
shotCount: 0
|
|
63
74
|
});
|
|
64
75
|
deleteContent('absolute', 'plugin-screenshot-toast');
|
|
65
76
|
clearInterval(timer.current);
|
|
@@ -81,31 +92,20 @@ export function Screenshot(props) {
|
|
|
81
92
|
marginLeft: screenType === 'vertical' ? '0' : '-200px'
|
|
82
93
|
},
|
|
83
94
|
content: () => {
|
|
84
|
-
return /*#__PURE__*/React.createElement(
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
})), /*#__PURE__*/React.createElement(View, {
|
|
92
|
-
className: "ipc-player-plugin-screenshot-toast-title"
|
|
93
|
-
}, Strings.getLang('ipc_player_screenshot_success_tip')), /*#__PURE__*/React.createElement(View, {
|
|
94
|
-
onClick: handCheck,
|
|
95
|
-
className: "ipc-player-plugin-screenshot-toast-bottom",
|
|
96
|
-
style: {
|
|
97
|
-
color: brandColor,
|
|
98
|
-
borderColor: brandColor
|
|
99
|
-
}
|
|
100
|
-
}, Strings.getLang('ipc_player_shot_success_check')));
|
|
95
|
+
return /*#__PURE__*/React.createElement(CaptureResultToast, {
|
|
96
|
+
brandColor: brandColor,
|
|
97
|
+
count: state.shotCount,
|
|
98
|
+
kind: "screenshot",
|
|
99
|
+
onCheck: handCheck,
|
|
100
|
+
thumbnailPath: state.shotUrl
|
|
101
|
+
});
|
|
101
102
|
}
|
|
102
103
|
});
|
|
103
104
|
timeToCloseToast();
|
|
104
105
|
};
|
|
105
106
|
const handClick = useMemoizedFn(async () => {
|
|
106
|
-
var _props$event
|
|
107
|
-
|
|
108
|
-
((_props$event2 = props.event) !== null && _props$event2 !== void 0 ? _props$event2 : event).emit(widgetClick, {
|
|
107
|
+
var _props$event;
|
|
108
|
+
((_props$event = props.event) !== null && _props$event !== void 0 ? _props$event : event).emit(widgetClick, {
|
|
109
109
|
widgetId: widgetLabs.SCREENSHOT
|
|
110
110
|
});
|
|
111
111
|
console.log('截屏!!!');
|
|
@@ -119,27 +119,49 @@ export function Screenshot(props) {
|
|
|
119
119
|
props.event ? props.event.emit(changeIgnoreHideStopPreview, true) : event.emit(changeIgnoreHideStopPreview, true);
|
|
120
120
|
}
|
|
121
121
|
event.emit(pauseTimeToHideAllComponent);
|
|
122
|
+
const setIgnoreHideStopPreview = value => {
|
|
123
|
+
var _props$event2;
|
|
124
|
+
((_props$event2 = props.event) !== null && _props$event2 !== void 0 ? _props$event2 : event).emit(changeIgnoreHideStopPreview, value);
|
|
125
|
+
};
|
|
126
|
+
const handleSnapshotFail = err => {
|
|
127
|
+
setIgnoreHideStopPreview(false);
|
|
128
|
+
console.log(err, 'err');
|
|
129
|
+
const errObj = err.innerError || err || {};
|
|
130
|
+
const errMsg = errObj.errorMsg || Strings.getLang('ipc_player_error_screenshot_error_tip');
|
|
131
|
+
toast({
|
|
132
|
+
title: errMsg
|
|
133
|
+
});
|
|
134
|
+
};
|
|
122
135
|
const granted = await ensureAlbumPermission();
|
|
123
|
-
|
|
136
|
+
setIgnoreHideStopPreview(false);
|
|
124
137
|
if (!granted) return;
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
138
|
+
(() => {
|
|
139
|
+
const requestId = ++snapshotRequestIdRef.current;
|
|
140
|
+
IPCPlayerContext.snapshot({
|
|
141
|
+
saveToAlbum,
|
|
142
|
+
success: async res => {
|
|
143
|
+
var _props$multiCameraCtx;
|
|
144
|
+
setIgnoreHideStopPreview(false);
|
|
145
|
+
const splitNum = (_props$multiCameraCtx = props.multiCameraCtx) === null || _props$multiCameraCtx === void 0 || (_props$multiCameraCtx = _props$multiCameraCtx.protocol) === null || _props$multiCameraCtx === void 0 ? void 0 : _props$multiCameraCtx.total_split_num;
|
|
146
|
+
const summary = await getCaptureResultSummary(res, {
|
|
147
|
+
multiLens: props.multiLens,
|
|
148
|
+
protocolCount: splitNum,
|
|
149
|
+
devId
|
|
150
|
+
});
|
|
151
|
+
if (requestId !== snapshotRequestIdRef.current) return;
|
|
152
|
+
if (!summary) {
|
|
153
|
+
handleSnapshotFail({});
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
setState({
|
|
157
|
+
showShot: true,
|
|
158
|
+
shotUrl: summary.thumbnailPath,
|
|
159
|
+
shotCount: summary.isMultiLens ? summary.count : 0
|
|
160
|
+
});
|
|
161
|
+
},
|
|
162
|
+
fail: handleSnapshotFail
|
|
163
|
+
});
|
|
164
|
+
})();
|
|
143
165
|
});
|
|
144
166
|
if (hideScreenShotMenu) return null;
|
|
145
167
|
return /*#__PURE__*/React.createElement(View, {
|
|
@@ -2,46 +2,7 @@
|
|
|
2
2
|
color: var(--iconColor);
|
|
3
3
|
font-size: calc(var(--iconPlayerSize) * var(--ipc-player-size-scale, 1)) !important;
|
|
4
4
|
}
|
|
5
|
+
|
|
5
6
|
.ipc-player-plugin-screenshot-toast-wrap {
|
|
6
7
|
position: absolute;
|
|
7
8
|
}
|
|
8
|
-
.ipc-player-plugin-screenshot-toast {
|
|
9
|
-
flex: 1;
|
|
10
|
-
border-radius: calc(8px * var(--ipc-player-size-scale, 1));;
|
|
11
|
-
background-color: var(--shot-card-bg-color);
|
|
12
|
-
display: flex;
|
|
13
|
-
align-items: center;
|
|
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 {
|
|
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;
|
|
26
|
-
}
|
|
27
|
-
.ipc-player-plugin-screenshot-toast-title {
|
|
28
|
-
flex: 1;
|
|
29
|
-
margin-left: calc(12px * var(--ipc-player-size-scale, 1));
|
|
30
|
-
font-size: calc(14px * var(--ipc-player-size-scale, 1));
|
|
31
|
-
color: var(--fontColor);
|
|
32
|
-
margin-right: calc(12px * var(--ipc-player-size-scale, 1));
|
|
33
|
-
word-break: break-word;
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
.ipc-player-plugin-screenshot-toast-bottom {
|
|
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));
|
|
40
|
-
border-radius: calc(4px * var(--ipc-player-size-scale, 1));
|
|
41
|
-
padding: calc(5px * var(--ipc-player-size-scale, 1)) calc(11px * var(--ipc-player-size-scale, 1));
|
|
42
|
-
font-size: calc(14px * var(--ipc-player-size-scale, 1));
|
|
43
|
-
white-space: nowrap;
|
|
44
|
-
overflow: hidden;
|
|
45
|
-
text-overflow: ellipsis;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { act, renderHook } from '@testing-library/react-hooks/dom';
|
|
2
|
+
import { atom } from 'jotai';
|
|
3
|
+
import { authorize, authorizeStatus, getSystemInfoSync, showModal } from '@ray-js/ray';
|
|
4
|
+
import { getDeviceInfo } from '../../utils/device';
|
|
5
|
+
import { Screenshot } from './screenshot';
|
|
6
|
+
jest.mock('@ray-js/ray', () => ({
|
|
7
|
+
View: 'div',
|
|
8
|
+
Text: 'span',
|
|
9
|
+
Image: 'img',
|
|
10
|
+
getSystemInfoSync: jest.fn(),
|
|
11
|
+
authorize: jest.fn(),
|
|
12
|
+
authorizeStatus: jest.fn(),
|
|
13
|
+
showModal: jest.fn(),
|
|
14
|
+
openAppSystemSettingPage: jest.fn()
|
|
15
|
+
}));
|
|
16
|
+
jest.mock('@ray-js/ray-ipc-utils', () => ({
|
|
17
|
+
goToIpcPageNativeRoute: jest.fn()
|
|
18
|
+
}));
|
|
19
|
+
jest.mock('../../utils/device', () => ({
|
|
20
|
+
getDeviceInfo: jest.fn()
|
|
21
|
+
}));
|
|
22
|
+
jest.mock('../../i18n', () => ({
|
|
23
|
+
__esModule: true,
|
|
24
|
+
default: {
|
|
25
|
+
getLang: key => key
|
|
26
|
+
}
|
|
27
|
+
}));
|
|
28
|
+
jest.mock('./screenshot.less', () => ({}));
|
|
29
|
+
jest.mock('../captureResult/captureResult.less', () => ({}));
|
|
30
|
+
beforeEach(() => {
|
|
31
|
+
jest.clearAllMocks();
|
|
32
|
+
getSystemInfoSync.mockReturnValue({
|
|
33
|
+
platform: 'android',
|
|
34
|
+
system: 'android 12'
|
|
35
|
+
});
|
|
36
|
+
authorizeStatus.mockImplementation(_ref => {
|
|
37
|
+
let {
|
|
38
|
+
fail
|
|
39
|
+
} = _ref;
|
|
40
|
+
return fail({
|
|
41
|
+
errorCode: 9004
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
authorize.mockImplementation(_ref2 => {
|
|
45
|
+
let {
|
|
46
|
+
fail
|
|
47
|
+
} = _ref2;
|
|
48
|
+
return fail({
|
|
49
|
+
errorCode: 9004
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
getDeviceInfo.mockResolvedValue({
|
|
53
|
+
configMetas: {
|
|
54
|
+
tyabimr4v3: {
|
|
55
|
+
total_split_num: 3
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
const createProps = () => ({
|
|
61
|
+
IPCPlayerContext: {
|
|
62
|
+
snapshot: jest.fn(_ref3 => {
|
|
63
|
+
let {
|
|
64
|
+
success
|
|
65
|
+
} = _ref3;
|
|
66
|
+
return success({
|
|
67
|
+
tempImagePath: 'thingfile://capture.jpg'
|
|
68
|
+
});
|
|
69
|
+
})
|
|
70
|
+
},
|
|
71
|
+
addContent: jest.fn(),
|
|
72
|
+
deleteContent: jest.fn(),
|
|
73
|
+
saveToAlbum: 0,
|
|
74
|
+
devId: 'camera-1',
|
|
75
|
+
toast: jest.fn(),
|
|
76
|
+
screenType: atom('vertical'),
|
|
77
|
+
brandColor: atom('#000000'),
|
|
78
|
+
multiLens: true,
|
|
79
|
+
event: {
|
|
80
|
+
emit: jest.fn()
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
it('keeps multi-lens results when legacy album authorization is unavailable', async () => {
|
|
84
|
+
const props = createProps();
|
|
85
|
+
const {
|
|
86
|
+
result,
|
|
87
|
+
unmount
|
|
88
|
+
} = renderHook(() => Screenshot(props));
|
|
89
|
+
await act(async () => {
|
|
90
|
+
await result.current.props.onClick();
|
|
91
|
+
});
|
|
92
|
+
expect(authorizeStatus).not.toHaveBeenCalled();
|
|
93
|
+
expect(props.IPCPlayerContext.snapshot).toHaveBeenCalledWith(expect.objectContaining({
|
|
94
|
+
saveToAlbum: 0
|
|
95
|
+
}));
|
|
96
|
+
const [, config] = props.addContent.mock.calls[0];
|
|
97
|
+
expect(config.content().props).toEqual(expect.objectContaining({
|
|
98
|
+
count: 3,
|
|
99
|
+
thumbnailPath: 'thingfile://capture_lens1.jpg'
|
|
100
|
+
}));
|
|
101
|
+
unmount();
|
|
102
|
+
});
|
|
103
|
+
it('keeps the permission rejection path before taking a snapshot', async () => {
|
|
104
|
+
getSystemInfoSync.mockReturnValue({
|
|
105
|
+
platform: 'ios',
|
|
106
|
+
system: 'iOS 18'
|
|
107
|
+
});
|
|
108
|
+
const props = createProps();
|
|
109
|
+
const {
|
|
110
|
+
result,
|
|
111
|
+
unmount
|
|
112
|
+
} = renderHook(() => Screenshot(props));
|
|
113
|
+
await act(async () => {
|
|
114
|
+
await result.current.props.onClick();
|
|
115
|
+
});
|
|
116
|
+
expect(props.IPCPlayerContext.snapshot).not.toHaveBeenCalled();
|
|
117
|
+
expect(props.addContent).not.toHaveBeenCalled();
|
|
118
|
+
expect(showModal).toHaveBeenCalledTimes(1);
|
|
119
|
+
unmount();
|
|
120
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ray-js/ipc-player-integration",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.56-beta.0",
|
|
4
4
|
"description": "IPC 融合播放器",
|
|
5
5
|
"main": "lib/index",
|
|
6
6
|
"files": [
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@ray-js/direction-control": "^0.0.8",
|
|
39
39
|
"@ray-js/ipc-ptz-zoom": "^0.0.3",
|
|
40
|
-
"@ray-js/ray-ipc-player": "
|
|
40
|
+
"@ray-js/ray-ipc-player": "2.1.5-beta.0",
|
|
41
41
|
"@ray-js/ray-ipc-utils": "^1.1.16",
|
|
42
42
|
"@ray-js/svg": "0.2.0",
|
|
43
43
|
"clsx": "^1.2.1",
|