From 3ce498a12bb41d4c898efed3f74f2e154d56fc22 Mon Sep 17 00:00:00 2001 From: ByteZhang Date: Mon, 22 Jul 2024 16:11:04 +0800 Subject: [PATCH] chore: add reboot board --- src/components/Firmware/Firmware.tsx | 25 +++++++++++++++++++++++++ src/hardware/index.ts | 6 ++++++ src/locales/en-US.json | 1 + src/locales/zh-CN.json | 1 + 4 files changed, 33 insertions(+) diff --git a/src/components/Firmware/Firmware.tsx b/src/components/Firmware/Firmware.tsx index dac40aa..b57c58f 100644 --- a/src/components/Firmware/Firmware.tsx +++ b/src/components/Firmware/Firmware.tsx @@ -89,6 +89,30 @@ const Description: FC<{ text: string; value: any }> = ({ text, value }) => ( ); +const RebootToBoard: FC = () => { + const intl = useIntl(); + const device = useSelector((state: RootState) => state.runtime.device); + const [loading, setLoading] = useState(false); + + const onRebootToBoard = useCallback(async () => { + setLoading(true); + await serviceHardware.rebootToBoard(); + setLoading(false); + }, []); + + if (['touch', 'pro'].includes(getDeviceType(device?.features))) { + return ( +
+ +
+ ); + } + + return null; +}; + const ConfirmUpdate: FC = () => { const intl = useIntl(); const device = useSelector((state: RootState) => state.runtime.device); @@ -311,6 +335,7 @@ export default function Firmware() { })} value={device?.uuid ?? '-'} /> + {['touch', 'pro'].includes(getDeviceType(device?.features)) && ( diff --git a/src/hardware/index.ts b/src/hardware/index.ts index 5f30c93..58f09a6 100644 --- a/src/hardware/index.ts +++ b/src/hardware/index.ts @@ -414,6 +414,12 @@ class ServiceHardware { return response.payload; }); } + + async rebootToBoard() { + const hardwareSDK = await this.getSDKInstance(); + const response = await hardwareSDK.deviceRebootToBoardloader(''); + return !!response.success; + } } export default ServiceHardware; diff --git a/src/locales/en-US.json b/src/locales/en-US.json index 30857cd..a62b23e 100644 --- a/src/locales/en-US.json +++ b/src/locales/en-US.json @@ -2,6 +2,7 @@ "TR_CLOSE": "close", "TR_RES_REPAIR": "For {0} device, if there are problems such as picture display, you can click the fix button to restore the resources", "TR_CLICK_TO_REPAIR": "click to fix", + "TR_CLICK_TO_BOARD": "Click to enter the board mode", "TR_FIRMWARE_UPDATE_1": "Please first upgrade your OneKey Touch firmware to {version} or above", "TR_FIRMWARE_UPDATE_2": "current version", "TR_LIST_TIP_1": "Please unlock the device and keep it on the home page of the device, click the start button to operate, do not operate the device during the process", diff --git a/src/locales/zh-CN.json b/src/locales/zh-CN.json index 2c49a80..9ddb4a1 100644 --- a/src/locales/zh-CN.json +++ b/src/locales/zh-CN.json @@ -2,6 +2,7 @@ "TR_CLOSE": "关闭", "TR_RES_REPAIR": "{0} 设备,如果出现图片、图标显示不完全等问题,可以点击后方按钮进行资源修复后恢复", "TR_CLICK_TO_REPAIR": "点击修复", + "TR_CLICK_TO_BOARD": "点击进入 Board 模式", "TR_FIRMWARE_UPDATE_1": "请首先将您的 OneKey Touch 固件升级到 {version} 或以上", "TR_FIRMWARE_UPDATE_2": "当前版本", "TR_LIST_TIP_1": "请解锁设备并保持在设备首页后,点击开始按钮进行操作,过程中切勿操作设备",