ipanel-rnapp-ajb-base 1.0.44 → 1.0.45

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.
Files changed (109) hide show
  1. package/app/.local_dev/polyfill.js +31 -25
  2. package/app/App.js +123 -22
  3. package/app/api/ipanelCloudApi.js +81 -12
  4. package/app/assets/img/bent_voice_record_btn_default.png +0 -0
  5. package/app/assets/img/bent_voice_record_btn_focus.png +0 -0
  6. package/app/assets/img/emoji_talk_icon.png +0 -0
  7. package/app/assets/img/more_feature_area_icon.png +0 -0
  8. package/app/assets/img/profile_icon.png +0 -0
  9. package/app/assets/img/switch_keyboard_icon.png +0 -0
  10. package/app/assets/img/switch_voice_icon.png +0 -0
  11. package/app/assets/img/voice_wave2.gif +0 -0
  12. package/app/base.js +408 -103
  13. package/app/components/common/ActionPicker/index.js +14 -14
  14. package/app/components/common/AddressPicker/index.js +5 -5
  15. package/app/components/common/Cell/index.js +2 -2
  16. package/app/components/common/CustomTabBar/index.js +33 -31
  17. package/app/components/common/Dialog/baseDialog.js +1 -1
  18. package/app/components/common/Dialog/prompt.js +33 -30
  19. package/app/components/common/Dialog/select.js +19 -15
  20. package/app/components/common/FamilyProfile/index.js +1281 -0
  21. package/app/components/common/ModalView/ModalProvider.js +89 -0
  22. package/app/components/common/ModalView/index.js +160 -0
  23. package/app/components/common/PickerV1/index.js +92 -79
  24. package/app/components/common/PickerV2/index.js +113 -86
  25. package/app/components/common/PickerV2Base/_util/devWarning.tsx +4 -2
  26. package/app/components/common/PickerV2Base/picker/Picker.tsx +86 -84
  27. package/app/components/common/ScreenBackHeader/index.js +2 -2
  28. package/app/components/common/SelectPicker/index.js +24 -23
  29. package/app/components/common/SheetManage/index.js +63 -60
  30. package/app/components/index.js +2 -1
  31. package/app/components/iot/AddDeviceActionSheet/index.js +191 -187
  32. package/app/components/iot/RoomActionSheet/index.js +54 -54
  33. package/app/components/iot/ViewDeviceActionSheet/index.js +14 -14
  34. package/app/eventBus/index.js +1 -0
  35. package/app/hooks/checkLogin.js +35 -7
  36. package/app/hooks/shopMessageManager.js +45 -38
  37. package/app/hooks/useAddress.js +42 -42
  38. package/app/hooks/useAddress2.js +89 -89
  39. package/app/hooks/useKeyboard.js +6 -6
  40. package/app/hooks/useMessageManager.js +454 -80
  41. package/app/hooks/useMessageManager_Design.md +397 -0
  42. package/app/hooks/useStreamingText.js +67 -119
  43. package/app/screens/BaseScreen.js +79 -40
  44. package/app/screens/ChatModeScreen/ChatTemplates/ActionPrompt/index.js +41 -40
  45. package/app/screens/ChatModeScreen/ChatTemplates/DeviceFaq/index.js +35 -33
  46. package/app/screens/ChatModeScreen/ChatTemplates/DeviceStatus/index.js +97 -87
  47. package/app/screens/ChatModeScreen/ChatTemplates/Link/index.js +120 -45
  48. package/app/screens/ChatModeScreen/ChatTemplates/SceneReport/index.js +108 -100
  49. package/app/screens/ChatModeScreen/ChatTemplates/SportHealthReport/index.js +42 -36
  50. package/app/screens/ChatModeScreen/ChatTemplates/index.js +25 -23
  51. package/app/screens/ChatModeScreen/chat/MyChat.js +185 -104
  52. package/app/screens/ChatModeScreen/components/ChatHeader/index.js +118 -0
  53. package/app/screens/ChatModeScreen/components/ChatInputBar/TabBarInput.js +94 -66
  54. package/app/screens/ChatModeScreen/components/ChatInputBar/index.js +564 -229
  55. package/app/screens/ChatModeScreen/components/ChatInputBar/index_bak.js +1238 -0
  56. package/app/screens/ChatModeScreen/components/ChatMessage/index.js +157 -121
  57. package/app/screens/ChatModeScreen/components/DrawerMenu/index.js +223 -0
  58. package/app/screens/ChatModeScreen/components/EditableText/index.js +82 -33
  59. package/app/screens/ChatModeScreen/components/ErrorBoundary/index.js +20 -20
  60. package/app/screens/ChatModeScreen/components/FunASRClient.js +609 -0
  61. package/app/screens/ChatModeScreen/components/SimpleProfileScreen.js +377 -13
  62. package/app/screens/ChatModeScreen/components/{IncrementalMarkdownText → StaticMarkdownText}/index.js +59 -195
  63. package/app/screens/ChatModeScreen/components/ToolCallIndicator/index.js +166 -0
  64. package/app/screens/ChatModeScreen/components/VoiceRecognitionManager.js +755 -0
  65. package/app/screens/ChatModeScreen/index.js +115 -72
  66. package/app/screens/CommonScreens/BossScreen/index.js +19 -19
  67. package/app/screens/CommonScreens/DeviceFeedbackScreen/index.js +7 -7
  68. package/app/screens/CommonScreens/EditInvoiceTitleScreen/index.js +122 -115
  69. package/app/screens/CommonScreens/FamilyDetailScreen/index.js +88 -83
  70. package/app/screens/CommonScreens/HomedLoginScreen/index.js +22 -15
  71. package/app/screens/CommonScreens/OperatorSelectScreen/index.js +115 -99
  72. package/app/screens/CommonScreens/PersonalScreen/index.js +71 -70
  73. package/app/screens/CommonScreens/ScanQRCodeScreen/index.js +7 -7
  74. package/app/screens/CommonScreens/TvAlbumScreen/index.js +105 -97
  75. package/app/screens/LoginScreen/GraphSmscode.js +98 -81
  76. package/app/screens/LoginScreen/OpenLogSheet.js +51 -47
  77. package/app/screens/LoginScreen/index.js +59 -30
  78. package/app/screens/LoginScreen/indexEdu.js +254 -236
  79. package/app/screens/LoginScreen/indexSbk.js +14 -10
  80. package/app/screens/RegisteCountScreen/index.js +20 -20
  81. package/app/screens/ResePassword/index.js +84 -77
  82. package/app/screens/SbkScreen.js +2 -2
  83. package/app/screens/SimpleBaseScreen.js +56 -52
  84. package/app/sdApp/auth.js +149 -0
  85. package/app/sdApp/config.js +106 -0
  86. package/app/sdApp/index.js +150 -0
  87. package/app/sdApp/operator.js +73 -0
  88. package/app/sdApp/request.js +176 -0
  89. package/app/sdApp/socket.js +912 -0
  90. package/app/sdApp/token.js +295 -0
  91. package/app/utils/JPushService.js +207 -0
  92. package/app/utils/SBK_plugin/eventProcess.js +46 -41
  93. package/app/utils/SBK_plugin/ipanelDeviceToSbkDevice.js +11 -11
  94. package/app/utils/appLinkHandler.js +127 -0
  95. package/app/utils/applyPermissions.js +59 -51
  96. package/app/utils/bundleUpdater.js +11 -11
  97. package/app/utils/chatMessageParser.js +133 -0
  98. package/app/utils/common.js +170 -114
  99. package/app/utils/config.js +16 -4
  100. package/app/utils/http.js +14 -9
  101. package/app/utils/logger.js +11 -0
  102. package/app/utils/navigationPackageUtils.js +67 -27
  103. package/app/utils/scaleSize.js +9 -3
  104. package/app/utils/soundPlayer.js +12 -12
  105. package/app/utils/timeFormatter.js +43 -0
  106. package/package.json +1 -1
  107. package/app/components/common/CustomTabBar_bak/TabBarInput.js +0 -210
  108. package/app/components/common/CustomTabBar_bak/index.js +0 -832
  109. package/app/screens/LoginScreen/indexNew.js +0 -1917
