[English](./README.md) | 简体中文

# LampScheduleSetFunction

## 使用

- src/global.config.ts 中配置 appid

```ts
export const tuya = {
  // 其他内容
  // ...xxxx

  functionalPages: {
    // 其他功能页
    // ...xxxx

    // 定时功能页
    LampScheduleSetFunction: {
      appid: 'ty56cr7pi6rxiucspo',
    },
  },
};
```

```tsx
import { navigateToSchedule } from '@ray-js/lamp-schedule-core';

const handleJump = () => {
  // sigmesh 注意这里配置的 devId 需要在自己账号的家庭下， 否则无法获取到 devInfo 数据导致各种异常
  // 不带 rtc_timer
  // const deviceId = 'vdevo174167890140766';
  // sigmesh 带 rtc_timer
  // const deviceId = 'vdevo174367051524181';
  // wifi
  const deviceId = '6c927ad99d26660de1nnta';
  const groupId = '';

  const transData = {
    // 非必填，默认 dark 模式
    themeConfig: {
      // themeType 可选，dark or light, 默认 dark
      themeType: 'light',
      // bgImg 可选，只支持 https 远程图片
      bgImg: 'https://images.tuyacn.com/smart/uiconf/bg_57_s.jpg?t=1750749772928', // 只支持 https 远程图片
      // themeColor 可选，主题色，默认 #1082FE
      themeColor: 'rgba(255, 0, 255, 1)',
      // mainColor 可选，主色，默认 #ffffff
      mainColor: 'rgba(255, 0, 0, 1)',
      // bgColor 可选，背景色，默认 #121222
      bgColor: 'rgba(255, 255, 255, 0.9)',
    },
    // 普通定时是否支持“备注”和“提醒”功能, 默认不支持普通定时是否支持“备注”和“提醒”功能, 默认不支持
    // normalTimerAdvances: {
    //   remarks: true,
    //   notice: true,
    // },
    forceSupport: {
      // 正常是根据 dp 是否存在来展示，支持强制不展示，不支持强制展示，因为如果没有对应 dp 的话 功能无法正常运行
      // countdown: false, // 倒计时
      // rhythms: false, // 生物节律
      // sleep: false, // 睡眠
      // wakeup: false, // 起床
      // cycle: false, // 循环
      // random: false, // 随机
      // timer: false, // 定时
    },
    // 多语言 key 值映射，用于兼容老面板的多语言
    i18nKeyMap: {
      // 老的多语言key: 新的多语言 key
      rhythms_title: 'rhythms_title1',
    } as I18nKeys,
    countdownType: 'hourMinuteSecond',
    // 如果是云定时，需要指定 cloudTimerCategory，默认使用 ‘timer'
    switchDpCode: "switch_led", // 自定义 开关 dp
    cloudTimerCategory: 'switch_led',
    // NoNature => 适合吸顶灯 UI 风格
    rhythmsType: ERhythmsType.Normal,
    // 跳转定时执行行为的路由 类似 /pages/xxx/index
    // timerActionRoute: '/pages/second/index',
    // 定时执行动作为开时页面传递的 dp 数据，会在 timerActionRoute 页面中获取到对应的 dp 值
    // timerActionOpenDpList: ['rtc_timer'],
  };

  navigateToSchedule(
    {
      deviceId,
      groupId,
    },
    transData,
    {
      timerDataChange: (res: { type: 'add' | 'delete' | 'edit' | 'cancel'; data: any }) => {
        // 这里获取到 timer 操作变化时的数据
        console.warn('navigateTo timerDataChange res1:', res);
      },
    }
  );
};
```

## 注意事项：

- 开发调试时
  - 需要注意 src 下配置的 devId 必须在自己当前家庭下，否则扫码时会报各种异常；
  - 在 IDE 上调试时需要注意项目中配置的 miniId 与 IDE 选择的 miniId 对应上,否则会拉取线上的版本，本地无法调试。