@ray-js/ipc-player-integration 0.0.35-beta.3 → 0.0.35-beta.30
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 +0 -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 +8 -3
- package/lib/ui/bottomLeftContent.js +50 -48
- package/lib/ui/bottomRightContent.d.ts +6 -2
- package/lib/ui/bottomRightContent.js +15 -6
- package/lib/ui/constant.d.ts +2 -2
- package/lib/ui/constant.js +2 -3
- package/lib/ui/index.d.ts +1 -1
- package/lib/ui/index.js +1 -1
- package/lib/ui/ui.js +106 -70
- package/lib/ui/ui.less +2 -2
- package/lib/utils/index.d.ts +0 -1
- package/lib/utils/index.js +0 -10
- package/lib/utils/navigation.d.ts +1 -0
- package/lib/utils/navigation.js +5 -2
- package/lib/utils/ttt.d.ts +7 -5
- package/lib/utils/ttt.js +132 -74
- 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 +24 -15
- package/lib/widgets/tryExperience/tryExperience.d.ts +5 -0
- package/lib/widgets/tryExperience/tryExperience.js +109 -13
- package/package.json +3 -3
package/lib/ui/ui.js
CHANGED
|
@@ -12,7 +12,7 @@ import { PlayState, PlayerStreamStatus, MultiCameraScreenMode } from '../interfa
|
|
|
12
12
|
import { useCtx } from '../ctx/ctx.composition';
|
|
13
13
|
import { useStore, updateAtom } from '../ctx/store';
|
|
14
14
|
import { UIEventContext } from './context';
|
|
15
|
-
import { showAllComponent, hideAllComponent, playerTap, startTimeToHideAllComponent, pauseTimeToHideAllComponent, decodeClarityDic, changeIgnoreHideStopPreview, moveablePtzControlId, tileActionsId, tileTipId, landscapeTipId, multiPtzId, ptzMoveableTipId, showFlowLowTipId, zoomLevelChange, setScaleMultipleEvent } from './constant';
|
|
15
|
+
import { showAllComponent, hideAllComponent, playerTap, startTimeToHideAllComponent, pauseTimeToHideAllComponent, decodeClarityDic, changeIgnoreHideStopPreview, moveablePtzControlId, tileActionsId, tileTipId, landscapeTipId, multiPtzId, ptzMoveableTipId, showFlowLowTipId, zoomLevelChange, setScaleMultipleEvent, trialCountdownEnd, refreshSmartImageQualityEvent } from './constant';
|
|
16
16
|
import BottomLeftContent from './bottomLeftContent';
|
|
17
17
|
import BottomRightContent from './bottomRightContent';
|
|
18
18
|
import TopLeftContent from './topLeftContent';
|
|
@@ -22,8 +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 {
|
|
26
|
-
import { getSmartImageQualityState } from '../utils/ttt';
|
|
25
|
+
import { getNgRawData, getSmartImageQualityState, isLowPhone } from '../utils/ttt';
|
|
27
26
|
function getCtxInstance(instance, devId) {
|
|
28
27
|
if (instance) return instance;
|
|
29
28
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
@@ -104,18 +103,37 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
104
103
|
useImperativeHandle(eventRefProp, () => eventRef.current, [eventRef.current]);
|
|
105
104
|
const timer = useRef();
|
|
106
105
|
const reGetOrientationTimer = useRef(null);
|
|
107
|
-
|
|
108
|
-
const [
|
|
106
|
+
// 统一调整为1倍缩放,保证画面展示完全
|
|
107
|
+
const [scaleMultiple, setScaleMultiple] = useState(1);
|
|
108
|
+
// 统一调整为1倍缩放,保证画面展示完全
|
|
109
|
+
const [currentZoomLevel, setCurrentZoomLevel] = useState(1);
|
|
109
110
|
const [createCtx, setCreateCtx] = useState(false);
|
|
110
111
|
// 是否需要忽略进入后台停止预览
|
|
111
112
|
const [ignoreStopOnHide, setIgnoreStopOnHide] = useState(ignoreHideStopPreview);
|
|
112
113
|
const [verticalCoverZoom, setVerticalCoverZoom] = useState(-2);
|
|
113
|
-
|
|
114
|
-
|
|
114
|
+
const isLowPhoneRef = useRef(false);
|
|
115
|
+
useEffect(() => {
|
|
116
|
+
isLowPhone().then(res => {
|
|
117
|
+
isLowPhoneRef.current = !!res;
|
|
118
|
+
});
|
|
119
|
+
}, []);
|
|
115
120
|
|
|
116
121
|
// 展示顶部内容
|
|
117
122
|
const [showTopContent, setShowTopContent] = useState(true);
|
|
118
123
|
|
|
124
|
+
// pad / 折叠屏小窗口展示面板的情况;getSystemInfoSync 在 onLoad 之后才有准确值,
|
|
125
|
+
// 这里给安全默认 false,由 onLoad / onResize 实际计算并更新
|
|
126
|
+
const [isSmallScreen, setIsSmallScreen] = useState(false);
|
|
127
|
+
const computeIsSmallScreen = useMemoizedFn(() => {
|
|
128
|
+
const {
|
|
129
|
+
windowWidth,
|
|
130
|
+
screenWidth,
|
|
131
|
+
windowHeight
|
|
132
|
+
} = getSystemInfoSync();
|
|
133
|
+
// 取小屏值判断是最准确的 pad / 折叠屏小窗口情况
|
|
134
|
+
return !(screenWidth === windowWidth || screenWidth === windowHeight);
|
|
135
|
+
});
|
|
136
|
+
|
|
119
137
|
// 外部传入的ignoreHideStopPreview变化时,同步更新
|
|
120
138
|
useEffect(() => {
|
|
121
139
|
setIgnoreStopOnHide(ignoreHideStopPreview);
|
|
@@ -407,8 +425,8 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
407
425
|
eventRef.current.emit(showAllComponent);
|
|
408
426
|
eventRef.current.emit('disablePlayerTap', true);
|
|
409
427
|
eventRef.current.emit(pauseTimeToHideAllComponent);
|
|
410
|
-
//
|
|
411
|
-
setScaleMultiple(
|
|
428
|
+
// 按宽填充,保证播放流宽度为屏幕宽度,高度自适应设为1倍
|
|
429
|
+
setScaleMultiple(1);
|
|
412
430
|
} else {
|
|
413
431
|
// 短屏或横屏时,恢复自动隐藏
|
|
414
432
|
eventRef.current.emit('disablePlayerTap', false);
|
|
@@ -417,27 +435,47 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
417
435
|
}, [isVerticalFullLayout, screenType, playerFit]);
|
|
418
436
|
useEffect(() => {
|
|
419
437
|
if (createCtx) {
|
|
420
|
-
|
|
421
|
-
|
|
438
|
+
// 统一调整为1倍缩放,保证画面展示完全
|
|
439
|
+
setScaleMultiple(1);
|
|
440
|
+
setCurrentZoomLevel(1);
|
|
422
441
|
}
|
|
423
442
|
}, [playerFit, createCtx]);
|
|
424
443
|
useEffect(() => {
|
|
425
444
|
setBrandColor(brandColor);
|
|
426
445
|
setVerticalMic(verticalMic);
|
|
427
446
|
}, [brandColor, verticalMic]);
|
|
428
|
-
const refreshSmartImageQuality = useMemoizedFn(() => {
|
|
429
|
-
getSmartImageQualityState(devId)
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
447
|
+
const refreshSmartImageQuality = useMemoizedFn(async () => {
|
|
448
|
+
const res = await getSmartImageQualityState(devId);
|
|
449
|
+
if (!res) 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===getSmartImageQualityState', res);
|
|
459
|
+
updatePlayerWidgetProps(instance, 'bottomLeft', 'TryExperience', {
|
|
460
|
+
isPurchase: res.isPurchase,
|
|
461
|
+
buttonState: res.buttonState,
|
|
462
|
+
trialRemainingSec: res.trialRemainingSec,
|
|
463
|
+
canOpenSettings: res.canOpenSettings,
|
|
464
|
+
gRawData: !!getNgRes,
|
|
465
|
+
isLowPhone: isLowPhoneRef.current
|
|
436
466
|
});
|
|
437
467
|
});
|
|
468
|
+
const siqInitRef = useRef(false);
|
|
438
469
|
useEffect(() => {
|
|
439
|
-
|
|
440
|
-
|
|
470
|
+
if (playState === PlayState.PLAYING) {
|
|
471
|
+
if (!siqInitRef.current) {
|
|
472
|
+
siqInitRef.current = true;
|
|
473
|
+
refreshSmartImageQuality();
|
|
474
|
+
}
|
|
475
|
+
} else {
|
|
476
|
+
siqInitRef.current = false;
|
|
477
|
+
}
|
|
478
|
+
}, [instance, playState]);
|
|
441
479
|
const refreshBottomLeft = () => {
|
|
442
480
|
event.current.emit(startTimeToHideAllComponent);
|
|
443
481
|
event.current.emit(showAllComponent);
|
|
@@ -467,6 +505,13 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
467
505
|
* 监听播放器实例创建完成
|
|
468
506
|
*/
|
|
469
507
|
|
|
508
|
+
/**
|
|
509
|
+
* 页面 onLoad 后才能拿到准确的 systemInfo,这里第一次确定小屏状态
|
|
510
|
+
*/
|
|
511
|
+
usePageEvent('onLoad', () => {
|
|
512
|
+
setIsSmallScreen(computeIsSmallScreen());
|
|
513
|
+
});
|
|
514
|
+
|
|
470
515
|
/**
|
|
471
516
|
* 监听屏幕布局变化
|
|
472
517
|
*/
|
|
@@ -480,8 +525,13 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
480
525
|
const {
|
|
481
526
|
type
|
|
482
527
|
} = sizeData;
|
|
528
|
+
|
|
529
|
+
// 折叠屏展开/收起、pad 多窗口拖拽等场景,需要重新计算并同步
|
|
530
|
+
const small = computeIsSmallScreen();
|
|
531
|
+
setIsSmallScreen(small);
|
|
532
|
+
|
|
483
533
|
// 针对pad 和折叠屏展开的情况暂不支持横屏,且在ios pad模式下 会触发onResize事件, 待解决
|
|
484
|
-
if (
|
|
534
|
+
if (small) {
|
|
485
535
|
setScreenType('vertical');
|
|
486
536
|
} else {
|
|
487
537
|
setScreenType(type === 'landscape' ? 'full' : 'vertical');
|
|
@@ -496,19 +546,8 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
496
546
|
}
|
|
497
547
|
triggerEvent(showAllComponent);
|
|
498
548
|
}
|
|
499
|
-
//
|
|
500
|
-
|
|
501
|
-
console.log(scaleMultiple, '===========fill');
|
|
502
|
-
setScaleMultiple(-1);
|
|
503
|
-
} else if (type === 'landscape' && landscapeMode === 'standard') {
|
|
504
|
-
console.log(scaleMultiple, '===========landscape');
|
|
505
|
-
setScaleMultiple(-2);
|
|
506
|
-
} else {
|
|
507
|
-
// 竖屏时 将屏幕播放比例设为按宽按高
|
|
508
|
-
|
|
509
|
-
console.log(scaleMultiple, '===========landscape');
|
|
510
|
-
setScaleMultiple(playerFit === 'contain' ? scaleMultiple === 1 ? -1 : 1 : -2);
|
|
511
|
-
}
|
|
549
|
+
// 横屏(fill/standard)与竖屏均统一调整为 1 倍缩放,保证画面完整展示
|
|
550
|
+
setScaleMultiple(1);
|
|
512
551
|
} catch (err) {
|
|
513
552
|
console.log(err, 'err');
|
|
514
553
|
}
|
|
@@ -641,14 +680,18 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
641
680
|
|
|
642
681
|
/**
|
|
643
682
|
* 右下角可见按钮数 → 右下角组件宽度(左下角同时用作右侧预留宽度)
|
|
644
|
-
*
|
|
683
|
+
* - 横屏: 固定 35%(用百分比,左下角自动按 100% - 35% = 65% 可视,溢出走横向滚动)
|
|
684
|
+
* - 竖屏: 1 个按钮 115px / 2+ 个按钮 132px / 0 个按钮 0
|
|
645
685
|
*/
|
|
646
686
|
const bottomRightWidth = useMemo(() => {
|
|
687
|
+
if (screenType === 'full') {
|
|
688
|
+
return '35%';
|
|
689
|
+
}
|
|
647
690
|
const visibleCount = (bottomRightContent || []).filter(item => !item.hidden).length;
|
|
648
691
|
if (visibleCount <= 0) return 0;
|
|
649
692
|
if (visibleCount === 1) return 115;
|
|
650
693
|
return 132;
|
|
651
|
-
}, [bottomRightContent]);
|
|
694
|
+
}, [bottomRightContent, screenType]);
|
|
652
695
|
|
|
653
696
|
/**
|
|
654
697
|
* 视频流加载状态封装
|
|
@@ -672,10 +715,12 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
672
715
|
}
|
|
673
716
|
}
|
|
674
717
|
if (playState === PlayState.PLAYING) {
|
|
675
|
-
// 仅在第一次播放成功时,针对竖屏并且为cover模式时,设置为-2
|
|
718
|
+
// 仅在第一次播放成功时,针对竖屏并且为cover模式时,设置为-2 修改为只针对第一次播放成功时
|
|
676
719
|
console.log('Playing状态');
|
|
677
|
-
if (screenType === 'vertical' && playerFit === 'cover' && !hasPlayedRef.current) {
|
|
678
|
-
|
|
720
|
+
// if (screenType === 'vertical' && playerFit === 'cover' && !hasPlayedRef.current) {
|
|
721
|
+
if (!hasPlayedRef.current) {
|
|
722
|
+
// 统一调整为1倍缩放,保证画面展示完全
|
|
723
|
+
setScaleMultiple(1);
|
|
679
724
|
hasPlayedRef.current = true;
|
|
680
725
|
}
|
|
681
726
|
}
|
|
@@ -752,6 +797,12 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
752
797
|
const onSetScaleMultiple = value => {
|
|
753
798
|
setScaleMultiple(value);
|
|
754
799
|
};
|
|
800
|
+
const onTrialCountdownEnd = useMemoizedFn(() => {
|
|
801
|
+
// updatePlayerWidgetProps(instance, 'bottomLeft', 'TryExperience' as any, {
|
|
802
|
+
// buttonState: 2,
|
|
803
|
+
// });
|
|
804
|
+
refreshSmartImageQuality();
|
|
805
|
+
});
|
|
755
806
|
useEffect(() => {
|
|
756
807
|
eventRef.current.on(startTimeToHideAllComponent, listenStart);
|
|
757
808
|
eventRef.current.on(pauseTimeToHideAllComponent, listenPause);
|
|
@@ -761,6 +812,8 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
761
812
|
eventRef.current.on('refreshBottomLeft', refreshBottomLeft);
|
|
762
813
|
eventRef.current.on(changeIgnoreHideStopPreview, onChangeIgnoreHideStopPreview);
|
|
763
814
|
eventRef.current.on(setScaleMultipleEvent, onSetScaleMultiple);
|
|
815
|
+
eventRef.current.on(trialCountdownEnd, onTrialCountdownEnd);
|
|
816
|
+
eventRef.current.on(refreshSmartImageQualityEvent, refreshSmartImageQuality);
|
|
764
817
|
return () => {
|
|
765
818
|
eventRef.current.off(startTimeToHideAllComponent, listenStart);
|
|
766
819
|
eventRef.current.off(pauseTimeToHideAllComponent, listenPause);
|
|
@@ -770,6 +823,8 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
770
823
|
eventRef.current.off('refreshBottomLeft', refreshBottomLeft);
|
|
771
824
|
eventRef.current.off(changeIgnoreHideStopPreview, onChangeIgnoreHideStopPreview);
|
|
772
825
|
eventRef.current.off(setScaleMultipleEvent, onSetScaleMultiple);
|
|
826
|
+
eventRef.current.off(trialCountdownEnd, onTrialCountdownEnd);
|
|
827
|
+
eventRef.current.off(refreshSmartImageQualityEvent, refreshSmartImageQuality);
|
|
773
828
|
if (multiTapTimerRef.current) {
|
|
774
829
|
clearTimeout(multiTapTimerRef.current);
|
|
775
830
|
multiTapTimerRef.current = null;
|
|
@@ -784,14 +839,6 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
784
839
|
/**
|
|
785
840
|
* 监听当前的zoom比例状态
|
|
786
841
|
*/
|
|
787
|
-
// useEffect(() => {
|
|
788
|
-
// if (screenType === 'vertical') {
|
|
789
|
-
// console.log(currentZoomLevel, '竖屏时的缩放比例');
|
|
790
|
-
// setVerticalZoomLevel(currentZoomLevel);
|
|
791
|
-
// // setScaleMultiple(currentZoomLevel);
|
|
792
|
-
// }
|
|
793
|
-
// }, [screenType, currentZoomLevel]);
|
|
794
|
-
|
|
795
842
|
const onZoomChange = useMemoizedFn(data => {
|
|
796
843
|
const {
|
|
797
844
|
zoomLevel,
|
|
@@ -802,30 +849,19 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
802
849
|
if (zoomLevel === 0) {
|
|
803
850
|
return false;
|
|
804
851
|
}
|
|
805
|
-
/**
|
|
806
|
-
* 针对竖屏为cover模式时,横屏为standard模式时,主动设置缩放比例,避免因值不能正常变化
|
|
807
|
-
*/
|
|
808
|
-
if (scaleMode === -2 && playerFit === 'cover' && screenType === 'vertical' && landscapeMode === 'standard') {
|
|
809
|
-
console.log('dsadsadsad----', zoomLevel);
|
|
810
|
-
setScaleMultiple(zoomLevel);
|
|
811
|
-
}
|
|
812
852
|
/**
|
|
813
853
|
* 针对竖屏为contain模式时,横屏为fill模式时,主动设置缩放比例,避免因值不能正常变化
|
|
814
854
|
*/
|
|
815
|
-
if (
|
|
816
|
-
|
|
817
|
-
|
|
855
|
+
// if (
|
|
856
|
+
// scaleMode === -1 &&
|
|
857
|
+
// playerFit === 'contain' &&
|
|
858
|
+
// screenType === 'vertical' &&
|
|
859
|
+
// landscapeMode === 'fill'
|
|
860
|
+
// ) {
|
|
861
|
+
// setVerticalCoverZoom(zoomLevel);
|
|
862
|
+
// }
|
|
818
863
|
|
|
819
|
-
|
|
820
|
-
* 横屏情况下 针对竖屏为contain模式时,横屏为fill模式时,主动设置缩放比例,避免因值不能正常变化
|
|
821
|
-
*/
|
|
822
|
-
if (scaleMode === -2 && playerFit === 'cover' && screenType !== 'vertical' && landscapeMode === 'standard') {
|
|
823
|
-
setScaleMultiple(zoomLevel);
|
|
824
|
-
}
|
|
825
|
-
if (scaleMode === -1 && playerFit === 'contain' && screenType !== 'vertical' && landscapeMode === 'fill') {
|
|
826
|
-
setVerticalCoverZoom(zoomLevel);
|
|
827
|
-
setScaleMultiple(zoomLevel);
|
|
828
|
-
}
|
|
864
|
+
// 直接记录当前缩放比例
|
|
829
865
|
setCurrentZoomLevel(zoomLevel);
|
|
830
866
|
instance.event.emit(zoomLevelChange, zoomLevel);
|
|
831
867
|
return false;
|
|
@@ -887,12 +923,12 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
|
|
|
887
923
|
,
|
|
888
924
|
privateState: privateState,
|
|
889
925
|
onPlayerTap: data => {
|
|
890
|
-
console.log('
|
|
926
|
+
console.log('playerTap event');
|
|
891
927
|
if (disablePlayerTap.current) {
|
|
892
928
|
console.log('playerTap 事件已禁止');
|
|
893
929
|
return;
|
|
894
930
|
}
|
|
895
|
-
console.log('res===on
|
|
931
|
+
console.log('res===on onVideoTap1', data);
|
|
896
932
|
if (instance.multiCameraCtx.isSupport) {
|
|
897
933
|
var _instance$multiCamera, _instance$multiCamera2;
|
|
898
934
|
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/ui/ui.less
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
bottom: 0;
|
|
20
20
|
left: 0;
|
|
21
21
|
right: 0;
|
|
22
|
-
padding-top: 12px;
|
|
22
|
+
// padding-top: 12px;
|
|
23
23
|
z-index: 90;
|
|
24
24
|
height: 60px;
|
|
25
25
|
background: linear-gradient(360deg, rgba(0, 0, 0, 0.4) 0%, rgba(0, 0, 0, 0) 100%);
|
|
@@ -157,7 +157,7 @@
|
|
|
157
157
|
// 左下角子元素内容区域样式
|
|
158
158
|
.ipc-player-bottom-left-content-container {
|
|
159
159
|
display: flex;
|
|
160
|
-
flex-direction:
|
|
160
|
+
flex-direction: row;
|
|
161
161
|
}
|
|
162
162
|
|
|
163
163
|
// 右下角子元素内容区域样式
|
package/lib/utils/index.d.ts
CHANGED
package/lib/utils/index.js
CHANGED
|
@@ -1,14 +1,4 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
-
import { getSystemInfoSync } from '@ray-js/ray';
|
|
3
|
-
const {
|
|
4
|
-
windowWidth,
|
|
5
|
-
screenWidth,
|
|
6
|
-
windowHeight
|
|
7
|
-
} = getSystemInfoSync();
|
|
8
|
-
|
|
9
|
-
// pad和折叠屏小窗口展示面板的情况
|
|
10
|
-
export const isSmallScreen = !(screenWidth === windowWidth || screenWidth === windowHeight);
|
|
11
|
-
|
|
12
2
|
/**
|
|
13
3
|
* 麦克风对讲按钮径向渐变
|
|
14
4
|
*/
|
|
@@ -4,3 +4,4 @@ export declare const miniIdLabs: {
|
|
|
4
4
|
};
|
|
5
5
|
export declare function gotoAIDrawMiniProgram(devId: string, brandColor: string): void;
|
|
6
6
|
export declare function gotoSecurityCloudService(homeId: string, uuid: string): Promise<void>;
|
|
7
|
+
export declare function gotoSecurityCloudService2(devId: string): Promise<import("@ray-js/ray-ipc-utils/lib/interface").IRes<unknown>>;
|
package/lib/utils/navigation.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { goToMiniProgramByShortLink } from '@ray-js/ray-ipc-utils';
|
|
1
|
+
import { getServiceUrl, goToMiniProgramByShortLink } from '@ray-js/ray-ipc-utils';
|
|
2
2
|
import Color from 'color';
|
|
3
3
|
|
|
4
4
|
// 小程序ID集合
|
|
@@ -11,10 +11,13 @@ export const miniIdLabs = {
|
|
|
11
11
|
export function gotoAIDrawMiniProgram(devId, brandColor) {
|
|
12
12
|
const color = new Color(brandColor);
|
|
13
13
|
const rgbColor = color.rgb().toString();
|
|
14
|
-
const url = `godzilla://${miniIdLabs.aiDrawMini}
|
|
14
|
+
const url = `godzilla://${miniIdLabs.aiDrawMini}?deviceId=${devId}&themeColor=${rgbColor}`;
|
|
15
15
|
goToMiniProgramByShortLink(url, 'right');
|
|
16
16
|
}
|
|
17
17
|
export async function gotoSecurityCloudService(homeId, uuid) {
|
|
18
18
|
const url = `godzilla://${miniIdLabs.securityCloudService}${'/pages/serviceList/index'}?homeId=${homeId}&deviceId=${uuid}&categoryCode=${'security_cloud_service'}`;
|
|
19
19
|
goToMiniProgramByShortLink(url, 'right');
|
|
20
|
+
}
|
|
21
|
+
export async function gotoSecurityCloudService2(devId) {
|
|
22
|
+
return getServiceUrl(devId, 'security_cloud_service', {}, true);
|
|
20
23
|
}
|
package/lib/utils/ttt.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export type SmartImageQualityResult = {
|
|
|
4
4
|
trialRemainingSec: number;
|
|
5
5
|
canOpenSettings: boolean;
|
|
6
6
|
};
|
|
7
|
-
export declare function getSmartImageQualityState(devId: string): Promise<SmartImageQualityResult>;
|
|
7
|
+
export declare function getSmartImageQualityState(devId: string): Promise<SmartImageQualityResult | null>;
|
|
8
8
|
export type AIFrameFeatureScope = {
|
|
9
9
|
inPreview: boolean;
|
|
10
10
|
inMessage: boolean;
|
|
@@ -25,6 +25,7 @@ export type SetAIFrameFeatureParams = {
|
|
|
25
25
|
devId: string;
|
|
26
26
|
enabled: boolean;
|
|
27
27
|
aiFrameFeature: AIFrameFeatureConfig;
|
|
28
|
+
scene: string;
|
|
28
29
|
};
|
|
29
30
|
export type GetAIFrameFeatureResult = {
|
|
30
31
|
enabled: boolean;
|
|
@@ -33,7 +34,8 @@ export type GetAIFrameFeatureResult = {
|
|
|
33
34
|
localPath: string;
|
|
34
35
|
thingFileUri: string;
|
|
35
36
|
};
|
|
36
|
-
export declare function getAIFrameFeature(devId: string): Promise<GetAIFrameFeatureResult>;
|
|
37
|
-
export declare function setAIFrameFeature(
|
|
38
|
-
export declare function
|
|
39
|
-
export declare function
|
|
37
|
+
export declare function getAIFrameFeature(devId: string): Promise<GetAIFrameFeatureResult | null>;
|
|
38
|
+
export declare function setAIFrameFeature(params: SetAIFrameFeatureParams): Promise<any>;
|
|
39
|
+
export declare function setTrailFinish(devId: string): Promise<unknown>;
|
|
40
|
+
export declare function isLowPhone(): Promise<boolean>;
|
|
41
|
+
export declare function getNgRawData(): Promise<unknown>;
|
package/lib/utils/ttt.js
CHANGED
|
@@ -1,87 +1,145 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
2
|
export function getSmartImageQualityState(devId) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
});
|
|
3
|
+
return new Promise(resolve => {
|
|
4
|
+
var _ty$ipc;
|
|
5
|
+
const isSupport = typeof ((_ty$ipc = ty.ipc) === null || _ty$ipc === void 0 ? void 0 : _ty$ipc.getSmartImageQualityState) === 'function';
|
|
6
|
+
if (!isSupport) {
|
|
7
|
+
resolve(null);
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
try {
|
|
11
|
+
var _ty;
|
|
12
|
+
(_ty = ty) === null || _ty === void 0 || (_ty = _ty.ipc) === null || _ty === void 0 || _ty.getSmartImageQualityState({
|
|
13
|
+
devId,
|
|
14
|
+
scene: 'inPreview',
|
|
15
|
+
success: data => {
|
|
16
|
+
resolve(data);
|
|
17
|
+
},
|
|
18
|
+
fail: () => {
|
|
19
|
+
resolve(null);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
} catch (e) {
|
|
23
|
+
resolve(null);
|
|
24
|
+
}
|
|
27
25
|
});
|
|
28
26
|
}
|
|
29
27
|
export function getAIFrameFeature(devId) {
|
|
30
|
-
return new Promise(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
28
|
+
return new Promise(resolve => {
|
|
29
|
+
var _ty$ipc2;
|
|
30
|
+
const isSupport = typeof ((_ty$ipc2 = ty.ipc) === null || _ty$ipc2 === void 0 ? void 0 : _ty$ipc2.getAIFrameFeature) === 'function';
|
|
31
|
+
if (!isSupport) {
|
|
32
|
+
resolve(null);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
ty.ipc.getAIFrameFeature({
|
|
37
|
+
devId,
|
|
38
|
+
success: data => {
|
|
39
|
+
console.log('res===getAIFrameFeature data', data);
|
|
40
|
+
resolve(data);
|
|
41
|
+
},
|
|
42
|
+
fail: e => {
|
|
43
|
+
console.warn('res===getAIFrameFeature fail', e);
|
|
44
|
+
resolve(null);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
} catch (e) {
|
|
48
|
+
resolve(null);
|
|
49
|
+
}
|
|
44
50
|
});
|
|
45
51
|
}
|
|
46
|
-
export function setAIFrameFeature(
|
|
47
|
-
return new Promise(
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
},
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
52
|
+
export function setAIFrameFeature(params) {
|
|
53
|
+
return new Promise(resolve => {
|
|
54
|
+
var _ty$ipc3;
|
|
55
|
+
const isSupport = typeof ((_ty$ipc3 = ty.ipc) === null || _ty$ipc3 === void 0 ? void 0 : _ty$ipc3.setAIFrameFeature) === 'function';
|
|
56
|
+
if (!isSupport) {
|
|
57
|
+
resolve(null);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
try {
|
|
61
|
+
ty.ipc.setAIFrameFeature(_objectSpread(_objectSpread({}, params), {}, {
|
|
62
|
+
success: data => {
|
|
63
|
+
console.log('res===setAIFrameFeature data', data);
|
|
64
|
+
resolve(data);
|
|
65
|
+
},
|
|
66
|
+
fail: e => {
|
|
67
|
+
console.warn('res===setAIFrameFeature fail', e);
|
|
68
|
+
resolve(null);
|
|
69
|
+
}
|
|
70
|
+
}));
|
|
71
|
+
} catch (e) {
|
|
72
|
+
resolve(null);
|
|
73
|
+
}
|
|
61
74
|
});
|
|
62
75
|
}
|
|
63
|
-
export function
|
|
64
|
-
return new Promise(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
76
|
+
export function setTrailFinish(devId) {
|
|
77
|
+
return new Promise(resolve => {
|
|
78
|
+
var _ty$ipc4;
|
|
79
|
+
const isSupport = typeof ((_ty$ipc4 = ty.ipc) === null || _ty$ipc4 === void 0 ? void 0 : _ty$ipc4.setTrailFinish) === 'function';
|
|
80
|
+
if (!isSupport) {
|
|
81
|
+
resolve(null);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
try {
|
|
85
|
+
var _ty2;
|
|
86
|
+
(_ty2 = ty) === null || _ty2 === void 0 || (_ty2 = _ty2.ipc) === null || _ty2 === void 0 || _ty2.setTrailFinish({
|
|
87
|
+
devId,
|
|
88
|
+
success: res => {
|
|
89
|
+
resolve(res);
|
|
90
|
+
},
|
|
91
|
+
fail: () => {
|
|
92
|
+
resolve(null);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
} catch (e) {
|
|
96
|
+
resolve(null);
|
|
97
|
+
}
|
|
74
98
|
});
|
|
75
99
|
}
|
|
76
|
-
export function
|
|
77
|
-
return new Promise(
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
100
|
+
export function isLowPhone() {
|
|
101
|
+
return new Promise(resolve => {
|
|
102
|
+
var _ty$ipc5;
|
|
103
|
+
const isSupport = typeof ((_ty$ipc5 = ty.ipc) === null || _ty$ipc5 === void 0 ? void 0 : _ty$ipc5.isLowPhone) === 'function';
|
|
104
|
+
if (!isSupport) {
|
|
105
|
+
resolve(false);
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
try {
|
|
109
|
+
ty.ipc.isLowPhone({
|
|
110
|
+
success: res => {
|
|
111
|
+
var _res$isLow;
|
|
112
|
+
resolve((_res$isLow = res === null || res === void 0 ? void 0 : res.isLow) !== null && _res$isLow !== void 0 ? _res$isLow : false);
|
|
113
|
+
},
|
|
114
|
+
fail: () => {
|
|
115
|
+
resolve(false);
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
} catch (e) {
|
|
119
|
+
resolve(false);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
export function getNgRawData() {
|
|
124
|
+
return new Promise(resolve => {
|
|
125
|
+
var _ty3;
|
|
126
|
+
const isSupport = typeof ((_ty3 = ty) === null || _ty3 === void 0 ? void 0 : _ty3.getNgRawData) === 'function';
|
|
127
|
+
if (!isSupport) {
|
|
128
|
+
resolve(false);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
try {
|
|
132
|
+
ty.getNgRawData({
|
|
133
|
+
rawKey: 'is_smart_image_quality',
|
|
134
|
+
success: res => {
|
|
135
|
+
resolve((res === null || res === void 0 ? void 0 : res.rawData) === 'true');
|
|
136
|
+
},
|
|
137
|
+
fail: () => {
|
|
138
|
+
resolve(false);
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
} catch (e) {
|
|
142
|
+
resolve(false);
|
|
143
|
+
}
|
|
86
144
|
});
|
|
87
145
|
}
|
|
@@ -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';
|