@ray-js/ipc-player-integration 0.0.35-beta.2 → 0.0.35-beta.3

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.
@@ -8,18 +8,12 @@ export type InitPlayerWidgetsOptions = {
8
8
  hideScreenShotMenu?: boolean;
9
9
  hideRecordVideoMenu?: boolean;
10
10
  hideResolutionMenu?: boolean;
11
- hideTryExperienceMenu?: boolean;
12
11
  hideKbsMenu?: boolean;
13
12
  hideSignalMenu?: boolean;
14
13
  showToggleVerticalFull?: boolean;
15
14
  showRealTimeMagnification?: boolean;
16
15
  directionControlProps?: Partial<React.ComponentProps<typeof FullScreen>['directionControlProps']>;
17
- smartImageQualityState?: {
18
- isPurchase: boolean;
19
- buttonState: number;
20
- trialRemainingSec: number;
21
- canOpenSettings: boolean;
22
- };
16
+ hideSmartImageQualityState?: boolean;
23
17
  topLeftContent?: ComponentConfig[];
24
18
  topRightContent?: ComponentConfig[];
25
19
  bottomLeftContent?: ComponentConfig[];
@@ -21,12 +21,10 @@ export async function initPlayerWidgets(ctx, options) {
21
21
  const screenShotIndex = newDefaultBottomLeftContent.findIndex(item => item.id === 'Screenshot');
22
22
  const recordVideoIndex = newDefaultBottomLeftContent.findIndex(item => item.id === 'RecordVideo');
23
23
  if (tryExperienceIndex !== -1) {
24
- var _options$smartImageQu, _options$smartImageQu2;
24
+ var _options$hideSmartIma;
25
25
  // @ts-ignore
26
26
  newDefaultBottomLeftContent[tryExperienceIndex].initProps = {
27
- hideTryExperienceMenu: options.hideTryExperienceMenu,
28
- buttonState: (_options$smartImageQu = options.smartImageQualityState) === null || _options$smartImageQu === void 0 ? void 0 : _options$smartImageQu.buttonState,
29
- trialRemainingSec: (_options$smartImageQu2 = options.smartImageQualityState) === null || _options$smartImageQu2 === void 0 ? void 0 : _options$smartImageQu2.trialRemainingSec
27
+ hideTryExperienceMenu: (_options$hideSmartIma = options.hideSmartImageQualityState) !== null && _options$hideSmartIma !== void 0 ? _options$hideSmartIma : true
30
28
  };
31
29
  }
32
30
  if (resolutionIndex !== -1) {
@@ -32,6 +32,7 @@ declare const Strings: kit.I18N<{
32
32
  ipc_player_trial_in_use: string;
33
33
  ipc_player_trial_preview_text: string;
34
34
  ipc_player_trial_subscribe: string;
35
+ ipc_player_fetch_error: string;
35
36
  };
36
37
  zh: {
37
38
  ipc_player_resolution_HD: string;
@@ -65,6 +66,7 @@ declare const Strings: kit.I18N<{
65
66
  ipc_player_trial_in_use: string;
66
67
  ipc_player_trial_preview_text: string;
67
68
  ipc_player_trial_subscribe: string;
69
+ ipc_player_fetch_error: string;
68
70
  };
69
71
  }, {
70
72
  ipc_player_resolution_HD: string;
@@ -98,6 +100,7 @@ declare const Strings: kit.I18N<{
98
100
  ipc_player_trial_in_use: string;
99
101
  ipc_player_trial_preview_text: string;
100
102
  ipc_player_trial_subscribe: string;
103
+ ipc_player_fetch_error: string;
101
104
  } | {
102
105
  ipc_player_resolution_HD: string;
103
106
  ipc_player_resolution_SD: string;
@@ -130,5 +133,6 @@ declare const Strings: kit.I18N<{
130
133
  ipc_player_trial_in_use: string;
131
134
  ipc_player_trial_preview_text: string;
132
135
  ipc_player_trial_subscribe: string;
136
+ ipc_player_fetch_error: string;
133
137
  }>;
134
138
  export default Strings;
@@ -31,6 +31,7 @@ declare const _default: {
31
31
  ipc_player_trial_in_use: string;
32
32
  ipc_player_trial_preview_text: string;
33
33
  ipc_player_trial_subscribe: string;
34
+ ipc_player_fetch_error: string;
34
35
  };
35
36
  zh: {
36
37
  ipc_player_resolution_HD: string;
@@ -64,6 +65,7 @@ declare const _default: {
64
65
  ipc_player_trial_in_use: string;
65
66
  ipc_player_trial_preview_text: string;
66
67
  ipc_player_trial_subscribe: string;
68
+ ipc_player_fetch_error: string;
67
69
  };
68
70
  };
69
71
  export default _default;
@@ -29,8 +29,9 @@ export default {
29
29
  ipc_player_ptz_moveable_tip_text: 'Hold the middle to drag the direction control area',
30
30
  ipc_player_flow_low_tip: 'The device’s remaining data is below 200MB. Please recharge as soon as possible.',
31
31
  ipc_player_trial_in_use: 'Trial',
32
- ipc_player_trial_preview_text: 'Preview',
33
- ipc_player_trial_subscribe: 'Open'
32
+ ipc_player_trial_preview_text: 'End',
33
+ ipc_player_trial_subscribe: 'Open',
34
+ ipc_player_fetch_error: 'Failed to fetch data'
34
35
  },
35
36
  zh: {
36
37
  ipc_player_resolution_HD: '高清',
@@ -62,7 +63,8 @@ export default {
62
63
  ipc_player_ptz_moveable_tip_text: '长按中间可拖动方向控制区域',
63
64
  ipc_player_flow_low_tip: '设备当前剩余流量不足200M,请尽快充值',
64
65
  ipc_player_trial_in_use: '试用中',
65
- ipc_player_trial_preview_text: '试看剩余',
66
- ipc_player_trial_subscribe: '开通'
66
+ ipc_player_trial_preview_text: '后结束',
67
+ ipc_player_trial_subscribe: '开通',
68
+ ipc_player_fetch_error: '获取异常'
67
69
  }
68
70
  };
@@ -47,20 +47,27 @@ const BottomLeftContent = _ref => {
47
47
  brandColor: ctx.brandColor,
48
48
  bottomLeftContent: ctx.bottomLeftContent
49
49
  });
50
+ const showSmartImageQuality = useMemo(() => {
51
+ var _tryExp$initProps;
52
+ const tryExp = bottomLeftContent === null || bottomLeftContent === void 0 ? void 0 : bottomLeftContent.find(item => item.id === 'TryExperience');
53
+ return !(tryExp !== null && tryExp !== void 0 && (_tryExp$initProps = tryExp.initProps) !== null && _tryExp$initProps !== void 0 && _tryExp$initProps.hideTryExperienceMenu);
54
+ }, [bottomLeftContent]);
50
55
  const trialRemainingSec = useMemo(() => {
51
- var _trialRemainingSec, _tryExp$initProps;
56
+ var _trialRemainingSec, _tryExp$initProps2;
52
57
  const tryExp = bottomLeftContent === null || bottomLeftContent === void 0 ? void 0 : bottomLeftContent.find(item => item.id === 'TryExperience');
53
- return (_trialRemainingSec = tryExp === null || tryExp === void 0 || (_tryExp$initProps = tryExp.initProps) === null || _tryExp$initProps === void 0 ? void 0 : _tryExp$initProps.trialRemainingSec) !== null && _trialRemainingSec !== void 0 ? _trialRemainingSec : 0;
58
+ 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;
59
+ }, [bottomLeftContent]);
60
+ const refreshToken = useMemo(() => {
61
+ var _refreshToken, _tryExp$initProps3;
62
+ const tryExp = bottomLeftContent === null || bottomLeftContent === void 0 ? void 0 : bottomLeftContent.find(item => item.id === 'TryExperience');
63
+ 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;
54
64
  }, [bottomLeftContent]);
55
65
  const [shouldHide] = useComponentHideState();
56
-
57
- // 横竖屏共用同一份徽章状态、回调;TrialBadge 实例不随 screenType 切换而重挂载,
58
- // 倒计时与可见性可在横竖屏切换之间保持一致
59
66
  const {
60
67
  showTrialBadge,
61
68
  handleTrialSubscribe,
62
69
  handleCountdownEnd
63
- } = useTrialBadge(ctx.event, trialRemainingSec);
70
+ } = useTrialBadge(ctx.event, ctx.devId, trialRemainingSec);
64
71
  const paddingLeftPx = screenType === 'vertical' ? 0 : 25;
65
72
  const trialBadgeWrapStyle = screenType === 'vertical' ? TRIAL_BADGE_WRAP_STYLE_VERTICAL : TRIAL_BADGE_WRAP_STYLE_FULL;
66
73
  return /*#__PURE__*/React.createElement(CoverView, {
@@ -72,7 +79,7 @@ const BottomLeftContent = _ref => {
72
79
  right: `${reservedRight}px`,
73
80
  height: screenType === 'vertical' ? shouldHide ? '41px' : '40px' : shouldHide ? '57px' : '58px'
74
81
  }
75
- }, showTrialBadge && /*#__PURE__*/React.createElement(View, {
82
+ }, showSmartImageQuality && showTrialBadge && /*#__PURE__*/React.createElement(View, {
76
83
  className: clsx('bottom-left-item-container'),
77
84
  style: _objectSpread(_objectSpread({}, trialBadgeWrapStyle), {}, {
78
85
  transform: shouldHide ? 'translateY(40px)' : 'translateY(0)',
@@ -82,6 +89,7 @@ const BottomLeftContent = _ref => {
82
89
  }, /*#__PURE__*/React.createElement(TrialBadge, {
83
90
  brandColor: brandColor,
84
91
  trialRemainingSec: trialRemainingSec,
92
+ refreshToken: refreshToken,
85
93
  onSubscribe: handleTrialSubscribe,
86
94
  onCountdownEnd: handleCountdownEnd
87
95
  })), /*#__PURE__*/React.createElement(View, {
package/lib/ui/ui.js CHANGED
@@ -23,6 +23,7 @@ import { Storage } from '../utils/storage';
23
23
  import './ui.less';
24
24
  import { updatePlayerWidgetProps } from '../features';
25
25
  import { isSmallScreen } from '../utils';
26
+ import { getSmartImageQualityState } from '../utils/ttt';
26
27
  function getCtxInstance(instance, devId) {
27
28
  if (instance) return instance;
28
29
  // eslint-disable-next-line react-hooks/rules-of-hooks
@@ -424,6 +425,19 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
424
425
  setBrandColor(brandColor);
425
426
  setVerticalMic(verticalMic);
426
427
  }, [brandColor, verticalMic]);
428
+ const refreshSmartImageQuality = useMemoizedFn(() => {
429
+ getSmartImageQualityState(devId).then(res => {
430
+ console.log('res===getSmartImageQualityState', res);
431
+ updatePlayerWidgetProps(instance, 'bottomLeft', 'TryExperience', {
432
+ buttonState: res.buttonState,
433
+ trialRemainingSec: res.trialRemainingSec,
434
+ refreshToken: Date.now()
435
+ });
436
+ });
437
+ });
438
+ useEffect(() => {
439
+ refreshSmartImageQuality();
440
+ }, [instance]);
427
441
  const refreshBottomLeft = () => {
428
442
  event.current.emit(startTimeToHideAllComponent);
429
443
  event.current.emit(showAllComponent);
@@ -956,7 +970,7 @@ export const IPCPlayerIntegration = /*#__PURE__*/React.memo(props => {
956
970
  style: {
957
971
  height: screenType === 'vertical' ? '48px' : '72px'
958
972
  }
959
- }, /*#__PURE__*/React.createElement(React.Fragment, null, playerReady && /*#__PURE__*/React.createElement(BottomLeftContent, {
973
+ }, /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(BottomLeftContent, {
960
974
  ctx: instance,
961
975
  reservedRight: bottomRightWidth
962
976
  }, renderBottomLeftContent), /*#__PURE__*/React.createElement(BottomRightContent, {
@@ -15,3 +15,5 @@ export declare const promisify: <TParams extends Record<string, any>, TSuccessRe
15
15
  complete?: (() => void) | undefined;
16
16
  }) => void) => (params: Omit<TParams, "complete" | "success" | "fail">) => Promise<TSuccessResult>;
17
17
  export * from './videoSplitHelper';
18
+ export * from './navigation';
19
+ export * from './ttt';
@@ -47,4 +47,6 @@ export const promisify = apiFunction => {
47
47
  });
48
48
  };
49
49
  };
50
- export * from './videoSplitHelper';
50
+ export * from './videoSplitHelper';
51
+ export * from './navigation';
52
+ export * from './ttt';
@@ -0,0 +1,6 @@
1
+ export declare const miniIdLabs: {
2
+ aiDrawMini: string;
3
+ securityCloudService: string;
4
+ };
5
+ export declare function gotoAIDrawMiniProgram(devId: string, brandColor: string): void;
6
+ export declare function gotoSecurityCloudService(homeId: string, uuid: string): Promise<void>;
@@ -0,0 +1,20 @@
1
+ import { goToMiniProgramByShortLink } from '@ray-js/ray-ipc-utils';
2
+ import Color from 'color';
3
+
4
+ // 小程序ID集合
5
+ export const miniIdLabs = {
6
+ // ai智能画质
7
+ aiDrawMini: 'tyjo8cvir22cc0yech',
8
+ // security_cloud_service, 增值服务商城小程序ID
9
+ securityCloudService: 'tyeavwo0j4oocvdrf1'
10
+ };
11
+ export function gotoAIDrawMiniProgram(devId, brandColor) {
12
+ const color = new Color(brandColor);
13
+ const rgbColor = color.rgb().toString();
14
+ const url = `godzilla://${miniIdLabs.aiDrawMini}${'/pages/home/index'}?deviceId=${devId}&themeColor=${rgbColor}`;
15
+ goToMiniProgramByShortLink(url, 'right');
16
+ }
17
+ export async function gotoSecurityCloudService(homeId, uuid) {
18
+ const url = `godzilla://${miniIdLabs.securityCloudService}${'/pages/serviceList/index'}?homeId=${homeId}&deviceId=${uuid}&categoryCode=${'security_cloud_service'}`;
19
+ goToMiniProgramByShortLink(url, 'right');
20
+ }
@@ -0,0 +1,39 @@
1
+ export type SmartImageQualityResult = {
2
+ isPurchase: boolean;
3
+ buttonState: number;
4
+ trialRemainingSec: number;
5
+ canOpenSettings: boolean;
6
+ };
7
+ export declare function getSmartImageQualityState(devId: string): Promise<SmartImageQualityResult>;
8
+ export type AIFrameFeatureScope = {
9
+ inPreview: boolean;
10
+ inMessage: boolean;
11
+ inPlayback: boolean;
12
+ inCloudData: boolean;
13
+ };
14
+ export type AIFrameFeatureDetail = {
15
+ srModelStatus: number;
16
+ lightModelStatus: number;
17
+ filterStatus: number;
18
+ };
19
+ export type AIFrameFeatureConfig = {
20
+ scope: AIFrameFeatureScope;
21
+ feature: AIFrameFeatureDetail;
22
+ exportEnabled: boolean;
23
+ };
24
+ export type SetAIFrameFeatureParams = {
25
+ devId: string;
26
+ enabled: boolean;
27
+ aiFrameFeature: AIFrameFeatureConfig;
28
+ };
29
+ export type GetAIFrameFeatureResult = {
30
+ enabled: boolean;
31
+ aiFrameFeature: AIFrameFeatureConfig;
32
+ requestId: string;
33
+ localPath: string;
34
+ thingFileUri: string;
35
+ };
36
+ export declare function getAIFrameFeature(devId: string): Promise<GetAIFrameFeatureResult>;
37
+ export declare function setAIFrameFeature(devId: string, params: Omit<SetAIFrameFeatureParams, 'devId'>): Promise<any>;
38
+ export declare function getDeviceInfoRay(devId: string): Promise<unknown>;
39
+ export declare function getCurrentHomeInfoRay(): Promise<unknown>;
@@ -0,0 +1,87 @@
1
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
+ export function getSmartImageQualityState(devId) {
3
+ // const mockData: SmartImageQualityResult = {
4
+ // isPurchase: false,
5
+ // buttonState: 1,
6
+ // trialRemainingSec: 200,
7
+ // canOpenSettings: false,
8
+ // };
9
+ // if (typeof ty?.ipc?.getSmartImageQualityState !== 'function') {
10
+ // console.log('res===getSmartImageQualityState not exist, use mockData', mockData);
11
+ // return Promise.resolve(mockData);
12
+ // }
13
+ return new Promise((resolve, reject) => {
14
+ ty.ipc.getSmartImageQualityState({
15
+ params: {
16
+ devId
17
+ },
18
+ success: data => {
19
+ console.log('res===getSmartImageQualityState data', data);
20
+ resolve(data);
21
+ },
22
+ fail: e => {
23
+ console.warn('res===getSmartImageQualityState fail', e);
24
+ reject(e);
25
+ }
26
+ });
27
+ });
28
+ }
29
+ export function getAIFrameFeature(devId) {
30
+ return new Promise((resolve, reject) => {
31
+ ty.ipc.getAIFrameFeature({
32
+ params: {
33
+ devId
34
+ },
35
+ success: data => {
36
+ console.log('res===getAIFrameFeature data', data);
37
+ resolve(data);
38
+ },
39
+ fail: e => {
40
+ console.warn('res===getAIFrameFeature fail', e);
41
+ reject(e);
42
+ }
43
+ });
44
+ });
45
+ }
46
+ export function setAIFrameFeature(devId, params) {
47
+ return new Promise((resolve, reject) => {
48
+ ty.ipc.setAIFrameFeature({
49
+ params: _objectSpread({
50
+ devId
51
+ }, params),
52
+ success: data => {
53
+ console.log('res===setAIFrameFeature data', data);
54
+ resolve(data);
55
+ },
56
+ fail: e => {
57
+ console.warn('res===setAIFrameFeature fail', e);
58
+ reject(e);
59
+ }
60
+ });
61
+ });
62
+ }
63
+ export function getDeviceInfoRay(devId) {
64
+ return new Promise((resolve, reject) => {
65
+ ty.device.getDeviceInfo({
66
+ deviceId: devId,
67
+ success: res => {
68
+ resolve(res);
69
+ },
70
+ fail: error => {
71
+ reject(error);
72
+ }
73
+ });
74
+ });
75
+ }
76
+ export function getCurrentHomeInfoRay() {
77
+ return new Promise((resolve, reject) => {
78
+ ty.home.getCurrentHomeInfo({
79
+ success: res => {
80
+ resolve(res);
81
+ },
82
+ fail: error => {
83
+ reject(error);
84
+ }
85
+ });
86
+ });
87
+ }
@@ -6,10 +6,12 @@ type Props = {
6
6
  brandColor?: string;
7
7
  /** 试看倒计时初始秒数,来源于 smartImageQualityState.trialRemainingSec */
8
8
  trialRemainingSec?: number;
9
+ /** 刷新令牌,变化时重置倒计时状态 */
10
+ refreshToken?: number;
9
11
  /** 点击「开通」按钮回调 */
10
12
  onSubscribe?: () => void;
11
13
  /** 倒计时归零时触发,本组件保证整个生命周期内只回调一次 */
12
14
  onCountdownEnd?: () => void;
13
15
  };
14
- export declare const TrialBadge: ({ className, brandColor, trialRemainingSec, onSubscribe, onCountdownEnd, }: Props) => React.JSX.Element;
16
+ export declare const TrialBadge: ({ className, brandColor, trialRemainingSec, refreshToken, onSubscribe, onCountdownEnd, }: Props) => React.JSX.Element;
15
17
  export { useTrialBadge } from './useTrialBadge';
@@ -18,6 +18,7 @@ export const TrialBadge = _ref => {
18
18
  className,
19
19
  brandColor = FALLBACK_BRAND_COLOR,
20
20
  trialRemainingSec = 0,
21
+ refreshToken,
21
22
  onSubscribe,
22
23
  onCountdownEnd
23
24
  } = _ref;
@@ -27,8 +28,9 @@ export const TrialBadge = _ref => {
27
28
  const onCountdownEndRef = useRef(onCountdownEnd);
28
29
  onCountdownEndRef.current = onCountdownEnd;
29
30
  useEffect(() => {
31
+ endedRef.current = false;
30
32
  setRemainingSec(Math.max(0, Math.floor(trialRemainingSec)));
31
- }, [trialRemainingSec]);
33
+ }, [trialRemainingSec, refreshToken]);
32
34
  useEffect(() => {
33
35
  if (remainingSec <= 0) {
34
36
  if (!endedRef.current) {
@@ -54,7 +56,7 @@ export const TrialBadge = _ref => {
54
56
  });
55
57
  }, 1000);
56
58
  return () => clearInterval(timer);
57
- }, [trialRemainingSec]);
59
+ }, [trialRemainingSec, refreshToken]);
58
60
  const countdownText = formatCountdown(remainingSec);
59
61
  return /*#__PURE__*/React.createElement(View, {
60
62
  className: clsx('ipc-player-trial-badge', className)
@@ -68,7 +70,7 @@ export const TrialBadge = _ref => {
68
70
  className: "ipc-player-trial-badge-divider"
69
71
  }, "|"), /*#__PURE__*/React.createElement(Text, {
70
72
  className: "ipc-player-trial-badge-preview"
71
- }, `${Strings.getLang('ipc_player_trial_preview_text')} ${countdownText}`), /*#__PURE__*/React.createElement(View, {
73
+ }, `${countdownText} ${Strings.getLang('ipc_player_trial_preview_text')}`), /*#__PURE__*/React.createElement(View, {
72
74
  className: "ipc-player-trial-badge-cta",
73
75
  style: {
74
76
  backgroundColor: brandColor
@@ -1,16 +1,8 @@
1
1
  /// <reference types="react" />
2
2
  import type { EventInstance } from '../../interface';
3
- /**
4
- * 试用徽章共享 Hook:vertical / full 两种 screenType 下共用同一份状态、回调和方法。
5
- *
6
- * - `showTrialBadge`:是否展示徽章;仅当 0 < trialRemainingSec < 300 时展示,倒计时归零会自动置 false。
7
- * - `handleTrialSubscribe`:「开通」按钮点击回调。
8
- * - `handleCountdownEnd`:倒计时归零回调,内部会广播 `trialCountdownEnd`
9
- * 事件给其它控件(例如 TryExperience)刷新自身状态。
10
- */
11
- export declare const useTrialBadge: (event: EventInstance, trialRemainingSec: number) => {
3
+ export declare const useTrialBadge: (event: EventInstance, devId: string, trialRemainingSec: number) => {
12
4
  showTrialBadge: boolean;
13
5
  setShowTrialBadge: import("react").Dispatch<import("react").SetStateAction<boolean>>;
14
- handleTrialSubscribe: () => void;
15
- handleCountdownEnd: () => void;
6
+ handleTrialSubscribe: () => Promise<void>;
7
+ handleCountdownEnd: () => Promise<void>;
16
8
  };
@@ -1,37 +1,44 @@
1
1
  import { useCallback, useEffect, useState } from 'react';
2
- import { trialCountdownEnd } from '../../ui/constant';
3
-
4
- /**
5
- * 试看倒计时归零后的业务 hook 点(mock)。
6
- * 后续接入业务校验 / 上报时替换该实现。横竖屏共用同一份逻辑。
7
- */
8
- const trialEndedTest = () => {
9
- console.log('res===[TrialBadge] countdown end -> test()');
10
- };
11
-
12
- /**
13
- * 试用徽章共享 Hook:vertical / full 两种 screenType 下共用同一份状态、回调和方法。
14
- *
15
- * - `showTrialBadge`:是否展示徽章;仅当 0 < trialRemainingSec < 300 时展示,倒计时归零会自动置 false。
16
- * - `handleTrialSubscribe`:「开通」按钮点击回调。
17
- * - `handleCountdownEnd`:倒计时归零回调,内部会广播 `trialCountdownEnd`
18
- * 事件给其它控件(例如 TryExperience)刷新自身状态。
19
- */
20
- export const useTrialBadge = (event, trialRemainingSec) => {
2
+ import { getAIFrameFeature, getCurrentHomeInfoRay, getDeviceInfoRay, setAIFrameFeature } from '../../utils/ttt';
3
+ import { gotoSecurityCloudService } from '../../utils';
4
+ import Strings from '../../i18n';
5
+ export const useTrialBadge = (event, devId, trialRemainingSec) => {
21
6
  const [showTrialBadge, setShowTrialBadge] = useState(false);
22
7
  useEffect(() => {
23
8
  if (trialRemainingSec > 0 && trialRemainingSec < 300) {
24
9
  setShowTrialBadge(true);
25
10
  }
26
11
  }, [trialRemainingSec]);
27
- const handleTrialSubscribe = useCallback(() => {
28
- console.log('[TrialBadge] click subscribe');
29
- }, []);
30
- const handleCountdownEnd = useCallback(() => {
31
- trialEndedTest();
32
- event.emit(trialCountdownEnd);
33
- setShowTrialBadge(false);
34
- }, [event]);
12
+ const handleTrialSubscribe = useCallback(async () => {
13
+ try {
14
+ const homeInfo = await getCurrentHomeInfoRay();
15
+ const deviceInfo = await getDeviceInfoRay(devId);
16
+ console.log('res===', deviceInfo, homeInfo);
17
+ gotoSecurityCloudService(homeInfo.homeId, deviceInfo.uuid);
18
+ } catch (error) {
19
+ console.log('res===handleTrialSubscribe error', error);
20
+ ty.showToast({
21
+ title: Strings.getLang('ipc_player_fetch_error'),
22
+ icon: 'none'
23
+ });
24
+ }
25
+ }, [devId]);
26
+ const handleCountdownEnd = useCallback(async () => {
27
+ try {
28
+ const getAI = await getAIFrameFeature(devId);
29
+ console.log('res===handleCountdownEnd', getAI);
30
+ setAIFrameFeature(devId, {
31
+ enabled: false,
32
+ aiFrameFeature: getAI.aiFrameFeature
33
+ });
34
+ setShowTrialBadge(false);
35
+ } catch (error) {
36
+ ty.showToast({
37
+ title: Strings.getLang('ipc_player_fetch_error'),
38
+ icon: 'none'
39
+ });
40
+ }
41
+ }, [devId, event]);
35
42
  return {
36
43
  showTrialBadge,
37
44
  setShowTrialBadge,
@@ -1,8 +1,8 @@
1
1
  import { View, Image, getSystemInfoSync } from '@ray-js/ray';
2
2
  import clsx from 'clsx';
3
- import React, { useContext } from 'react';
4
- import { pauseTimeToHideAllComponent, widgetClick, widgetLabs, tryExperienceBtnClick } from '../../ui/constant';
5
- import { UIEventContext } from '../../ui/context';
3
+ import React from 'react';
4
+ import { useStore } from '../../ctx/store';
5
+ import { gotoAIDrawMiniProgram } from '../../utils';
6
6
  import tryZh from '../../res/try/try_zh.png';
7
7
  import tryEn from '../../res/try/try_en.png';
8
8
  import tryOpen from '../../res/try/try_open.png';
@@ -41,13 +41,13 @@ export const TryExperience = props => {
41
41
  const {
42
42
  className,
43
43
  hideTryExperienceMenu,
44
- buttonState = 0,
45
- event: propsEvent
44
+ buttonState = 0
46
45
  } = props;
47
46
  const {
48
- event: ctxEvent
49
- } = useContext(UIEventContext);
50
- const event = propsEvent !== null && propsEvent !== void 0 ? propsEvent : ctxEvent;
47
+ brandColor
48
+ } = useStore({
49
+ brandColor: props.brandColor
50
+ });
51
51
  const iconUrl = pickIconByStatus(buttonState);
52
52
  if (hideTryExperienceMenu) {
53
53
  return null;
@@ -55,11 +55,8 @@ export const TryExperience = props => {
55
55
  return /*#__PURE__*/React.createElement(View, {
56
56
  className: clsx(className),
57
57
  onClick: () => {
58
- event.emit(widgetClick, {
59
- widgetId: widgetLabs.TRY_EXPERIENCE
60
- });
61
- event.emit(tryExperienceBtnClick);
62
- event.emit(pauseTimeToHideAllComponent);
58
+ console.log('res===onTryExperience', props.devId, brandColor);
59
+ gotoAIDrawMiniProgram(props.devId, brandColor);
63
60
  }
64
61
  }, /*#__PURE__*/React.createElement(View, {
65
62
  className: "try-experience-box"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/ipc-player-integration",
3
- "version": "0.0.35-beta.2",
3
+ "version": "0.0.35-beta.3",
4
4
  "description": "IPC 融合播放器",
5
5
  "main": "lib/index",
6
6
  "files": [