面板小程序节律api请求

小程序开发相关产品技术讨论,包括面板、智能小程序、React Native、Ray跨端框架、Panel SDK、微信小程序、小程序开发工具(IDE)及其他开发技术相关等话题


Post Reply
YY.
Posts: 2

  • Tuya MiniApp IDE 版本信息:Node v16.20.2 Tools 0.8.12 Ray 1.7.10
    • App 应用版本信息: 设置-关于中进行查看~
    • "@ray-js/panel-sdk": "1.13.1", "@ray-js/ray": "1.7.24",
    • 移动设备信息:iphone 15pro
    • 相关代码: const fetchCityInfo = useCallback(
      async (
      latitude: number,
      longitude: number
      ): Promise<{ country?: string; province?: string; city?: string } | undefined> => {
      if (!devId) {
      return undefined;
      }
      try {
      const result = await getLightRhythmsCityInfo({
      bizId: devId,
      bizType: 0,
      lon: ${longitude},
      lat: ${latitude},
      });
      console.log('getLightRhythmsCityInfo response:', result);
      const visited = new WeakSet<Record<string, unknown>>();
      const resolveCityInfo = (
      value: unknown
      ): { country?: string; province?: string; city?: string } | undefined => {
      if (value == null) {
      return undefined;
      }
      if (typeof value === 'string') {
      try {
      const parsed = JSON.parse(value);
      return resolveCityInfo(parsed);
      } catch (error) {
      return undefined;
      }
      }
      if (typeof value !== 'object') {
      return undefined;
      }
      const record = value as Record<string, unknown>;
      if (visited.has(record)) {
      return undefined;
      }
      visited.add(record);
      if (record.country record.province record.city) {
      return {
      country: typeof record.country === 'string' ? record.country : undefined,
      province: typeof record.province === 'string' ? record.province : undefined,
      city: typeof record.city === 'string' ? record.city : undefined,
      };
      }
      return Object.values(record).reduce<
      { country?: string; province?: string; city?: string } | undefined
      >((found, next) => found resolveCityInfo(next), undefined);
      };
      const parsed = resolveCityInfo(result);
      if (parsed) {
      console.log('Parsed city info:', parsed);
      }
      return parsed
      undefined;
      } catch (error) {
      console.error('getLightRhythmsCityInfo failed:', error);
      return undefined;
      }
      },
      [devId]
      );
    • 日志信息:Image
    • 问题描述(复现步骤):真机调试请求api,真实设备请求被阻止,后面用虚拟设备发现可以请求。已经在小程序平台授权节律的apiImage
    • 预期结果:真实设备能正常请求api
    • 实际结果:真实设备不能发送请求api,被阻止了
Attachments
92ef6abe2b2f4b00db070a4b5f962682.png
1f5481de75722e09a1ceae079ab61d7a.png

Tags:
muhai
Posts: 139

Re: 面板小程序节律api请求

真实设备在IDE授权的账号家庭下吗,是否是没有该设备权限? 设备id可以发一下

YY.
Posts: 2

Re: 面板小程序节律api请求

真实设备是共享到ide开发账号下,设备id:6ca473326cfb0b958dwfiq

muhai
Posts: 139

Re: 面板小程序节律api请求

YY. 2025年 Oct 29日 14:18

真实设备是共享到ide开发账号下,设备id:6ca473326cfb0b958dwfiq

这个方法会校验真实设备是否开通了生物节律高级能力,虚拟设备是没有校验的,真实设备需要开通高级能力(除授权能力包外,需要设备开通高级能力),可以提工单填写设备id/产品id开通生物节律高级能力后,再重新尝试 :D

Post Reply