智能小程序 Ray 开发其他 API —— changeDebugMode & initPanelKit API 接口汇总

changeDebugMode

设置调试模式

引入

import { changeDebugMode } from '@ray-js/ray';

需引入MiniKit,且在>=2.6.0版本才可使用

参数

Object object

属性类型默认值必填说明
isEnableboolean调试模式开关
completefunction接口调用结束的回调函数(调用成功、失败都会执行)
successfunction接口调用成功的回调函数
failfunction接口调用失败的回调函数

👉 立即免费领取开发资源,体验涂鸦 MiniApp 小程序开发。  

ty.panel.initPanelKit

初始化面板基础能力

  1. 用于初始化面板基础能力(注册 设备 / 群组 事件监听),若无特殊业务需求(如:监听当前设备以外的其他设备 dp 状态、设备信息等变更),业务不需要再调用 ty.device.registerDeviceListListener 或 ty.device.registerGroupChange 方法。
  2. 用于创建设备上下线监听,设备离线后弹出离线弹窗,若无特殊需求,业务不需要再开发离线弹窗界面及逻辑。

类型

deviceId 或 groupId 二者必填其一

type PanelKitInitConfig = {
  /**
   * 设备 ID
   */
  deviceId?: string;
  /**
   * 群组 ID
   */
  groupId?: string;
 
  /**
   * @description 是否使用默认离线弹窗
   * @default true
   */
  useDefaultOffline: boolean;
  /**
   * 蓝牙 toast 是否需要覆盖界面
   * @default false
   * @version 2.10.4
   */
  bleCover?: boolean;
 
  /**
   * @description 自定义导航栏后,需要配置高度
   * @default 0
   * @version 2.10.4
   */
  customTop?: string;
 
  /**
   * @description 是否显示蓝牙连接状态提示
   *
   * @default true
   * @version 2.10.4
   */
  showBLEToast?: boolean;
 
  /**
   * @description 蓝牙连接类型。0 : 网关和app都需要,默认值,本地和网关两个途径任何一个可用均可生效 1 : 仅app,只会判定本地是否在线,以及本地连接是否成功 2 : 仅网关连接,只会判定网关是否在线,以及坚持网关连接是否成功
   * @default 0
   */
  bleConnectType?: number;
};

请求参数

参数数据类型说明是否必填
configPanelKitInitConfig初始化面板基础能力配置

返回参数

请求示例

ty.panel.initPanelKit({ deviceId: 'vdev1234567' });

返回示例

注意事项

如果需要自定义设备离线的多语言词条,可参考下方 JSON 数据自行在 涂鸦开发者平台的产品多语言或面板多语言里配置。

{
  "zh": {
    "openBle": "开启系统蓝牙",
    "openBleShare": "开启“蓝牙共享”",
    "openBleShareStep": "设置 > 找到您的 App > 开启蓝牙共享",
    "deviceOfflineHelpNew": "① 确保设备通电正常(或电池电量充足)\n② 将手机尽量贴近设备\n③ 若设备曾被其他手机连接过,请先断开,再进行",
    "offline_link": "重新连接",
    "backToHome": "返回首页",
    "checkHelp": "查看帮助",
    "offline_alreadyOffline": "设备已离线",
    "offline_pleaseCheck": "请依次检查:",
    "offline_linkFront": "3. 检查是否修改了路由器的名称或密码,可以尝试",
    "offline_moreHelp": "更多帮助",
    "offline_textLinkMore": "",
    "bluetoothShareTip": "功能受限,请开启“蓝牙共享”",
    "bluetoothOfflineTip": "请开启“蓝牙”",
    "deviceOffline": "设备连接失败"
  },
  "en": {
    "openBle": "Enable System Bluetooth",
    "openBleShare": "Enable Bluetooth Sharing",
    "openBleShareStep": "Settings > Find Your App > Enable Bluetooth Sharing",
    "deviceOfflineHelpNew": "① Make sure that the device is powered on or that the battery capacity is sufficient.\n② Place the mobile phone as close as possible to the device.\n③ If the device has been connected to another mobile phone, close the connection and try to ",
    "offline_link": "reconnect the router.",
    "backToHome": "Homepage",
    "checkHelp": "View Help",
    "offline_alreadyOffline": "Offline Device",
    "offline_pleaseCheck": "Check the following items:",
    "offline_linkFront": "3. Whether the name or password of the router is modified. You can try to ",
    "offline_moreHelp": "More Help",
    "offline_textLinkMore": "",
    "bluetoothShareTip": "Limited functionality, please turn on \"Bluetooth Sharing\"",
    "bluetoothOfflineTip": "Enable Bluetooth on your mobile phone.",
    "deviceOffline": "Device Connection Failure"
  }
}

👉 立即免费领取开发资源,体验涂鸦 MiniApp 小程序开发。  

  • 3
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

IoT砖家涂拉拉

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值