@@ -1,5 +1,5 @@
1
- import React from 'react';
2
- import {AppRegistry, NativeModules, View, Text} from 'react-native';
1
+ import React from "react";
2
+ import { AppRegistry, NativeModules, View, Text } from "react-native";
3
3
 
4
4
  // isMultiBundle:是否为分包加载方式(不是的话就是不分包方式,用于本地调试)
5
5
  const isLocalDev = !NativeModules.RNToNativeEmitter?.isMultiBundle;
@@ -12,38 +12,44 @@ async function getRemoteComponentByName(componentName) {
12
12
  try {
13
13
  // 用于本地开发测试,每加一个业务包这里都需要加一下
14
14
  switch (componentName) {
15
- case 'tvShare':
16
- return (await import('../../app_tvShare/App.js')).default;
17
- case 'smartHome':
18
- return (await import('../../app_smartHome/App.js')).default;
19
- case 'shop':
20
- return (await import('../../app_shop/App.js')).default;
21
- case 'panYuGovData':
22
- return (await import('../../app_panYuGovData/App.js')).default;
23
- case 'myProfile':
24
- return (await import('../../app_myProfile/App.js')).default;
25
- case 'adg':
26
- return (await import('../../app_adg/App.js')).default;
27
- case 'orderFood':
28
- return (await import('../../app_orderFood/App.js')).default;
29
- case 'apartment':
30
- return (await import('../../app_apartment/App.js')).default;
31
- case 'jinpeng':
32
- return (await import('../../app_jinpeng/App.js')).default;
15
+ case "tvShare":
16
+ return (await import("../../app_tvShare/App.js")).default;
17
+ case "smartHome":
18
+ return (await import("../../app_smartHome/App.js")).default;
19
+ case "shop":
20
+ return (await import("../../app_shop/App.js")).default;
21
+ case "panYuGovData":
22
+ return (await import("../../app_panYuGovData/App.js")).default;
23
+ case "myProfile":
24
+ return (await import("../../app_myProfile/App.js")).default;
25
+ case "adg":
26
+ return (await import("../../app_adg/App.js")).default;
27
+ case "orderFood":
28
+ return (await import("../../app_orderFood/App.js")).default;
29
+ case "apartment":
30
+ return (await import("../../app_apartment/App.js")).default;
31
+ case "jinpeng":
32
+ return (await import("../../app_jinpeng/App.js")).default;
33
+ // 山东享TV(整包里平铺的 app_shandongXxx,对应各业务仓的 app/ 目录)
34
+ case 'shandongHome':
35
+ return (await import('../../app_shandongHome/App.js')).default;
36
+ case 'shandongMyProfile':
37
+ return (await import('../../app_shandongMyProfile/App.js')).default;
33
38
  // __BASE_SINGLETON_MODE_APP__
34
39
  default:
35
40
  return () => {
36
41
  return (
37
- <View>
38
- <Text>__BASE_SINGLETON_MODE_APP__</Text>
39
- </View>)
42
+ <View>
43
+ <Text>__BASE_SINGLETON_MODE_APP__</Text>
44
+ </View>
45
+ );
40
46
  };
41
47
  }
42
48
  } catch (e) {
43
- console.log(componentName, e);
49
+ global.base.logger.info("component error", { componentName, error: e });
44
50
  return false;
45
51
  }
