@ray-js/ipc-player-integration 0.0.35-beta.12 → 0.0.35-beta.14
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/ui/bottomLeftContent.js +38 -53
- package/lib/ui/constant.d.ts +1 -0
- package/lib/ui/constant.js +1 -0
- package/lib/ui/ui.js +15 -19
- package/lib/utils/ttt.d.ts +1 -0
- package/lib/utils/ttt.js +17 -1
- package/lib/widgets/trialBadge/index.d.ts +1 -3
- package/lib/widgets/trialBadge/index.js +21 -22
- package/lib/widgets/trialBadge/index.less +5 -4
- package/lib/widgets/trialBadge/useTrialBadge.js +8 -1
- package/lib/widgets/tryExperience/tryExperience.d.ts +1 -0
- package/lib/widgets/tryExperience/tryExperience.js +20 -7
- package/package.json +1 -1
|
@@ -8,29 +8,7 @@ import { useStore } from '../ctx/store';
|
|
|
8
8
|
import { useComponentHideState } from './hooks';
|
|
9
9
|
import { TrialBadge, useTrialBadge } from '../widgets/trialBadge';
|
|
10
10
|
/** 右侧透明渐变宽度,用于提示横向可滑动 */
|
|
11
|
-
const FADE_MASK = 'linear-gradient(to right, #000 calc(100% -
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* 试用徽章在不同 screenType 下的容器样式。
|
|
15
|
-
* 「贴在底栏顶部」的策略一致(bottom: 100%),只是 left / marginBottom
|
|
16
|
-
* 等数值按横竖屏不同的边距规则做差异化处理。
|
|
17
|
-
*/
|
|
18
|
-
const TRIAL_BADGE_WRAP_STYLE_VERTICAL = {
|
|
19
|
-
position: 'absolute',
|
|
20
|
-
left: '0px',
|
|
21
|
-
bottom: '100%',
|
|
22
|
-
marginBottom: 4,
|
|
23
|
-
zIndex: 2,
|
|
24
|
-
width: 'max-content'
|
|
25
|
-
};
|
|
26
|
-
const TRIAL_BADGE_WRAP_STYLE_FULL = {
|
|
27
|
-
position: 'absolute',
|
|
28
|
-
left: '25px',
|
|
29
|
-
bottom: '100%',
|
|
30
|
-
marginBottom: 8,
|
|
31
|
-
zIndex: 2,
|
|
32
|
-
width: 'max-content'
|
|
33
|
-
};
|
|
11
|
+
const FADE_MASK = 'linear-gradient(to right, #000 calc(100% - 48px), transparent 100%)';
|
|
34
12
|
const BottomLeftContent = _ref => {
|
|
35
13
|
let {
|
|
36
14
|
ctx,
|
|
@@ -58,16 +36,16 @@ const BottomLeftContent = _ref => {
|
|
|
58
36
|
const tryExp = bottomLeftContent === null || bottomLeftContent === void 0 ? void 0 : bottomLeftContent.find(item => item.id === 'TryExperience');
|
|
59
37
|
return (_trialRemainingSec = tryExp === null || tryExp === void 0 || (_tryExp$initProps2 = tryExp.initProps) === null || _tryExp$initProps2 === void 0 ? void 0 : _tryExp$initProps2.trialRemainingSec) !== null && _trialRemainingSec !== void 0 ? _trialRemainingSec : 0;
|
|
60
38
|
}, [bottomLeftContent]);
|
|
61
|
-
const refreshToken = useMemo(() => {
|
|
62
|
-
var _refreshToken, _tryExp$initProps3;
|
|
63
|
-
const tryExp = bottomLeftContent === null || bottomLeftContent === void 0 ? void 0 : bottomLeftContent.find(item => item.id === 'TryExperience');
|
|
64
|
-
return (_refreshToken = tryExp === null || tryExp === void 0 || (_tryExp$initProps3 = tryExp.initProps) === null || _tryExp$initProps3 === void 0 ? void 0 : _tryExp$initProps3.refreshToken) !== null && _refreshToken !== void 0 ? _refreshToken : 0;
|
|
65
|
-
}, [bottomLeftContent]);
|
|
66
39
|
const isLowPhone = useMemo(() => {
|
|
67
|
-
var _isLowPhone, _tryExp$
|
|
40
|
+
var _isLowPhone, _tryExp$initProps3;
|
|
68
41
|
const tryExp = bottomLeftContent === null || bottomLeftContent === void 0 ? void 0 : bottomLeftContent.find(item => item.id === 'TryExperience');
|
|
69
|
-
return (_isLowPhone = tryExp === null || tryExp === void 0 || (_tryExp$
|
|
42
|
+
return (_isLowPhone = tryExp === null || tryExp === void 0 || (_tryExp$initProps3 = tryExp.initProps) === null || _tryExp$initProps3 === void 0 ? void 0 : _tryExp$initProps3.isLowPhone) !== null && _isLowPhone !== void 0 ? _isLowPhone : false;
|
|
70
43
|
}, []);
|
|
44
|
+
const gRawData = useMemo(() => {
|
|
45
|
+
var _gRawData, _tryExp$initProps4;
|
|
46
|
+
const tryExp = bottomLeftContent === null || bottomLeftContent === void 0 ? void 0 : bottomLeftContent.find(item => item.id === 'TryExperience');
|
|
47
|
+
return (_gRawData = tryExp === null || tryExp === void 0 || (_tryExp$initProps4 = tryExp.initProps) === null || _tryExp$initProps4 === void 0 ? void 0 : _tryExp$initProps4.gRawData) !== null && _gRawData !== void 0 ? _gRawData : false;
|
|
48
|
+
}, [bottomLeftContent]);
|
|
71
49
|
const [shouldHide] = useComponentHideState();
|
|
72
50
|
const {
|
|
73
51
|
showTrialBadge,
|
|
@@ -75,30 +53,40 @@ const BottomLeftContent = _ref => {
|
|
|
75
53
|
handleCountdownEnd
|
|
76
54
|
} = useTrialBadge(ctx.event, ctx.devId, trialRemainingSec);
|
|
77
55
|
const paddingLeftPx = screenType === 'vertical' ? 0 : 25;
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
,
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
56
|
+
const containerHeight = screenType === 'vertical' ? '40px' : '58px';
|
|
57
|
+
const trialBadgeStyle = screenType === 'vertical' ? {
|
|
58
|
+
position: 'absolute',
|
|
59
|
+
left: '0px',
|
|
60
|
+
bottom: '48px',
|
|
61
|
+
marginBottom: 4,
|
|
62
|
+
zIndex: 101,
|
|
63
|
+
width: 'max-content'
|
|
64
|
+
} : {
|
|
65
|
+
position: 'absolute',
|
|
66
|
+
left: '25px',
|
|
67
|
+
bottom: '72px',
|
|
68
|
+
marginBottom: 8,
|
|
69
|
+
zIndex: 101,
|
|
70
|
+
width: 'max-content'
|
|
71
|
+
};
|
|
72
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, showSmartImageQuality && showTrialBadge && canOpenSettings && gRawData && !isLowPhone && trialRemainingSec > 0 && /*#__PURE__*/React.createElement(CoverView, {
|
|
73
|
+
style: _objectSpread(_objectSpread({}, trialBadgeStyle), {}, {
|
|
92
74
|
opacity: shouldHide ? 0 : 1,
|
|
93
|
-
|
|
94
|
-
})
|
|
75
|
+
pointerEvents: shouldHide ? 'none' : 'auto'
|
|
76
|
+
}),
|
|
77
|
+
onClick: e => e.stopPropagation()
|
|
95
78
|
}, /*#__PURE__*/React.createElement(TrialBadge, {
|
|
96
79
|
brandColor: brandColor,
|
|
97
80
|
trialRemainingSec: trialRemainingSec,
|
|
98
|
-
refreshToken: refreshToken,
|
|
99
81
|
onSubscribe: handleTrialSubscribe,
|
|
100
82
|
onCountdownEnd: handleCountdownEnd
|
|
101
|
-
})), /*#__PURE__*/React.createElement(
|
|
83
|
+
})), /*#__PURE__*/React.createElement(CoverView, {
|
|
84
|
+
className: clsx('ipc-player-bottom-left-content-wrap'),
|
|
85
|
+
style: {
|
|
86
|
+
right: `${reservedRight}px`,
|
|
87
|
+
height: containerHeight
|
|
88
|
+
}
|
|
89
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
102
90
|
style: {
|
|
103
91
|
paddingBottom: screenType === 'vertical' ? '14px' : '32px',
|
|
104
92
|
paddingLeft: `${paddingLeftPx}px`,
|
|
@@ -111,10 +99,7 @@ const BottomLeftContent = _ref => {
|
|
|
111
99
|
WebkitMaskImage: FADE_MASK,
|
|
112
100
|
maskImage: FADE_MASK
|
|
113
101
|
},
|
|
114
|
-
className: clsx('ipc-player-bottom-left-content-container'
|
|
115
|
-
|
|
116
|
-
// 'ipc-player-bottom-left-content-show': !shouldHide,
|
|
117
|
-
})
|
|
118
|
-
}, children));
|
|
102
|
+
className: clsx('ipc-player-bottom-left-content-container')
|
|
103
|
+
}, children)));
|
|
119
104
|
};
|
|
120
105
|
export default BottomLeftContent;
|
package/lib/ui/constant.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ export declare const widgetClick = "widgetClick";
|
|
|
26
26
|
* 业务侧/相关控件可监听此事件刷新自己的状态(例如 TryExperience 重新拉取状态)
|
|
27
27
|
*/
|
|
28
28
|
export declare const trialCountdownEnd = "trialCountdownEnd";
|
|
29
|
+
export declare const hideTrialBadgeEvent = "hideTrialBadge";
|
|
29
30
|
export declare const refreshSmartImageQualityEvent = "refreshSmartImageQuality";
|
|
30
31
|
/** 控件点击事件用的 widgetId,统一在此维护 */
|
|
31
32
|
export declare const widgetLabs: {
|
package/lib/ui/constant.js
CHANGED
|
@@ -27,6 +27,7 @@ export const widgetClick = 'widgetClick';
|
|
|
27
27
|
* 业务侧/相关控件可监听此事件刷新自己的状态(例如 TryExperience 重新拉取状态)
|
|
28
28
|
*/
|
|
29
29
|
export const trialCountdownEnd = 'trialCountdownEnd';
|
|
30
|
+
export const hideTrialBadgeEvent = 'hideTrialBadge';
|
|
30
31
|
export const refreshSmartImageQualityEvent = 'refreshSmartImageQuality';
|
|
31
32
|
|
|
32
33
|
/** 控件点击事件用的 widgetId,统一在此维护 */
|
package/lib/ui/ui.js
CHANGED
|
@@ -22,7 +22,7 @@ import { useMemoizedFn } from '../hooks';
|
|
|
22
22
|
import { Storage } from '../utils/storage';
|
|
23
23
|
import './ui.less';
|
|
24
24
|
import { updatePlayerWidgetProps } from '../features';
|
|
25
|
-
import { getSmartImageQualityState, isLowPhone } from '../utils/ttt';
|
|
25
|
+
import { getNgRawData, getSmartImageQualityState, isLowPhone } from '../utils/ttt';
|
|
26
26
|
function getCtxInstance(instance, devId) {
|
|
27
27
|
if (instance) return instance;
|
|
28
28
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
@@ -111,9 +111,6 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
111
111
|
// 是否需要忽略进入后台停止预览
|
|
112
112
|
const [ignoreStopOnHide, setIgnoreStopOnHide] = useState(ignoreHideStopPreview);
|
|
113
113
|
const [verticalCoverZoom, setVerticalCoverZoom] = useState(-2);
|
|
114
|
-
// const [verticalCoverZoom, setVerticalCoverZoom] = useState(-2);
|
|
115
|
-
// const [verticalZoomLevel, setVerticalZoomLevel] = useState(playerFit === 'contain' ? 1 : -2);
|
|
116
|
-
|
|
117
114
|
const isLowPhoneRef = useRef(false);
|
|
118
115
|
useEffect(() => {
|
|
119
116
|
isLowPhone().then(res => {
|
|
@@ -448,25 +445,24 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
448
445
|
setVerticalMic(verticalMic);
|
|
449
446
|
}, [brandColor, verticalMic]);
|
|
450
447
|
const refreshSmartImageQuality = useMemoizedFn(async () => {
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
//
|
|
454
|
-
//
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
}
|
|
448
|
+
const res = await getSmartImageQualityState(devId);
|
|
449
|
+
if (res === undefined) return;
|
|
450
|
+
// 调试时使用
|
|
451
|
+
// res = {
|
|
452
|
+
// isPurchase: false,
|
|
453
|
+
// buttonState: 0,
|
|
454
|
+
// trialRemainingSec: 20,
|
|
455
|
+
// canOpenSettings: true,
|
|
456
|
+
// };
|
|
457
|
+
const getNgRes = await getNgRawData();
|
|
458
|
+
console.log('res===getNgRes', res, getNgRes);
|
|
463
459
|
updatePlayerWidgetProps(instance, 'bottomLeft', 'TryExperience', {
|
|
464
460
|
isPurchase: res.isPurchase,
|
|
465
461
|
buttonState: res.buttonState,
|
|
466
462
|
trialRemainingSec: res.trialRemainingSec,
|
|
467
463
|
canOpenSettings: res.canOpenSettings,
|
|
468
|
-
|
|
469
|
-
|
|
464
|
+
gRawData: !!getNgRes,
|
|
465
|
+
isLowPhone: isLowPhoneRef.current
|
|
470
466
|
});
|
|
471
467
|
});
|
|
472
468
|
useEffect(() => {
|
|
@@ -921,7 +917,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
921
917
|
console.log('playerTap 事件已禁止');
|
|
922
918
|
return;
|
|
923
919
|
}
|
|
924
|
-
console.log('res===on
|
|
920
|
+
console.log('res===on onVideoTap1', data);
|
|
925
921
|
if (instance.multiCameraCtx.isSupport) {
|
|
926
922
|
var _instance$multiCamera, _instance$multiCamera2;
|
|
927
923
|
const preTapIndex = (_instance$multiCamera = (_instance$multiCamera2 = instance.multiCameraCtx.selectedLenInfoRef.current) === null || _instance$multiCamera2 === void 0 ? void 0 : _instance$multiCamera2.index) !== null && _instance$multiCamera !== void 0 ? _instance$multiCamera : prevSelectedIndexRef.current;
|
package/lib/utils/ttt.d.ts
CHANGED
|
@@ -40,3 +40,4 @@ export declare function getDeviceInfo(devId: string): Promise<unknown>;
|
|
|
40
40
|
export declare function getCurrentHomeInfo(): Promise<unknown>;
|
|
41
41
|
export declare function setTrailFinish(devId: string): Promise<unknown>;
|
|
42
42
|
export declare function isLowPhone(): Promise<unknown>;
|
|
43
|
+
export declare function getNgRawData(): Promise<unknown>;
|
package/lib/utils/ttt.js
CHANGED
|
@@ -6,7 +6,6 @@ export function getSmartImageQualityState(devId) {
|
|
|
6
6
|
devId,
|
|
7
7
|
scene: 'inPreview',
|
|
8
8
|
success: data => {
|
|
9
|
-
console.log('res===getSmartImageQualityState data', data);
|
|
10
9
|
resolve(data);
|
|
11
10
|
},
|
|
12
11
|
fail: () => {
|
|
@@ -120,4 +119,21 @@ export function isLowPhone() {
|
|
|
120
119
|
resolve(false);
|
|
121
120
|
}
|
|
122
121
|
});
|
|
122
|
+
}
|
|
123
|
+
export function getNgRawData() {
|
|
124
|
+
return new Promise(resolve => {
|
|
125
|
+
try {
|
|
126
|
+
ty.getNgRawData({
|
|
127
|
+
rawKey: 'is_smart_image_quality',
|
|
128
|
+
success: res => {
|
|
129
|
+
resolve(res);
|
|
130
|
+
},
|
|
131
|
+
fail: () => {
|
|
132
|
+
resolve(false);
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
} catch (e) {
|
|
136
|
+
resolve(false);
|
|
137
|
+
}
|
|
138
|
+
});
|
|
123
139
|
}
|
|
@@ -6,12 +6,10 @@ type Props = {
|
|
|
6
6
|
brandColor?: string;
|
|
7
7
|
/** 试看倒计时初始秒数,来源于 smartImageQualityState.trialRemainingSec */
|
|
8
8
|
trialRemainingSec?: number;
|
|
9
|
-
/** 刷新令牌,变化时重置倒计时状态 */
|
|
10
|
-
refreshToken?: number;
|
|
11
9
|
/** 点击「开通」按钮回调 */
|
|
12
10
|
onSubscribe?: () => void;
|
|
13
11
|
/** 倒计时归零时触发,本组件保证整个生命周期内只回调一次 */
|
|
14
12
|
onCountdownEnd?: () => void;
|
|
15
13
|
};
|
|
16
|
-
export declare const TrialBadge: ({ className, brandColor, trialRemainingSec,
|
|
14
|
+
export declare const TrialBadge: ({ className, brandColor, trialRemainingSec, onSubscribe, onCountdownEnd, }: Props) => React.JSX.Element;
|
|
17
15
|
export { useTrialBadge } from './useTrialBadge';
|
|
@@ -18,21 +18,25 @@ export const TrialBadge = _ref => {
|
|
|
18
18
|
className,
|
|
19
19
|
brandColor = FALLBACK_BRAND_COLOR,
|
|
20
20
|
trialRemainingSec = 0,
|
|
21
|
-
refreshToken,
|
|
22
21
|
onSubscribe,
|
|
23
22
|
onCountdownEnd
|
|
24
23
|
} = _ref;
|
|
25
24
|
const [remainingSec, setRemainingSec] = useState(Math.max(0, Math.floor(trialRemainingSec)));
|
|
26
|
-
/** 防止 onCountdownEnd 被重复触发;同时持有最新回调,避免依赖变化导致 effect 重跑 */
|
|
27
25
|
const endedRef = useRef(false);
|
|
28
26
|
const onCountdownEndRef = useRef(onCountdownEnd);
|
|
29
27
|
onCountdownEndRef.current = onCountdownEnd;
|
|
28
|
+
const startTimeRef = useRef(Date.now());
|
|
29
|
+
const initialSecRef = useRef(Math.max(0, Math.floor(trialRemainingSec)));
|
|
30
30
|
useEffect(() => {
|
|
31
|
+
console.log('res===trialRemainingSec', trialRemainingSec);
|
|
32
|
+
const sec = Math.max(0, Math.floor(trialRemainingSec));
|
|
31
33
|
endedRef.current = false;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
+
initialSecRef.current = sec;
|
|
35
|
+
startTimeRef.current = Date.now();
|
|
36
|
+
setRemainingSec(sec);
|
|
37
|
+
}, [trialRemainingSec]);
|
|
34
38
|
useEffect(() => {
|
|
35
|
-
if (
|
|
39
|
+
if (trialRemainingSec <= 0) {
|
|
36
40
|
if (!endedRef.current) {
|
|
37
41
|
var _onCountdownEndRef$cu;
|
|
38
42
|
endedRef.current = true;
|
|
@@ -41,22 +45,20 @@ export const TrialBadge = _ref => {
|
|
|
41
45
|
return undefined;
|
|
42
46
|
}
|
|
43
47
|
const timer = setInterval(() => {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return 0;
|
|
48
|
+
const elapsed = Math.floor((Date.now() - startTimeRef.current) / 1000);
|
|
49
|
+
const next = Math.max(0, initialSecRef.current - elapsed);
|
|
50
|
+
setRemainingSec(next);
|
|
51
|
+
if (next <= 0) {
|
|
52
|
+
clearInterval(timer);
|
|
53
|
+
if (!endedRef.current) {
|
|
54
|
+
var _onCountdownEndRef$cu2;
|
|
55
|
+
endedRef.current = true;
|
|
56
|
+
(_onCountdownEndRef$cu2 = onCountdownEndRef.current) === null || _onCountdownEndRef$cu2 === void 0 || _onCountdownEndRef$cu2.call(onCountdownEndRef);
|
|
54
57
|
}
|
|
55
|
-
|
|
56
|
-
});
|
|
58
|
+
}
|
|
57
59
|
}, 1000);
|
|
58
60
|
return () => clearInterval(timer);
|
|
59
|
-
}, [trialRemainingSec
|
|
61
|
+
}, [trialRemainingSec]);
|
|
60
62
|
const countdownText = formatCountdown(remainingSec);
|
|
61
63
|
return /*#__PURE__*/React.createElement(View, {
|
|
62
64
|
className: clsx('ipc-player-trial-badge', className)
|
|
@@ -75,10 +77,7 @@ export const TrialBadge = _ref => {
|
|
|
75
77
|
style: {
|
|
76
78
|
backgroundColor: brandColor
|
|
77
79
|
},
|
|
78
|
-
onClick:
|
|
79
|
-
if (e && typeof e.stopPropagation === 'function') {
|
|
80
|
-
e.stopPropagation();
|
|
81
|
-
}
|
|
80
|
+
onClick: () => {
|
|
82
81
|
onSubscribe === null || onSubscribe === void 0 || onSubscribe();
|
|
83
82
|
}
|
|
84
83
|
}, /*#__PURE__*/React.createElement(Text, {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
.ipc-player-trial-badge {
|
|
2
2
|
display: inline-flex;
|
|
3
3
|
align-items: center;
|
|
4
|
-
height:
|
|
4
|
+
height: 40px;
|
|
5
5
|
padding: 0 4px 0 8px;
|
|
6
6
|
border-radius: 6px;
|
|
7
7
|
background: rgba(0, 0, 0, 0.65);
|
|
@@ -43,9 +43,10 @@
|
|
|
43
43
|
display: inline-flex;
|
|
44
44
|
align-items: center;
|
|
45
45
|
justify-content: center;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
min-width: 44px;
|
|
47
|
+
min-height: 28px;
|
|
48
|
+
padding: 0 12px;
|
|
49
|
+
border-radius: 14px;
|
|
49
50
|
flex-shrink: 0;
|
|
50
51
|
}
|
|
51
52
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useCallback, useEffect, useState } from 'react';
|
|
2
2
|
import { setTrailFinish } from '../../utils/ttt';
|
|
3
3
|
import { gotoSecurityCloudService2 } from '../../utils';
|
|
4
|
-
import { trialCountdownEnd } from '../../ui/constant';
|
|
4
|
+
import { trialCountdownEnd, hideTrialBadgeEvent } from '../../ui/constant';
|
|
5
5
|
import Strings from '../../i18n';
|
|
6
6
|
export const useTrialBadge = (event, devId, trialRemainingSec) => {
|
|
7
7
|
const [showTrialBadge, setShowTrialBadge] = useState(false);
|
|
@@ -10,6 +10,13 @@ export const useTrialBadge = (event, devId, trialRemainingSec) => {
|
|
|
10
10
|
setShowTrialBadge(true);
|
|
11
11
|
}
|
|
12
12
|
}, [trialRemainingSec]);
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
const hide = () => setShowTrialBadge(false);
|
|
15
|
+
event.on(hideTrialBadgeEvent, hide);
|
|
16
|
+
return () => {
|
|
17
|
+
event.off(hideTrialBadgeEvent, hide);
|
|
18
|
+
};
|
|
19
|
+
}, [event]);
|
|
13
20
|
const handleTrialSubscribe = useCallback(async () => {
|
|
14
21
|
try {
|
|
15
22
|
const res = await gotoSecurityCloudService2(devId);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
2
|
import { View, Image, getSystemInfoSync, showToast } from '@ray-js/ray';
|
|
3
3
|
import clsx from 'clsx';
|
|
4
|
-
import React, { useState, useEffect, useCallback } from 'react';
|
|
4
|
+
import React, { useState, useEffect, useCallback, useRef } from 'react';
|
|
5
5
|
import { useStore } from '../../ctx/store';
|
|
6
6
|
import Strings from '../../i18n';
|
|
7
7
|
import { getAIFrameFeature, gotoAIDrawMiniProgram, setAIFrameFeature } from '../../utils';
|
|
8
|
-
import { refreshSmartImageQualityEvent } from '../../ui/constant';
|
|
8
|
+
import { refreshSmartImageQualityEvent, hideTrialBadgeEvent } from '../../ui/constant';
|
|
9
9
|
import tryZh from '../../res/try/try_zh.png';
|
|
10
10
|
import tryEn from '../../res/try/try_en.png';
|
|
11
11
|
import tryOpen from '../../res/try/try_open.png';
|
|
@@ -49,6 +49,7 @@ export const TryExperience = props => {
|
|
|
49
49
|
trialRemainingSec,
|
|
50
50
|
isPurchase,
|
|
51
51
|
canOpenSettings,
|
|
52
|
+
gRawData,
|
|
52
53
|
isLowPhone,
|
|
53
54
|
devId
|
|
54
55
|
} = props;
|
|
@@ -60,6 +61,7 @@ export const TryExperience = props => {
|
|
|
60
61
|
recording: props.recording
|
|
61
62
|
});
|
|
62
63
|
const [imgSrc, setImgSrc] = useState();
|
|
64
|
+
const lockRef = useRef(false);
|
|
63
65
|
useEffect(() => {
|
|
64
66
|
updateImgSrc();
|
|
65
67
|
}, [buttonState]);
|
|
@@ -69,6 +71,12 @@ export const TryExperience = props => {
|
|
|
69
71
|
setImgSrc(tryClose);
|
|
70
72
|
return;
|
|
71
73
|
}
|
|
74
|
+
// ty.getNgRawData({
|
|
75
|
+
// rawKey: 'is_smart_image_quality',
|
|
76
|
+
// success: () => {},
|
|
77
|
+
// fail: () => {},
|
|
78
|
+
// });
|
|
79
|
+
// success里具体的值 要看看实际调试结果, APP NG 配置支持的话 才展示智能画质开关哦
|
|
72
80
|
if (buttonState === 0 || buttonState) {
|
|
73
81
|
const iconUrl = pickIconByStatus(buttonState);
|
|
74
82
|
setImgSrc(iconUrl);
|
|
@@ -77,6 +85,7 @@ export const TryExperience = props => {
|
|
|
77
85
|
}
|
|
78
86
|
}, [buttonState]);
|
|
79
87
|
const onTryExperience = useCallback(async () => {
|
|
88
|
+
if (lockRef.current) return;
|
|
80
89
|
if (isLowPhone) {
|
|
81
90
|
showToast({
|
|
82
91
|
title: Strings.getLang('ipc_player_low_phone_not_support'),
|
|
@@ -91,10 +100,11 @@ export const TryExperience = props => {
|
|
|
91
100
|
});
|
|
92
101
|
return;
|
|
93
102
|
}
|
|
103
|
+
lockRef.current = true;
|
|
94
104
|
try {
|
|
95
105
|
const getAI = await getAIFrameFeature(devId);
|
|
96
106
|
if (buttonState === TryExperienceStatus.Open) {
|
|
97
|
-
var _getAI$aiFrameFeature, _getAI$aiFrameFeature2, _getAI$aiFrameFeature3, _props$event;
|
|
107
|
+
var _getAI$aiFrameFeature, _getAI$aiFrameFeature2, _getAI$aiFrameFeature3, _props$event, _props$event2;
|
|
98
108
|
// 由开变关的时候,只关inPreview
|
|
99
109
|
const scope = _objectSpread(_objectSpread({}, (_getAI$aiFrameFeature = getAI.aiFrameFeature) === null || _getAI$aiFrameFeature === void 0 ? void 0 : _getAI$aiFrameFeature.scope), {}, {
|
|
100
110
|
inPreview: false
|
|
@@ -110,9 +120,10 @@ export const TryExperience = props => {
|
|
|
110
120
|
exportEnabled: (_getAI$aiFrameFeature3 = getAI.aiFrameFeature) === null || _getAI$aiFrameFeature3 === void 0 ? void 0 : _getAI$aiFrameFeature3.exportEnabled
|
|
111
121
|
}
|
|
112
122
|
});
|
|
113
|
-
(_props$event = props.event) === null || _props$event === void 0 || _props$event.emit(
|
|
123
|
+
(_props$event = props.event) === null || _props$event === void 0 || _props$event.emit(hideTrialBadgeEvent);
|
|
124
|
+
(_props$event2 = props.event) === null || _props$event2 === void 0 || _props$event2.emit(refreshSmartImageQualityEvent);
|
|
114
125
|
} else if (buttonState === TryExperienceStatus.Close && isPurchase || buttonState === TryExperienceStatus.Close && trialRemainingSec < 300 && trialRemainingSec > 0) {
|
|
115
|
-
var _getAI$aiFrameFeature4, _getAI$aiFrameFeature5, _getAI$aiFrameFeature6, _props$
|
|
126
|
+
var _getAI$aiFrameFeature4, _getAI$aiFrameFeature5, _getAI$aiFrameFeature6, _props$event3;
|
|
116
127
|
const scope = _objectSpread(_objectSpread({}, (_getAI$aiFrameFeature4 = getAI.aiFrameFeature) === null || _getAI$aiFrameFeature4 === void 0 ? void 0 : _getAI$aiFrameFeature4.scope), {}, {
|
|
117
128
|
inPreview: true
|
|
118
129
|
});
|
|
@@ -128,18 +139,20 @@ export const TryExperience = props => {
|
|
|
128
139
|
exportEnabled: (_getAI$aiFrameFeature6 = getAI.aiFrameFeature) === null || _getAI$aiFrameFeature6 === void 0 ? void 0 : _getAI$aiFrameFeature6.exportEnabled
|
|
129
140
|
}
|
|
130
141
|
});
|
|
131
|
-
(_props$
|
|
142
|
+
(_props$event3 = props.event) === null || _props$event3 === void 0 || _props$event3.emit(refreshSmartImageQualityEvent);
|
|
132
143
|
} else {
|
|
133
144
|
gotoAIDrawMiniProgram(devId, brandColor);
|
|
134
145
|
}
|
|
135
146
|
} catch (error) {
|
|
136
147
|
//
|
|
148
|
+
} finally {
|
|
149
|
+
lockRef.current = false;
|
|
137
150
|
}
|
|
138
151
|
}, [buttonState, recording, isPurchase, trialRemainingSec]);
|
|
139
152
|
if (hideTryExperienceMenu) {
|
|
140
153
|
return null;
|
|
141
154
|
}
|
|
142
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, imgSrc && canOpenSettings && /*#__PURE__*/React.createElement(View, {
|
|
155
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, imgSrc && canOpenSettings && gRawData && /*#__PURE__*/React.createElement(View, {
|
|
143
156
|
className: clsx(className),
|
|
144
157
|
onClick: onTryExperience
|
|
145
158
|
}, /*#__PURE__*/React.createElement(View, {
|