@ray-js/ipc-player-integration 0.0.35-beta.9 → 0.0.36
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.js +0 -1
- package/lib/features/initPlayerWidgets/index.js +1 -1
- package/lib/i18n/index.d.ts +4 -0
- package/lib/i18n/strings.d.ts +2 -0
- package/lib/i18n/strings.js +4 -2
- package/lib/res/try/try_close.png +0 -0
- package/lib/ui/bottomLeftContent.d.ts +14 -3
- package/lib/ui/bottomLeftContent.js +284 -59
- package/lib/ui/bottomRightContent.d.ts +6 -2
- package/lib/ui/bottomRightContent.js +15 -6
- package/lib/ui/constant.d.ts +2 -0
- package/lib/ui/constant.js +2 -0
- package/lib/ui/ui.d.ts +2 -1
- package/lib/ui/ui.js +93 -26
- package/lib/ui/ui.less +70 -6
- package/lib/utils/navigation.js +1 -1
- package/lib/utils/ttt.d.ts +5 -4
- package/lib/utils/ttt.js +62 -24
- package/lib/widgets/trialBadge/index.d.ts +1 -3
- package/lib/widgets/trialBadge/index.js +20 -22
- package/lib/widgets/trialBadge/index.less +17 -6
- package/lib/widgets/trialBadge/useTrialBadge.js +20 -10
- package/lib/widgets/tryExperience/tryExperience.d.ts +4 -1
- package/lib/widgets/tryExperience/tryExperience.js +99 -18
- package/package.json +2 -2
|
@@ -1,24 +1,22 @@
|
|
|
1
|
-
import { useCallback, useEffect, useState } from 'react';
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
2
|
import { setTrailFinish } from '../../utils/ttt';
|
|
3
3
|
import { gotoSecurityCloudService2 } from '../../utils';
|
|
4
4
|
import { trialCountdownEnd } from '../../ui/constant';
|
|
5
5
|
import Strings from '../../i18n';
|
|
6
6
|
export const useTrialBadge = (event, devId, trialRemainingSec) => {
|
|
7
7
|
const [showTrialBadge, setShowTrialBadge] = useState(false);
|
|
8
|
+
const prevTrialSecRef = useRef(trialRemainingSec);
|
|
8
9
|
useEffect(() => {
|
|
9
10
|
if (trialRemainingSec > 0 && trialRemainingSec < 300) {
|
|
10
|
-
|
|
11
|
+
if (trialRemainingSec !== prevTrialSecRef.current) {
|
|
12
|
+
setShowTrialBadge(true);
|
|
13
|
+
}
|
|
11
14
|
}
|
|
15
|
+
prevTrialSecRef.current = trialRemainingSec;
|
|
12
16
|
}, [trialRemainingSec]);
|
|
13
17
|
const handleTrialSubscribe = useCallback(async () => {
|
|
14
18
|
try {
|
|
15
|
-
|
|
16
|
-
// const deviceInfo = await getDeviceInfoRay(devId);
|
|
17
|
-
// if (homeInfo !== undefined && deviceInfo !== undefined) {
|
|
18
|
-
// console.log('res===', deviceInfo, homeInfo);
|
|
19
|
-
// gotoSecurityCloudService(homeInfo.homeId, deviceInfo.uuid);
|
|
20
|
-
const res = await gotoSecurityCloudService2(devId);
|
|
21
|
-
console.log('res===gotoSecurityCloudService2', res);
|
|
19
|
+
await gotoSecurityCloudService2(devId);
|
|
22
20
|
} catch (error) {
|
|
23
21
|
ty.showToast({
|
|
24
22
|
title: Strings.getLang('ipc_player_fetch_error'),
|
|
@@ -29,8 +27,20 @@ export const useTrialBadge = (event, devId, trialRemainingSec) => {
|
|
|
29
27
|
const handleCountdownEnd = useCallback(async () => {
|
|
30
28
|
try {
|
|
31
29
|
setShowTrialBadge(false);
|
|
32
|
-
|
|
30
|
+
// const getAI = await getAIFrameFeature(devId);
|
|
31
|
+
// const scope = { ...getAI.aiFrameFeature?.scope, inPreview: false };
|
|
32
|
+
// await setAIFrameFeature({
|
|
33
|
+
// devId,
|
|
34
|
+
// scene: 'inPreview', // 实时预览场景
|
|
35
|
+
// enabled: getAI.enabled,
|
|
36
|
+
// aiFrameFeature: {
|
|
37
|
+
// scope,
|
|
38
|
+
// feature: getAI.aiFrameFeature?.feature,
|
|
39
|
+
// exportEnabled: getAI.aiFrameFeature?.exportEnabled,
|
|
40
|
+
// },
|
|
41
|
+
// });
|
|
33
42
|
await setTrailFinish(devId);
|
|
43
|
+
event.emit(trialCountdownEnd);
|
|
34
44
|
} catch (error) {
|
|
35
45
|
ty.showToast({
|
|
36
46
|
title: Strings.getLang('ipc_player_fetch_error'),
|
|
@@ -3,10 +3,13 @@ import { ComponentConfigProps } from '../../interface';
|
|
|
3
3
|
import './tryExperience.less';
|
|
4
4
|
type Props = ComponentConfigProps & {
|
|
5
5
|
className?: string;
|
|
6
|
-
|
|
6
|
+
hideSmartImageQualityState?: boolean;
|
|
7
7
|
buttonState?: number;
|
|
8
8
|
trialRemainingSec?: number;
|
|
9
9
|
isPurchase?: boolean;
|
|
10
|
+
canOpenSettings?: boolean;
|
|
11
|
+
gRawData?: boolean;
|
|
12
|
+
isLowPhone?: boolean;
|
|
10
13
|
};
|
|
11
14
|
export declare const TryExperience: (props: Props) => React.JSX.Element | null;
|
|
12
15
|
export {};
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import { View, Image, getSystemInfoSync, showToast } from '@ray-js/ray';
|
|
2
3
|
import clsx from 'clsx';
|
|
3
|
-
import React, { useState, useEffect, useCallback } from 'react';
|
|
4
|
+
import React, { useState, useEffect, useCallback, useRef } from 'react';
|
|
4
5
|
import { useStore } from '../../ctx/store';
|
|
5
|
-
import
|
|
6
|
+
import Strings from '../../i18n';
|
|
7
|
+
import { getAIFrameFeature, gotoAIDrawMiniProgram, setAIFrameFeature } from '../../utils';
|
|
8
|
+
import { refreshSmartImageQualityEvent } from '../../ui/constant';
|
|
6
9
|
import tryZh from '../../res/try/try_zh.png';
|
|
7
10
|
import tryEn from '../../res/try/try_en.png';
|
|
8
11
|
import tryOpen from '../../res/try/try_open.png';
|
|
@@ -41,33 +44,111 @@ const pickIconByStatus = buttonState => {
|
|
|
41
44
|
export const TryExperience = props => {
|
|
42
45
|
const {
|
|
43
46
|
className,
|
|
44
|
-
|
|
47
|
+
hideSmartImageQualityState,
|
|
45
48
|
buttonState,
|
|
46
49
|
trialRemainingSec,
|
|
47
|
-
isPurchase
|
|
50
|
+
isPurchase,
|
|
51
|
+
canOpenSettings,
|
|
52
|
+
gRawData,
|
|
53
|
+
isLowPhone,
|
|
54
|
+
devId
|
|
48
55
|
} = props;
|
|
49
56
|
const {
|
|
50
|
-
brandColor
|
|
57
|
+
brandColor,
|
|
58
|
+
recording
|
|
51
59
|
} = useStore({
|
|
52
|
-
brandColor: props.brandColor
|
|
60
|
+
brandColor: props.brandColor,
|
|
61
|
+
recording: props.recording
|
|
53
62
|
});
|
|
54
63
|
const [imgSrc, setImgSrc] = useState();
|
|
64
|
+
const lockRef = useRef(false);
|
|
55
65
|
useEffect(() => {
|
|
56
|
-
|
|
57
|
-
setImgSrc(iconUrl);
|
|
66
|
+
updateImgSrc();
|
|
58
67
|
}, [buttonState]);
|
|
59
|
-
const
|
|
60
|
-
if (
|
|
61
|
-
setImgSrc(tryOpen);
|
|
62
|
-
} else if (buttonState === TryExperienceStatus.Close && isPurchase) {
|
|
63
|
-
setImgSrc(tryClose);
|
|
64
|
-
} else if (buttonState === TryExperienceStatus.Close && trialRemainingSec < 300 && trialRemainingSec > 0) {
|
|
68
|
+
const updateImgSrc = useCallback(() => {
|
|
69
|
+
if (isLowPhone) {
|
|
65
70
|
setImgSrc(tryClose);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if (buttonState === 0 || buttonState) {
|
|
74
|
+
const iconUrl = pickIconByStatus(buttonState);
|
|
75
|
+
setImgSrc(iconUrl);
|
|
66
76
|
} else {
|
|
67
|
-
|
|
77
|
+
setImgSrc(undefined);
|
|
68
78
|
}
|
|
69
79
|
}, [buttonState]);
|
|
70
|
-
|
|
80
|
+
const onTryExperience = useCallback(async () => {
|
|
81
|
+
console.log('res===onTryExperience', lockRef.current, isLowPhone);
|
|
82
|
+
if (lockRef.current) return;
|
|
83
|
+
if (isLowPhone) {
|
|
84
|
+
showToast({
|
|
85
|
+
title: Strings.getLang('ipc_player_low_phone_not_support'),
|
|
86
|
+
icon: 'none'
|
|
87
|
+
});
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (recording) {
|
|
91
|
+
showToast({
|
|
92
|
+
title: Strings.getLang('ipc_player_recording_now_tip'),
|
|
93
|
+
icon: 'none'
|
|
94
|
+
});
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
lockRef.current = true;
|
|
98
|
+
try {
|
|
99
|
+
if (buttonState === TryExperienceStatus.Open) {
|
|
100
|
+
var _getAI$aiFrameFeature, _getAI$aiFrameFeature2, _getAI$aiFrameFeature3, _props$event;
|
|
101
|
+
const getAI = await getAIFrameFeature(devId);
|
|
102
|
+
if (!getAI) return;
|
|
103
|
+
// 由开变关的时候,只关inPreview
|
|
104
|
+
const scope = _objectSpread(_objectSpread({}, (_getAI$aiFrameFeature = getAI.aiFrameFeature) === null || _getAI$aiFrameFeature === void 0 ? void 0 : _getAI$aiFrameFeature.scope), {}, {
|
|
105
|
+
inPreview: false
|
|
106
|
+
});
|
|
107
|
+
await setAIFrameFeature({
|
|
108
|
+
devId,
|
|
109
|
+
scene: 'inPreview',
|
|
110
|
+
// 实时预览场景
|
|
111
|
+
enabled: getAI.enabled,
|
|
112
|
+
aiFrameFeature: {
|
|
113
|
+
scope,
|
|
114
|
+
feature: (_getAI$aiFrameFeature2 = getAI.aiFrameFeature) === null || _getAI$aiFrameFeature2 === void 0 ? void 0 : _getAI$aiFrameFeature2.feature,
|
|
115
|
+
exportEnabled: (_getAI$aiFrameFeature3 = getAI.aiFrameFeature) === null || _getAI$aiFrameFeature3 === void 0 ? void 0 : _getAI$aiFrameFeature3.exportEnabled
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
(_props$event = props.event) === null || _props$event === void 0 || _props$event.emit(refreshSmartImageQualityEvent);
|
|
119
|
+
} else if (buttonState === TryExperienceStatus.Close && isPurchase || buttonState === TryExperienceStatus.Close && trialRemainingSec < 300 && trialRemainingSec > 0) {
|
|
120
|
+
var _getAI$aiFrameFeature4, _getAI$aiFrameFeature5, _getAI$aiFrameFeature6, _props$event2;
|
|
121
|
+
const getAI = await getAIFrameFeature(devId);
|
|
122
|
+
if (!getAI) return;
|
|
123
|
+
const scope = _objectSpread(_objectSpread({}, (_getAI$aiFrameFeature4 = getAI.aiFrameFeature) === null || _getAI$aiFrameFeature4 === void 0 ? void 0 : _getAI$aiFrameFeature4.scope), {}, {
|
|
124
|
+
inPreview: true
|
|
125
|
+
});
|
|
126
|
+
// 由关变开的时候,enabled和inPreview两个都开
|
|
127
|
+
await setAIFrameFeature({
|
|
128
|
+
devId,
|
|
129
|
+
scene: 'inPreview',
|
|
130
|
+
// 实时预览场景
|
|
131
|
+
enabled: true,
|
|
132
|
+
aiFrameFeature: {
|
|
133
|
+
scope,
|
|
134
|
+
feature: (_getAI$aiFrameFeature5 = getAI.aiFrameFeature) === null || _getAI$aiFrameFeature5 === void 0 ? void 0 : _getAI$aiFrameFeature5.feature,
|
|
135
|
+
exportEnabled: (_getAI$aiFrameFeature6 = getAI.aiFrameFeature) === null || _getAI$aiFrameFeature6 === void 0 ? void 0 : _getAI$aiFrameFeature6.exportEnabled
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
(_props$event2 = props.event) === null || _props$event2 === void 0 || _props$event2.emit(refreshSmartImageQualityEvent);
|
|
139
|
+
} else {
|
|
140
|
+
gotoAIDrawMiniProgram(devId, brandColor);
|
|
141
|
+
}
|
|
142
|
+
} catch (error) {
|
|
143
|
+
//
|
|
144
|
+
} finally {
|
|
145
|
+
lockRef.current = false;
|
|
146
|
+
}
|
|
147
|
+
}, [buttonState, recording, isPurchase, trialRemainingSec]);
|
|
148
|
+
if (hideSmartImageQualityState) {
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
if (!imgSrc || !canOpenSettings || !gRawData) {
|
|
71
152
|
return null;
|
|
72
153
|
}
|
|
73
154
|
return /*#__PURE__*/React.createElement(View, {
|
|
@@ -75,7 +156,7 @@ export const TryExperience = props => {
|
|
|
75
156
|
onClick: onTryExperience
|
|
76
157
|
}, /*#__PURE__*/React.createElement(View, {
|
|
77
158
|
className: "try-experience-box"
|
|
78
|
-
},
|
|
159
|
+
}, /*#__PURE__*/React.createElement(Image, {
|
|
79
160
|
className: "try-experience-icon",
|
|
80
161
|
src: imgSrc,
|
|
81
162
|
mode: "heightFix"
|
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.36",
|
|
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": "2.1.
|
|
40
|
+
"@ray-js/ray-ipc-player": "^2.1.2",
|
|
41
41
|
"@ray-js/ray-ipc-utils": "^1.1.15",
|
|
42
42
|
"@ray-js/svg": "0.2.0",
|
|
43
43
|
"clsx": "^1.2.1",
|