46
52
  }
47
53
  }
48
54
 
49
- export {getRemoteComponentByName};
55
+ export { getRemoteComponentByName };
package/app/App.js CHANGED
@@ -11,6 +11,7 @@ import {
11
11
  AppState,
12
12
  NativeEventEmitter,
13
13
  DeviceEventEmitter,
14
+ Linking,
14
15
  } from "react-native";
15
16
  import { NavigationContainer } from "@react-navigation/native";
16
17
  import { createStackNavigator } from "@react-navigation/stack";
@@ -40,12 +41,15 @@ import storage from "./storage";
40
41
 
41
42
  import { navigationRef } from "./utils/RootNavigation";
42
43
  import checkLogin from "./hooks/checkLogin";
44
+ import { isShandongApp } from "./sdApp/config";
43
45
  import {
44
46
  getModuleVersionInfo,
45
47
  getUserInfo,
46
48
  delThirdId,
49
+ deviceReportThird,
47
50
  } from "./api/ipanelCloudApi";
48
51
  import { appReport } from "./utils/common";
52
+ import JPushService from "./utils/JPushService";
49
53
 
50
54
  // 基础导航页、登录页
51
55
  import BaseScreen from "./screens/BaseScreen";
@@ -117,6 +121,8 @@ const envVersion = NativeModules?.RNToNativeEmitter?.serverCluster || "alpha";
117
121
 
118
122
  const appName = NativeModules?.RNToNativeEmitter?.appName;
119
123
 
124
+ const JPushModule = NativeModules.JPushModule;
125
+
120
126
  let eventEmitter;
