diff --git a/entry/src/main/ets/pages/BluetoothControlPage.ets b/entry/src/main/ets/pages/BluetoothControlPage.ets index 40e73fe..3424da1 100644 --- a/entry/src/main/ets/pages/BluetoothControlPage.ets +++ b/entry/src/main/ets/pages/BluetoothControlPage.ets @@ -121,10 +121,10 @@ struct BluetoothControlPage { } .tabBar(this.TabBuilder(2, '自动模式')) - TabContent() { - AlarmBrowser({ deviceId: this.deviceId }) - } - .tabBar(this.TabBuilder(3, '告警信息')) + // TabContent() { + // AlarmBrowser({ deviceId: this.deviceId }) + // } + // .tabBar(this.TabBuilder(3, '告警信息')) } .vertical(false) .barMode(BarMode.Fixed) diff --git a/entry/src/main/ets/pages/components/AutoMode.ets b/entry/src/main/ets/pages/components/AutoMode.ets index 0f412fd..b393713 100644 --- a/entry/src/main/ets/pages/components/AutoMode.ets +++ b/entry/src/main/ets/pages/components/AutoMode.ets @@ -533,18 +533,7 @@ export struct AutoMode { .justifyContent(FlexAlign.Center) .padding(10) - // Bottom Info - Column() { - Row() { - Text(`日出时间:${this.sunriseTime}`).fontSize(12).fontColor('#b2ebf2').layoutWeight(1) - Text(`日落时间:${this.sunsetTime}`).fontSize(12).fontColor('#b2ebf2').layoutWeight(1) - }.width('100%') - } - .width('100%') - .padding(15) - .backgroundColor('rgba(15, 30, 60, 0.4)') - .borderRadius(8) - .margin({bottom: 20}) + // Dialog if(this.showTaskDialog) { diff --git a/entry/src/main/ets/pages/components/ManualControl.ets b/entry/src/main/ets/pages/components/ManualControl.ets index 05a9cfe..82baebc 100644 --- a/entry/src/main/ets/pages/components/ManualControl.ets +++ b/entry/src/main/ets/pages/components/ManualControl.ets @@ -293,6 +293,30 @@ export struct ManualControl { return `${h}:${min}:${s}`; } + confirmAction(message: string, action: () => void) { + AlertDialog.show({ + title: '提示', + message: message, + primaryButton: { + value: '取消', + action: () => {} + }, + secondaryButton: { + value: '确定', + action: () => { + action(); + } + } + }) + } + + restartDevice() { + this.m9zService.restartDevice({ + onSuccess: (val: boolean): void => { this.showToastMessage('发送重启命令成功'); }, + onError: (err: string): void => { this.showToastMessage('失败:' + err); } + }); + } + build() { Stack() { Scroll() { @@ -325,7 +349,7 @@ export struct ManualControl { .fontColor(this.manualData.disable ? '#22fdc8' : '#b2ebf2') .border({ width: 1, color: this.manualData.disable ? '#22fdc8' : '#213b67' }) .height(44) - .onClick(() => this.toggleMode()) + .onClick((): void => { this.confirmAction(`确定切换到${this.manualData.disable ? '自动' : '手动'}模式吗?`, (): void => this.toggleMode()); }) } .width('100%') .margin({bottom: 20}) @@ -360,7 +384,7 @@ export struct ManualControl { Text(loop.isOpen ? '开启' : '关闭') .fontSize(10).fontColor(loop.isOpen ? '#22fdc8' : '#999') } - .onClick(() => this.toggleLoop(loop.index)) + .onClick((): void => { this.confirmAction(`确定${loop.isOpen ? '关闭' : '开启'}回路${loop.index + 1}吗?`, (): void => this.toggleLoop(loop.index)); }) } }) } @@ -398,7 +422,7 @@ export struct ManualControl { Text(`通道${loop.index + 1}`) .fontSize(12).fontColor('#b2ebf2') } - .onClick(() => this.openBrightnessDialog(loop.index)) + .onClick((): void => { this.openBrightnessDialog(loop.index); }) } }) } @@ -417,7 +441,7 @@ export struct ManualControl { .border({width: 1, color: '#22fdc8'}) .layoutWeight(1) .height(40) - .onClick(() => this.turnOnAll()) + .onClick((): void => { this.confirmAction('确定要全开吗?', (): void => this.turnOnAll()); }) Button('全关') .backgroundColor('#1a1520') @@ -426,7 +450,7 @@ export struct ManualControl { .layoutWeight(1) .height(40) .margin({left: 10}) - .onClick(() => this.turnOffAll()) + .onClick((): void => { this.confirmAction('确定要全关吗?', (): void => this.turnOffAll()); }) Button('一键调光') .backgroundColor('#2a2515') @@ -435,7 +459,7 @@ export struct ManualControl { .layoutWeight(1) .height(40) .margin({left: 10}) - .onClick(() => this.openBrightnessDialog(-1)) + .onClick((): void => { this.openBrightnessDialog(-1); }) }.width('100%').margin({bottom: 15}) Row() { @@ -445,7 +469,7 @@ export struct ManualControl { .border({width: 1, color: '#40a7fa'}) .layoutWeight(1) .height(40) - .onClick(() => this.syncDeviceTime()) + .onClick((): void => { this.confirmAction('确定要同步设备时间吗?', (): void => this.syncDeviceTime()); }) Button('刷新数据') .backgroundColor('rgba(34, 253, 200, 0.1)') @@ -454,20 +478,18 @@ export struct ManualControl { .layoutWeight(1) .height(40) .margin({left: 10}) - .onClick(() => this.refreshData()) + .onClick((): void => { this.refreshData(); }) + + Button('重启设备') + .backgroundColor('#fa5050') + .fontColor('white') + .layoutWeight(1) + .height(40) + .margin({left: 10}) + .onClick((): void => { this.confirmAction('确定要重启设备吗?', (): void => this.restartDevice()); }) }.width('100%').margin({bottom: 20}) - // --- Bottom Info --- - Column() { - Row() { - Text(`日出时间:${this.sunriseTime}`).fontSize(12).fontColor('#b2ebf2').layoutWeight(1) - Text(`日落时间:${this.sunsetTime}`).fontSize(12).fontColor('#b2ebf2').layoutWeight(1) - }.width('100%') - } - .width('100%') - .padding(15) - .backgroundColor('rgba(15, 30, 60, 0.4)') - .borderRadius(8) + } .width('100%') .padding({ left: 15, right: 15, top: 15, bottom: 80 }) diff --git a/entry/src/main/ets/pages/components/ParameterSettings.ets b/entry/src/main/ets/pages/components/ParameterSettings.ets index 117deea..b821f95 100644 --- a/entry/src/main/ets/pages/components/ParameterSettings.ets +++ b/entry/src/main/ets/pages/components/ParameterSettings.ets @@ -246,22 +246,11 @@ export struct ParameterSettings { .margin({bottom: 15}) .width('100%') - // 当前日出日落时间 - Column() { - Text('今日光照时间').fontSize(16).fontWeight(FontWeight.Bold).fontColor('#22fdc8').width('100%').margin({bottom: 10}) - Text(`日出: ${this.sunRiseTime.sunrise ? this.formatTime(this.sunRiseTime.sunrise) : '--:--'}`).fontColor('#eaf6fc') - Text(`日落: ${this.sunRiseTime.sunset ? this.formatTime(this.sunRiseTime.sunset) : '--:--'}`).fontColor('#eaf6fc') - } - .padding(10) - .backgroundColor('rgba(20, 38, 81, 0.95)') - .borderRadius(8) - .margin({bottom: 15}) - .margin({bottom: 15}) - .width('100%') + // 周运行模式设置 Column() { - Text('周运行模式设置').fontSize(16).fontWeight(FontWeight.Bold).fontColor('#22fdc8').width('100%').margin({bottom: 10}) + Text('自动模式设置').fontSize(16).fontWeight(FontWeight.Bold).fontColor('#22fdc8').width('100%').margin({bottom: 10}) ForEach(this.displayIndices, (dataIndex: number) => { Row() { @@ -303,7 +292,7 @@ export struct ParameterSettings { .margin({top: 20}) .onClick(() => this.restartDevice()) - }.width('100%').padding(10) + }.width('100%').padding({ left: 15, right: 15, top: 15, bottom: 80 }) } if (this.isLoading) {