121
127
  if (Platform.OS === "android") {
122
128
  // ----yusm:安卓使用DeviceEventEmitter
@@ -301,7 +307,7 @@ global.base.initialNavigationPackages = initialNavigationPackages;
301
307
  // const packages = await global.base.storage.get('base.navigationPackages');
302
308
  // if (packages) {
303
309
  // global.base.navigationPackages = packages;
304
- // console.log('成功从本地读取上一次的底部导航模块,flag=', flag);
310
+ // global.base.logger.info('成功从本地读取上一次的底部导航模块,flag=', flag);
305
311
  // }
306
312
  // };
307
313
  // updateNavigationPackagesFromStorage(1);
@@ -323,9 +329,80 @@ const App = () => {
323
329
 
324
330
  const [isKeyboardVisible, setIsKeyboardVisible] = useState(false);
325
331
 
332
+ // 用于跟踪应用状态变化,只在从后台进入前台时上报
333
+ const [previousAppState, setPreviousAppState] = useState(
334
+ AppState.currentState,
335
+ );
336
+
326
337
  // 更新global.base
327
338
  global.base.DynamicStackScreens = DynamicStackScreens;
328
339
 
340
+ // 处理扫码启动的URL跳转 - 支持冷启动和事件监听
341
+ useEffect(() => {
342
+ // 添加URL事件监听器(冷/热启动时都会通过事件或onReady接收URL)
343
+ const subscription = Linking.addEventListener("url", (event) => {
344
+ global.base.logger.info("URL event received:", event);
345
+ global.base.parseURLAndSetRedirectParams(event.url, "event");
346
+ });
347
+
348
+ // 清理订阅
349
+ return () => {
350
+ subscription?.remove();
351
+ };
352
+ }, []);
353
+
354
+ // 检查并上报极光RegistrationID
355
+ const checkJPush = async (registrationIdEvent) => {
356
+ try {
357
+ if (appName === "遥控键码库") return;
358
+
359
+ // registrationIdEvent 可能是直接的ID字符串(iOS回调) 或 对象(Android回调)
360
+ // 如果是通过 addConnectListener 回调过来的,我们约定传的是 ID 字符串
361
+ const rid =
362
+ typeof registrationIdEvent === "string"
363
+ ? registrationIdEvent
364
+ : registrationIdEvent?.registerID || registrationIdEvent;
365
+ if (!rid) {
366
+ // 如果没有 ID,可能需要主动获取(兼容旧逻辑,但一般通过监听器过来都会有ID)
367
+ return;
368
+ }
369
+ global.base.logger.info("checkJPush with ID:", rid);
370
+ // 检查登录状态
371
+ const accountType = await storage.get("accountType");
372
+ const token = await storage.get(
373
+ accountType === "adg" ? "adgAccessToken" : "accessToken",
374
+ );
375
+
376
+ if (token) {
377
+ // 获取用户信息确认有效性
378
+ const accountData = await storage.get("accountData");
379
+ // const activeAddr = await storage.get('activeAddr');
380
+ const res = await getUserInfo();
381
+ const userList = res.result?.user_list || [];
382
+ const currentUser = userList.find(
383
+ (item) => item.user_id === accountData?.user.user_id,
384
+ );
385
+ const bindList = currentUser?.bind_list || [];
386
+ const jpushBindId = bindList.find(
387
+ (item) => item.third_type === "jpush",
388
+ )?.third_id;
389
+
390
+ if (rid !== jpushBindId) {
391
+ // 上报RegistrationID
392
+ await deviceReportThird({
393
+ third_type: "jpush",
394
+ third_id: rid,
395
+ user_id: currentUser?.user_id,
396
+ }).catch((e) => console.log("JPush report failed", e));
397
+ } else {
398
+ global.base.logger.info("JPush ID already bound:", rid);
399
+ }
400
+ }
401
+ } catch (error) {
402
+ global.base.logger.info("checkJPush error", error);
403
+ }
404
+ };
405
+
329
406
  // mounted
330
407
  useEffect(() => {
331
408
  if (Platform.OS === "android") {
@@ -336,6 +413,11 @@ const App = () => {
336
413
  global.base.accountType = res || "ajb";
337
414
  });
338
415
 
416
+ // 在App.js这里尽可能早地加载聊天输入类型设置,避免聊天输入框的闪动
417
+ storage.get("base.chatInputType").then((res) => {
418
+ global.base.chatInputType = res || "voice";
419
+ });
420
+
339
421
  const rnToNative = NativeModules.RNToNativeEmitter;
340
422
  // 应用通知app可正常显示,页面正常运行了,在componentDidMount 中加
341
423
  rnToNative?.notifyApplicationReady({
@@ -347,59 +429,73 @@ const App = () => {
347
429
  checkLogin();
348
430
  }
349
431
 
432
+ // 注册连接监听 (需要在 init 之前注册,防止 init 过快导致错过事件)
433
+ const removeConnectListener = JPushService.addConnectListener(checkJPush);
434
+ // 初始化极光推送
435
+ JPushService.init();
436
+
350
437
  // 获取最新版本并通知原生平台,由平台判断后弹出升级确认提示
351
438
  checkBaseVersion();
352
439
 
353
440
  AppState.addEventListener("change", async (nextAppState) => {
354
- console.log("nextAppState", nextAppState);
355
- if (nextAppState === "active") {
356
- appReport("APP_STARTUP");
441
+ global.base.logger.info("AppState change", {
442
+ previousAppState,
443
+ nextAppState,
444
+ });
445
+
446
+ // 只有当从后台状态进入前台时才上报,避免APP启动时的误触发
447
+ if (previousAppState === "background" && nextAppState === "active") {
448
+ global.base.logger.info("[appReport] by AppState active");
449
+ appReport("APP_STARTUP", {
450
+ location: "热启动",
451
+ });
357
452
  }
453
+ setPreviousAppState(nextAppState);
358
454
  });
359
455
 
360
456
  const keyboardDidShowListener = Keyboard.addListener(
361
457
  "keyboardDidShow",
362
458
  () => {
363
459
  setIsKeyboardVisible(true);
364
- }
460
+ },
365
461
  );
366
462
 
367
463
  const keyboardDidHideListener = Keyboard.addListener(
368
464
  "keyboardDidHide",
369
465
  () => {
370
466
  setIsKeyboardVisible(false);
371
- }
467
+ },
372
468
  );
373
469
 
374
470
  const cellularDataStateListener = eventEmitter.addListener(
375
471
  "CellularDataState",
376
472
  (data) => {
377
- console.log(JSON.stringify(data), "CellularDataState");
473
+ global.base.logger.info("CellularDataState", data);
378
474
  if (data?.state && data?.state !== 0) {
379
475
  checkBaseVersion();
380
476
  }
381
- }
477
+ },
382
478
  );
383
479
 
384
480
  const homedLogOutListener = DeviceEventEmitter.addListener(
385
481
  "HomedLogout",
386
482
  async (data) => {
387
- console.log("HomedLogout", data);
483
+ global.base.logger.info("HomedLogout", data);
388
484
 
389
485
  const accountData = await storage.get("accountData");
390
486
  // const activeAddr = await storage.get('activeAddr');
391
487
  const res = await getUserInfo();
392
- console.log(res, "HomedLogout getUserInfo");
488
+ global.base.logger.info("HomedLogout getUserInfo", res);
393
489
  const userList = res.result?.user_list || [];
394
490
  const currentUser = userList.find(
395
- (item) => item.user_id === accountData?.user.user_id
491
+ (item) => item.user_id === accountData?.user.user_id,
396
492
  );
397
493
  const bindList = currentUser?.bind_list || [];
398
- console.log(bindList, "HomedLogout bindList");
494
+ global.base.logger.info("HomedLogout bindList", bindList);
399
495
  const homedConfig = bindList.find(
400
- (item) => item.third_type === "homed"
496
+ (item) => item.third_type === "homed",
401
497
  );
402
- console.log("homedConfig", homedConfig);
498
+ global.base.logger.info("homedConfig", homedConfig);
403
499
 
404
500
  if (homedConfig) {
405
501
  // 解绑当前cloud用户对应的homed用户
@@ -408,10 +504,10 @@ const App = () => {
408
504
  third_id: homedConfig.third_id,
409
505
  user_id: homedConfig.user_id,
410
506
  }).catch((err) => {
411
- console.error(err);
507
+ global.base.logger.error("delThirdId failed", err);
412
508
  });
413
509
  if (!result || result.code !== 0) {
414
- console.error("解绑homed用户失败:", result);
510
+ global.base.logger.error("解绑homed用户失败:", result);
415
511
  global.toast.showToast("解绑电视用户失败");
416
512
  return;
417
513
  }
@@ -419,10 +515,10 @@ const App = () => {
419
515
  await storage.remove("homedAccessToken");
420
516
  await storage.remove("HomedLoginResult");
421
517
  } else {
422
- console.log("当前未绑定homed用户");
518
+ global.base.logger.info("当前未绑定homed用户");
423
519
  global.toast.showToast("当前没有绑定电视用户,无法解绑");
424
520
  }
425
- }
521
+ },
426
522
  );
427
523
 
428
524
  return () => {
@@ -430,6 +526,7 @@ const App = () => {
430
526
  keyboardDidHideListener.remove();
431
527
  cellularDataStateListener.remove();
432
528
  homedLogOutListener.remove();
529
+ removeConnectListener && removeConnectListener();
433
530
  };
434
531
  }, []);
435
532
 
@@ -448,10 +545,10 @@ const App = () => {
448
545
  if (res.code === 0) {
449
546
  const versionInfo = res.data.packages[0];
450
547
  const newVersion = Number(
451
- versionInfo.version.slice(1).replace(/\./g, "")
548
+ versionInfo.version.slice(1).replace(/\./g, ""),
452
549
  );
453
550
  const currentVersion = Number(
454
- baseVersionInfo.version.slice(1).replace(/\./g, "")
551
+ baseVersionInfo.version.slice(1).replace(/\./g, ""),
455
552
  );
456
553
  if (newVersion > currentVersion) {
457
554
  setVersionUpdateConfirmVisible(true);
@@ -476,7 +573,7 @@ const App = () => {
476
573
  const handleStateChange = ({ routes }) => {
477
574
  const routeName = routes[routes.length - 1].name;
478
575
  setIncludeBottom(
479
- allStackScreens[routeName]?.screenOptions?.includeBottom || false
576
+ allStackScreens[routeName]?.screenOptions?.includeBottom || false,
480
577
  );
481
578
  /* 加载之后每次navigate都鉴权一把登录状态(重置密码不需要检测) */
482
579
  if (
@@ -500,7 +597,11 @@ const App = () => {
500
597
  onStateChange={handleStateChange}
501
598
  >
502
599
  <Stack.Navigator
503
- initialRouteName={"Login"}
600
+ /**
601
+ * 山东享TV:起始路由走 `Home`,不再一进来就落登录页。
602
+ * 登录入口在「我的」页(`navigate('Login')`);其余产品仍是 `Login`,不受影响。
603
+ */
604
+ initialRouteName={isShandongApp() ? "Home" : "Login"}
504
605
  screenOptions={{
505
606
  headerStyle: {},
506
607
  }}
@@ -22,8 +22,8 @@ const CLOUDHOMECENTER_URL = `${config.IPANEL_CLOUD_BASE_URI}/s/smart_home/cloudh
22
22
 
23
23
  // 获取百度ASR token,支持缓存和自动刷新
24
24
  export const getBaiduAsrToken = async () => {
25
- const BAIDU_ASR_TOKEN_KEY = 'baiduasrtoken';
26
- const {storage} = global.base;
25
+ const BAIDU_ASR_TOKEN_KEY = "baiduasrtoken";
26
+ const { storage } = global.base;
27
27
 
28
28
  try {
29
29
  const cachedTokenInfo = await storage.get(BAIDU_ASR_TOKEN_KEY);
@@ -36,17 +36,20 @@ export const getBaiduAsrToken = async () => {
36
36
  return cachedTokenInfo.accessToken;
37
37
  }
38
38
  } catch (error) {
39
- console.error('Get baidu asr token from storage error', error);
39
+ global.base.logger.error("Get baidu asr token from storage error", error);
40
40
  }
41
41
 
42
42
  const result = await request({
43
43
  url: CLOUDHOMECENTER_URL,
44
- method: 'POST',
44
+ method: "POST",
45
45
  data: {
46
- path: 'asrproxy/token',
46
+ path: "asrproxy/token",
47
47
  },
48
- }).catch(err => {
49
- console.error('Failed to fetch Baidu ASR token', err);
48
+ }).catch((err) => {
49
+ global.base.logger.info(
50
+ "asrproxy/token Error: Failed to fetch Baidu ASR token",
51
+ err,
52
+ );
50
53
  });
51
54
 
52
55
  if (result && result.code === 0) {
@@ -60,26 +63,26 @@ export const getBaiduAsrToken = async () => {
60
63
  expiresAt: expiresAt,
61
64
  });
62
65
  } catch (error) {
63
- console.error('Set baidu asr token to storage error', error);
66
+ global.base.logger.error("Set baidu asr token to storage error", error);
64
67
  }
65
68
  return tokenData.access_token;
66
69
  }
67
70
  }
68
- return '';
71
+ return "";
69
72
  };
70
73
 
71
74
  // 百度ASR语音识别服务,支持动态token获取
72
- export const baiduAsr = async (cuid, len, speechBase64) => {
75
+ export const baiduAsr = async (cuid, len, speechBase64, format = "m4a") => {
73
76
  const token = await getBaiduAsrToken();
74
77
  if (!token) {
75
- throw new Error('Failed to obtain Baidu ASR token');
78
+ throw new Error("Failed to obtain Baidu ASR token");
76
79
  }
77
80
 
78
81
  return request({
79
82
  url: "https://vop.baidu.com/pro_api", // 语音识别极速版调用地址
80
83
  method: "POST",
81
84
  data: {
82
- format: "m4a",
85
+ format,
83
86
  rate: 16000,
84
87
  dev_pid: 80001,
85
88
  channel: 1,
@@ -1002,6 +1005,18 @@ export const queryCountByName = (data) => {
1002
1005
  });
1003
1006
  };
1004
1007
 
1008
+ // 扫码登录tv端的cloud账号
1009
+ export const accountLoginCode = data => {
1010
+ return request({
1011
+ url: ACCOUNT_SERVICE,
1012
+ method: 'POST',
1013
+ data: {
1014
+ action: 'homed_login',
1015
+ ...data,
1016
+ },
1017
+ });
1018
+ };
1019
+
1005
1020
  // 获取图形验证码
1006
1021
  export const getCaptcha = (data) => {
1007
1022
  return request({
@@ -1034,3 +1049,57 @@ export const getJinpengBindList = async (params) => {
1034
1049
  },
1035
1050
  });
1036
1051
  };
1052
+
1053
+ // 获取智能推荐问题列表
1054
+ export const getRecommendQuestions = async (data, abortSignal) => {
1055
+ const MSGCENTER_URL = `${config.IPANEL_CLOUD_BASE_URI}/1/cs_agent/api/families/${data.address_id}/recommend_questions`;
1056
+ return request({
1057
+ url: MSGCENTER_URL,
1058
+ method: "GET",
1059
+ signal: abortSignal, // 支持取消信号
1060
+ data: {
1061
+ user_id: data.user_id,
1062
+ },
1063
+ });
1064
+ };
1065
+
1066
+ // 家庭画像问卷API
1067
+
1068
+ /**
1069
+ * 获取家庭画像问卷数据
1070
+ * @param {string} storageRoomId - 家庭默认储物间房间uuid
1071
+ * @returns {Promise} API响应
1072
+ */
1073
+ export const getFamilyQuestionnaire = async (storageRoomId) => {
1074
+ const ROOMKEEPER_SERVICE = await getCurrentAddrRoomkeeperServiceBaseUri();
1075
+ return request({
1076
+ url: ROOMKEEPER_SERVICE,
1077
+ method: "POST",
1078
+ data: {
1079
+ path: "family/get_questionnaire",
1080
+ storage_room_id: storageRoomId,
1081
+ },
1082
+ });
1083
+ };
1084
+
1085
+ /**
1086
+ * 保存家庭画像问卷数据
1087
+ * @param {string} storageRoomId - 家庭默认储物间房间uuid
1088
+ * @param {object} questionnaireData - 问卷数据
1089
+ * @returns {Promise} API响应
1090
+ */
1091
+ export const saveFamilyQuestionnaire = async (
1092
+ storageRoomId,
1093
+ questionnaireData,
1094
+ ) => {
1095
+ const ROOMKEEPER_SERVICE = await getCurrentAddrRoomkeeperServiceBaseUri();
1096
+ return request({
1097
+ url: ROOMKEEPER_SERVICE,
1098
+ method: "POST",
1099
+ data: {
1100
+ path: "family/save_questionnaire",
1101
+ storage_room_id: storageRoomId,
1102
+ data: questionnaireData,
1103
+ },
1104
+ });
1105
+ };
Binary file
Binary file