@ledvance/ui-biz-bundle 1.1.69 → 1.1.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.babelrc +31 -31
- package/.eslintignore +5 -5
- package/.eslintrc.js +27 -27
- package/.prettierrc.js +1 -1
- package/.versionrc +5 -5
- package/package.json +74 -74
- package/rn-cli.config.js +8 -8
- package/src/hooks/DeviceDpStateHooks.d.ts +14 -14
- package/src/hooks/DeviceDpStateHooks.ts +50 -50
- package/src/modules/biorhythm/BiorhythmActions.d.ts +8 -8
- package/src/modules/biorhythm/BiorhythmActions.ts +324 -324
- package/src/modules/biorhythm/BiorhythmBean.d.ts +58 -58
- package/src/modules/biorhythm/BiorhythmBean.ts +230 -230
- package/src/modules/biorhythm/BiorhythmEditPage.d.ts +14 -14
- package/src/modules/biorhythm/BiorhythmEditPage.tsx +324 -324
- package/src/modules/biorhythm/BiorhythmPage.d.ts +10 -10
- package/src/modules/biorhythm/BiorhythmPage.tsx +796 -796
- package/src/modules/biorhythm/IconSelect.d.ts +2 -2
- package/src/modules/biorhythm/IconSelect.tsx +81 -81
- package/src/modules/biorhythm/Router.ts +34 -34
- package/src/modules/biorhythm/circular/ItemIcon.d.ts +22 -22
- package/src/modules/biorhythm/circular/ItemIcon.tsx +172 -172
- package/src/modules/biorhythm/circular/Progress.d.ts +24 -24
- package/src/modules/biorhythm/circular/Progress.tsx +411 -411
- package/src/modules/biorhythm/circular/TimeCircular.d.ts +11 -11
- package/src/modules/biorhythm/circular/TimeCircular.tsx +70 -70
- package/src/modules/biorhythm/iconListData.d.ts +7 -7
- package/src/modules/biorhythm/iconListData.ts +29 -29
- package/src/modules/biorhythm/pIdList.d.ts +2 -2
- package/src/modules/biorhythm/pIdList.ts +35 -35
- package/src/modules/biorhythm/res/BiologicalRes.d.ts +43 -43
- package/src/modules/biorhythm/res/BiologicalRes.ts +41 -41
- package/src/modules/config/ldvConfig.d.ts +2 -2
- package/src/modules/config/ldvConfig.tsx +18 -18
- package/src/modules/fixedTime/FixedTimeActions.ts +173 -173
- package/src/modules/fixedTime/FixedTimeDetailPage.tsx +372 -372
- package/src/modules/fixedTime/FixedTimePage.tsx +213 -213
- package/src/modules/fixedTime/Router.ts +26 -26
- package/src/modules/flags/FlagActions.ts +267 -267
- package/src/modules/flags/FlagEditPage.tsx +441 -441
- package/src/modules/flags/FlagInfo.tsx +563 -563
- package/src/modules/flags/FlagItem.tsx +90 -90
- package/src/modules/flags/FlagPage.tsx +277 -277
- package/src/modules/flags/Router.ts +25 -25
- package/src/modules/history/HistoryPage.d.ts +2 -2
- package/src/modules/history/HistoryPage.tsx +261 -261
- package/src/modules/history/Router.ts +16 -16
- package/src/modules/history/SwitchHistoryPageActions.d.ts +14 -14
- package/src/modules/history/SwitchHistoryPageActions.ts +76 -76
- package/src/modules/mood/AddMoodPage.d.ts +10 -10
- package/src/modules/mood/AddMoodPage.tsx +792 -792
- package/src/modules/mood/DynamicMoodEditorPage.d.ts +6 -6
- package/src/modules/mood/DynamicMoodEditorPage.tsx +561 -561
- package/src/modules/mood/FantasyMood.tsx +176 -176
- package/src/modules/mood/FantasyMoodEditPage.tsx +582 -582
- package/src/modules/mood/FantasyMoodItem.tsx +104 -104
- package/src/modules/mood/FantasyRouter.ts +35 -35
- package/src/modules/mood/MixMood/AddMixMoodPage.tsx +247 -247
- package/src/modules/mood/MixMood/MixMoodActions.ts +128 -128
- package/src/modules/mood/MixMood/MixMoodEditPage.tsx +721 -721
- package/src/modules/mood/MixMood/MixMoodItem.tsx +134 -134
- package/src/modules/mood/MixMood/MixMoodPage.tsx +326 -326
- package/src/modules/mood/MixMood/MixSceneBeans.ts +364 -364
- package/src/modules/mood/MixMood/RecommendMixMoodItem.tsx +69 -69
- package/src/modules/mood/MixMood/Router.ts +44 -44
- package/src/modules/mood/MoodItem.d.ts +11 -11
- package/src/modules/mood/MoodItem.tsx +114 -114
- package/src/modules/mood/MoodPage.d.ts +16 -16
- package/src/modules/mood/MoodPage.tsx +296 -296
- package/src/modules/mood/RecommendMoodItem.d.ts +13 -13
- package/src/modules/mood/RecommendMoodItem.tsx +74 -74
- package/src/modules/mood/Router.ts +53 -53
- package/src/modules/mood/StaticMoodEditorPage.d.ts +16 -16
- package/src/modules/mood/StaticMoodEditorPage.tsx +320 -320
- package/src/modules/mood/tools.d.ts +3 -3
- package/src/modules/mood/tools.ts +11 -11
- package/src/modules/music/MusicDataBean.d.ts +47 -47
- package/src/modules/music/MusicDataBean.ts +167 -167
- package/src/modules/music/MusicManager.d.ts +27 -27
- package/src/modules/music/MusicManager.ts +207 -207
- package/src/modules/music/MusicPage.d.ts +10 -10
- package/src/modules/music/MusicPage.tsx +347 -347
- package/src/modules/music/MusicPageActions.d.ts +35 -35
- package/src/modules/music/MusicPageActions.ts +317 -317
- package/src/modules/music/Router.ts +16 -16
- package/src/modules/music/SelecetGenre.d.ts +7 -7
- package/src/modules/music/SelecetGenre.tsx +63 -63
- package/src/modules/music/color.d.ts +2 -2
- package/src/modules/music/color.ts +73 -73
- package/src/modules/music/res/index.d.ts +10 -10
- package/src/modules/music/res/index.ts +9 -9
- package/src/modules/powerOnBehavior/PowerOnBehaviorActions.ts +11 -11
- package/src/modules/powerOnBehavior/PowerOnBehaviorPage.tsx +173 -173
- package/src/modules/powerOnBehavior/Router.ts +16 -16
- package/src/modules/randomTime/RandomTimeActions.ts +160 -160
- package/src/modules/randomTime/RandomTimeDetailPage.tsx +337 -337
- package/src/modules/randomTime/RandomTimePage.tsx +214 -214
- package/src/modules/randomTime/Router.ts +25 -25
- package/src/modules/randomTime/Summary.tsx +122 -122
- package/src/modules/scene/SceneAction.d.ts +13 -13
- package/src/modules/scene/SceneAction.ts +473 -473
- package/src/modules/scene/SceneDetailPage.d.ts +1 -1
- package/src/modules/scene/SceneDetailPage.tsx +421 -421
- package/src/modules/scene/SceneInfo.d.ts +72 -72
- package/src/modules/scene/SceneInfo.ts +1059 -1059
- package/src/modules/scene/ScenePage.d.ts +7 -7
- package/src/modules/scene/ScenePage.tsx +147 -147
- package/src/modules/select/SelectPage.d.ts +12 -12
- package/src/modules/select/SelectPage.tsx +137 -137
- package/src/modules/sleepWakeup/DeviceState.d.ts +9 -9
- package/src/modules/sleepWakeup/DeviceState.tsx +99 -99
- package/src/modules/sleepWakeup/LdvScheduleItem.d.ts +15 -15
- package/src/modules/sleepWakeup/LdvScheduleItem.tsx +176 -176
- package/src/modules/sleepWakeup/Router.ts +25 -25
- package/src/modules/sleepWakeup/SleepWakeUpActions.d.ts +2 -2
- package/src/modules/sleepWakeup/SleepWakeUpActions.ts +180 -180
- package/src/modules/sleepWakeup/SleepWakeUpDetailPage.d.ts +2 -2
- package/src/modules/sleepWakeup/SleepWakeUpDetailPage.tsx +616 -616
- package/src/modules/sleepWakeup/SleepWakeUpPage.d.ts +13 -13
- package/src/modules/sleepWakeup/SleepWakeUpPage.tsx +424 -424
- package/src/modules/sleepWakeup/utils.d.ts +44 -44
- package/src/modules/sleepWakeup/utils.ts +253 -253
- package/src/modules/timeSchedule/DeviceState.d.ts +17 -17
- package/src/modules/timeSchedule/DeviceState.tsx +94 -94
- package/src/modules/timeSchedule/LdvScheduleItem.d.ts +15 -15
- package/src/modules/timeSchedule/LdvScheduleItem.tsx +130 -130
- package/src/modules/timeSchedule/ManualSetting.d.ts +14 -14
- package/src/modules/timeSchedule/ManualSetting.tsx +219 -219
- package/src/modules/timeSchedule/MoodSetting.d.ts +11 -11
- package/src/modules/timeSchedule/MoodSetting.tsx +228 -228
- package/src/modules/timeSchedule/Router.ts +25 -25
- package/src/modules/timeSchedule/ScheduleScene.d.ts +6 -6
- package/src/modules/timeSchedule/ScheduleScene.tsx +144 -144
- package/src/modules/timeSchedule/SingleLightView.d.ts +12 -12
- package/src/modules/timeSchedule/SingleLightView.tsx +175 -175
- package/src/modules/timeSchedule/TimeScheduleBean.d.ts +14 -14
- package/src/modules/timeSchedule/TimeScheduleBean.ts +18 -18
- package/src/modules/timeSchedule/TimeScheduleEditpage.d.ts +6 -6
- package/src/modules/timeSchedule/TimeScheduleEditpage.tsx +765 -765
- package/src/modules/timeSchedule/TimeSchedulePage.d.ts +13 -13
- package/src/modules/timeSchedule/TimeSchedulePage.tsx +358 -358
- package/src/modules/timeSchedule/components/ColorList.ts +23 -23
- package/src/modules/timeSchedule/components/LampSwitchCard.tsx +106 -106
- package/src/modules/timeSchedule/mix/MixLightActions.d.ts +3 -3
- package/src/modules/timeSchedule/mix/MixLightActions.ts +49 -49
- package/src/modules/timeSchedule/mix/MixLightBean.d.ts +10 -10
- package/src/modules/timeSchedule/mix/MixLightBean.ts +9 -9
- package/src/modules/timeSchedule/mix/MixLightView.d.ts +7 -7
- package/src/modules/timeSchedule/mix/MixLightView.tsx +197 -197
- package/src/modules/timeSchedule/utils.d.ts +1 -1
- package/src/modules/timeSchedule/utils.ts +6 -6
- package/src/modules/timer/Router.ts +16 -16
- package/src/modules/timer/TimerPage.d.ts +11 -11
- package/src/modules/timer/TimerPage.tsx +384 -384
- package/src/modules/timer/TimerPageAction.d.ts +22 -22
- package/src/modules/timer/TimerPageAction.ts +131 -131
- package/src/navigation/Routers.d.ts +15 -15
- package/src/navigation/Routers.ts +46 -46
- package/src/navigation/tools.d.ts +9 -9
- package/src/navigation/tools.ts +21 -21
- package/src/newModules/biorhythm/BiorhythmActions.ts +62 -11
- package/src/newModules/biorhythm/BiorhythmPage.tsx +1 -4
- package/src/newModules/childLock/ChildLockPage.tsx +97 -97
- package/src/newModules/childLock/Router.ts +16 -16
- package/src/newModules/energyConsumption/EnergyConsumptionActions.ts +23 -23
- package/src/newModules/energyConsumption/EnergyConsumptionChart.tsx +84 -84
- package/src/newModules/energyConsumption/EnergyConsumptionDetail.tsx +322 -322
- package/src/newModules/energyConsumption/EnergyConsumptionPage.tsx +393 -393
- package/src/newModules/energyConsumption/Router.ts +34 -34
- package/src/newModules/energyConsumption/co2Data.ts +23655 -23655
- package/src/newModules/energyConsumption/component/BarChart.tsx +93 -93
- package/src/newModules/energyConsumption/component/EnergyModal.tsx +284 -284
- package/src/newModules/energyConsumption/component/Overview.tsx +118 -118
- package/src/newModules/fixedTime/FixedTimeActions.ts +241 -241
- package/src/newModules/fixedTime/FixedTimeDetailPage.tsx +345 -345
- package/src/newModules/fixedTime/FixedTimePage.tsx +302 -302
- package/src/newModules/fixedTime/Router.ts +25 -25
- package/src/newModules/lightMode/LightModePage.tsx +204 -204
- package/src/newModules/lightMode/Router.ts +16 -16
- package/src/newModules/mood/Interface.ts +5 -0
- package/src/newModules/mood/MixDynamicMoodEditor.tsx +8 -5
- package/src/newModules/mood/MoodActions.ts +32 -20
- package/src/newModules/mood/MoodItem.tsx +3 -3
- package/src/newModules/mood/MoodPage.tsx +31 -15
- package/src/newModules/mood/MoodParse.ts +5 -6
- package/src/newModules/mood/RecommendMoodItem.tsx +3 -3
- package/src/newModules/mood/Router.ts +9 -0
- package/src/newModules/overchargeSwitch/OverchargeSwitchPage.tsx +96 -96
- package/src/newModules/overchargeSwitch/Router.ts +16 -16
- package/src/newModules/powerOnBehavior/LightBehaviorPage.tsx +266 -266
- package/src/newModules/powerOnBehavior/PlugBehaviorPage.tsx +173 -173
- package/src/newModules/powerOnBehavior/PowerOnBehaviorActions.ts +106 -106
- package/src/newModules/powerOnBehavior/Router.ts +27 -27
- package/src/newModules/randomTime/RandomTimeActions.ts +238 -238
- package/src/newModules/randomTime/RandomTimeDetailPage.tsx +325 -325
- package/src/newModules/randomTime/RandomTimePage.tsx +299 -299
- package/src/newModules/randomTime/Router.ts +25 -25
- package/src/newModules/randomTime/Summary.tsx +116 -116
- package/src/newModules/remoteControl/RemoteControlActions.ts +5 -5
- package/src/newModules/remoteControl/RemoteControlPage.tsx +51 -51
- package/src/newModules/remoteControl/Router.ts +15 -15
- package/src/newModules/select/Route.ts +16 -16
- package/src/newModules/select/SelectPage.d.ts +12 -12
- package/src/newModules/select/SelectPage.tsx +137 -137
- package/src/newModules/sleepWakeUp/Interface.ts +69 -69
- package/src/newModules/sleepWakeUp/Router.ts +24 -24
- package/src/newModules/sleepWakeUp/SleepWakeUpActions.ts +317 -317
- package/src/newModules/sleepWakeUp/SleepWakeUpDetailPage.tsx +661 -661
- package/src/newModules/sleepWakeUp/SleepWakeUpPage.tsx +455 -455
- package/src/newModules/sleepWakeUp/utils.ts +253 -253
- package/src/newModules/swithInching/Router.ts +16 -16
- package/src/newModules/swithInching/SwithInching.tsx +231 -231
- package/src/newModules/swithInching/SwithInchingAction.ts +55 -55
- package/src/newModules/swithInching/pickerView.tsx +91 -91
- package/src/newModules/timeSchedule/Interface.ts +142 -142
- package/src/newModules/timeSchedule/Router.ts +25 -25
- package/src/newModules/timeSchedule/TimeScheduleActions.ts +53 -53
- package/src/newModules/timeSchedule/TimeScheduleDetailPage.tsx +648 -648
- package/src/newModules/timeSchedule/TimeSchedulePage.tsx +253 -253
- package/src/newModules/timeSchedule/components/ManuaSettings.tsx +460 -460
- package/src/newModules/timeSchedule/components/ScheduleCard.tsx +125 -125
- package/tsconfig.json +50 -50
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { dpItem } from "./TimerPage";
|
|
2
|
-
export declare const useCountdowns: (dps: dpItem[]) => {
|
|
3
|
-
label: string;
|
|
4
|
-
value: string;
|
|
5
|
-
dpId: string;
|
|
6
|
-
enableDp: string;
|
|
7
|
-
cloudKey: any;
|
|
8
|
-
stringOn: any;
|
|
9
|
-
stringOff: any;
|
|
10
|
-
countdown: any;
|
|
11
|
-
enable: any;
|
|
12
|
-
}[];
|
|
13
|
-
export declare const useProgress: (dps: dpItem[], cancelTimer: any) => {
|
|
14
|
-
label: string;
|
|
15
|
-
value: string;
|
|
16
|
-
dpId: string;
|
|
17
|
-
enableDp: string;
|
|
18
|
-
cloudKey: any;
|
|
19
|
-
stringOn: any;
|
|
20
|
-
stringOff: any;
|
|
21
|
-
progressHook: [number, (time: number, t: any) => void];
|
|
22
|
-
}[];
|
|
1
|
+
import { dpItem } from "./TimerPage";
|
|
2
|
+
export declare const useCountdowns: (dps: dpItem[]) => {
|
|
3
|
+
label: string;
|
|
4
|
+
value: string;
|
|
5
|
+
dpId: string;
|
|
6
|
+
enableDp: string;
|
|
7
|
+
cloudKey: any;
|
|
8
|
+
stringOn: any;
|
|
9
|
+
stringOff: any;
|
|
10
|
+
countdown: any;
|
|
11
|
+
enable: any;
|
|
12
|
+
}[];
|
|
13
|
+
export declare const useProgress: (dps: dpItem[], cancelTimer: any) => {
|
|
14
|
+
label: string;
|
|
15
|
+
value: string;
|
|
16
|
+
dpId: string;
|
|
17
|
+
enableDp: string;
|
|
18
|
+
cloudKey: any;
|
|
19
|
+
stringOn: any;
|
|
20
|
+
stringOff: any;
|
|
21
|
+
progressHook: [number, (time: number, t: any) => void];
|
|
22
|
+
}[];
|
|
@@ -1,131 +1,131 @@
|
|
|
1
|
-
import { useCallback, useEffect, useState } from "react"
|
|
2
|
-
import { useDeviceId, useDp } from "@ledvance/base/src/models/modules/NativePropsSlice"
|
|
3
|
-
import { Result } from "@ledvance/base/src/models/modules/Result"
|
|
4
|
-
import { dpItem } from "./TimerPage"
|
|
5
|
-
import { useCountDown as useCountDownAHook, useUpdateEffect } from 'ahooks'
|
|
6
|
-
import dayjs from "dayjs"
|
|
7
|
-
import { NativeApi } from "@ledvance/base/src/api/native"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export const useCountdowns = (dps: dpItem[]) => {
|
|
11
|
-
return dps.map(dp => {
|
|
12
|
-
return ({
|
|
13
|
-
countdown: useDp<number, (value: number) => Promise<Result<any>>>(dp.dpId),
|
|
14
|
-
enable: useDp<boolean, (value: boolean) => Promise<Result<any>>>(dp.enableDp),
|
|
15
|
-
...dp
|
|
16
|
-
})
|
|
17
|
-
})
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
type FormateProgressType = {
|
|
21
|
-
progressNumber: number
|
|
22
|
-
countdown: number
|
|
23
|
-
startTimer: (c: number, time: string) => Promise<void>
|
|
24
|
-
endTimer: () => void
|
|
25
|
-
}
|
|
26
|
-
const useFormateProgress: (dp: dpItem) => FormateProgressType = (dp) => {
|
|
27
|
-
const [countdown, setCountdown] = useDp<number, (value: number) => Promise<Result<any>>>(dp.dpId)
|
|
28
|
-
const [progress, setProgress] = useCountDownAHook({
|
|
29
|
-
interval: 1000,
|
|
30
|
-
onEnd: () => {
|
|
31
|
-
initTimerFn()
|
|
32
|
-
setCountdown(0)
|
|
33
|
-
},
|
|
34
|
-
})
|
|
35
|
-
const devId = useDeviceId()
|
|
36
|
-
const [cloudProgressNumber, setCloudProgressNumber] = useState(0)
|
|
37
|
-
const [progressNumber, setProgressNumber] = useState(0)
|
|
38
|
-
const [cloudData, setCloudData] = useState<any>()
|
|
39
|
-
const [isTrigger, setIsTeigger] = useState(false)
|
|
40
|
-
const getCloudJson = () => {
|
|
41
|
-
NativeApi.getJson(devId, dp.cloudKey).then(res => {
|
|
42
|
-
if (res.success && res.data) {
|
|
43
|
-
const result = JSON.parse(res.data)
|
|
44
|
-
setCloudData(result)
|
|
45
|
-
setCloudProgressNumber(result.progressAllNumber)
|
|
46
|
-
if (countdown > 0) setProgress(Date.now() + countdown * 1000)
|
|
47
|
-
}
|
|
48
|
-
})
|
|
49
|
-
}
|
|
50
|
-
useEffect(() => {
|
|
51
|
-
if(countdown > 0){
|
|
52
|
-
getCloudJson()
|
|
53
|
-
}
|
|
54
|
-
}, [])
|
|
55
|
-
|
|
56
|
-
useEffect(() => {
|
|
57
|
-
if (cloudProgressNumber > 0) {
|
|
58
|
-
const currentTime = dayjs().format('YYYY-MM-DD HH:mm:ss')
|
|
59
|
-
const remainingTime = Number(cloudData && dayjs(cloudData[getKey('StartTime', dp.dpId)] || 0).diff(currentTime))
|
|
60
|
-
const time = (cloudData && cloudData[getKey('Status', dp.dpId)] && remainingTime >= -1000) ? remainingTime : Number(progress.toString().slice(0, -3) + "000")
|
|
61
|
-
const conversion = (time / 1000) / cloudProgressNumber * 100
|
|
62
|
-
setProgressNumber(!isNaN(conversion) ? conversion : 0)
|
|
63
|
-
}
|
|
64
|
-
}, [progress])
|
|
65
|
-
|
|
66
|
-
useUpdateEffect(() =>{
|
|
67
|
-
if(countdown === 0){
|
|
68
|
-
setIsTeigger(false)
|
|
69
|
-
initTimerFn()
|
|
70
|
-
}
|
|
71
|
-
}, [countdown])
|
|
72
|
-
|
|
73
|
-
useUpdateEffect(() => {
|
|
74
|
-
if (countdown === 0) {
|
|
75
|
-
if(isTrigger){
|
|
76
|
-
NativeApi.putJson(devId, dp.cloudKey, JSON.stringify({ [getKey('Status', dp.dpId)]: false, [getKey('StartTime', dp.dpId)]: '', progressAllNumber: 0 })).then()
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if (countdown > 0 && !cloudData && !isTrigger) {
|
|
81
|
-
getCloudJson()
|
|
82
|
-
}
|
|
83
|
-
}, [countdown, cloudData])
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
const initTimerFn = useCallback(() =>{
|
|
88
|
-
setProgressNumber(0)
|
|
89
|
-
setCloudData(null)
|
|
90
|
-
setCloudProgressNumber(0)
|
|
91
|
-
setProgress(0)
|
|
92
|
-
}, [])
|
|
93
|
-
|
|
94
|
-
const getKey = (suffix: string, dpId: string) => {
|
|
95
|
-
const key = dpId + suffix
|
|
96
|
-
return key
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
const startTimer = async (time: number, t:string) => {
|
|
100
|
-
setIsTeigger(true)
|
|
101
|
-
await setCountdown(time)
|
|
102
|
-
const putData = { [getKey('Status', dp.dpId)]: true, [getKey('StartTime', dp.dpId)]: t, progressAllNumber: time }
|
|
103
|
-
await NativeApi.putJson(devId, dp.cloudKey, JSON.stringify(putData))
|
|
104
|
-
setCloudProgressNumber(time)
|
|
105
|
-
setProgress(Date.now() + time * 1000)
|
|
106
|
-
setCloudData(putData)
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
const endTimer = async () =>{
|
|
110
|
-
setIsTeigger(false)
|
|
111
|
-
await setCountdown(0)
|
|
112
|
-
NativeApi.putJson(devId, dp.cloudKey, JSON.stringify({ [getKey('Status', dp.dpId)]: false, [getKey('StartTime', dp.dpId)]: '', progressAllNumber: 0 })).then(() => {
|
|
113
|
-
initTimerFn()
|
|
114
|
-
})
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
return {
|
|
118
|
-
progressNumber,
|
|
119
|
-
countdown,
|
|
120
|
-
startTimer,
|
|
121
|
-
endTimer
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
export const useProgress = (dps: dpItem[]) => {
|
|
126
|
-
return dps.map(dp => ({
|
|
127
|
-
progressHook: useFormateProgress(dp),
|
|
128
|
-
enable: useDp(dp.enableDp)[0] as boolean,
|
|
129
|
-
...dp
|
|
130
|
-
}))
|
|
131
|
-
}
|
|
1
|
+
import { useCallback, useEffect, useState } from "react"
|
|
2
|
+
import { useDeviceId, useDp } from "@ledvance/base/src/models/modules/NativePropsSlice"
|
|
3
|
+
import { Result } from "@ledvance/base/src/models/modules/Result"
|
|
4
|
+
import { dpItem } from "./TimerPage"
|
|
5
|
+
import { useCountDown as useCountDownAHook, useUpdateEffect } from 'ahooks'
|
|
6
|
+
import dayjs from "dayjs"
|
|
7
|
+
import { NativeApi } from "@ledvance/base/src/api/native"
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
export const useCountdowns = (dps: dpItem[]) => {
|
|
11
|
+
return dps.map(dp => {
|
|
12
|
+
return ({
|
|
13
|
+
countdown: useDp<number, (value: number) => Promise<Result<any>>>(dp.dpId),
|
|
14
|
+
enable: useDp<boolean, (value: boolean) => Promise<Result<any>>>(dp.enableDp),
|
|
15
|
+
...dp
|
|
16
|
+
})
|
|
17
|
+
})
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
type FormateProgressType = {
|
|
21
|
+
progressNumber: number
|
|
22
|
+
countdown: number
|
|
23
|
+
startTimer: (c: number, time: string) => Promise<void>
|
|
24
|
+
endTimer: () => void
|
|
25
|
+
}
|
|
26
|
+
const useFormateProgress: (dp: dpItem) => FormateProgressType = (dp) => {
|
|
27
|
+
const [countdown, setCountdown] = useDp<number, (value: number) => Promise<Result<any>>>(dp.dpId)
|
|
28
|
+
const [progress, setProgress] = useCountDownAHook({
|
|
29
|
+
interval: 1000,
|
|
30
|
+
onEnd: () => {
|
|
31
|
+
initTimerFn()
|
|
32
|
+
setCountdown(0)
|
|
33
|
+
},
|
|
34
|
+
})
|
|
35
|
+
const devId = useDeviceId()
|
|
36
|
+
const [cloudProgressNumber, setCloudProgressNumber] = useState(0)
|
|
37
|
+
const [progressNumber, setProgressNumber] = useState(0)
|
|
38
|
+
const [cloudData, setCloudData] = useState<any>()
|
|
39
|
+
const [isTrigger, setIsTeigger] = useState(false)
|
|
40
|
+
const getCloudJson = () => {
|
|
41
|
+
NativeApi.getJson(devId, dp.cloudKey).then(res => {
|
|
42
|
+
if (res.success && res.data) {
|
|
43
|
+
const result = JSON.parse(res.data)
|
|
44
|
+
setCloudData(result)
|
|
45
|
+
setCloudProgressNumber(result.progressAllNumber)
|
|
46
|
+
if (countdown > 0) setProgress(Date.now() + countdown * 1000)
|
|
47
|
+
}
|
|
48
|
+
})
|
|
49
|
+
}
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
if(countdown > 0){
|
|
52
|
+
getCloudJson()
|
|
53
|
+
}
|
|
54
|
+
}, [])
|
|
55
|
+
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
if (cloudProgressNumber > 0) {
|
|
58
|
+
const currentTime = dayjs().format('YYYY-MM-DD HH:mm:ss')
|
|
59
|
+
const remainingTime = Number(cloudData && dayjs(cloudData[getKey('StartTime', dp.dpId)] || 0).diff(currentTime))
|
|
60
|
+
const time = (cloudData && cloudData[getKey('Status', dp.dpId)] && remainingTime >= -1000) ? remainingTime : Number(progress.toString().slice(0, -3) + "000")
|
|
61
|
+
const conversion = (time / 1000) / cloudProgressNumber * 100
|
|
62
|
+
setProgressNumber(!isNaN(conversion) ? conversion : 0)
|
|
63
|
+
}
|
|
64
|
+
}, [progress])
|
|
65
|
+
|
|
66
|
+
useUpdateEffect(() =>{
|
|
67
|
+
if(countdown === 0){
|
|
68
|
+
setIsTeigger(false)
|
|
69
|
+
initTimerFn()
|
|
70
|
+
}
|
|
71
|
+
}, [countdown])
|
|
72
|
+
|
|
73
|
+
useUpdateEffect(() => {
|
|
74
|
+
if (countdown === 0) {
|
|
75
|
+
if(isTrigger){
|
|
76
|
+
NativeApi.putJson(devId, dp.cloudKey, JSON.stringify({ [getKey('Status', dp.dpId)]: false, [getKey('StartTime', dp.dpId)]: '', progressAllNumber: 0 })).then()
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (countdown > 0 && !cloudData && !isTrigger) {
|
|
81
|
+
getCloudJson()
|
|
82
|
+
}
|
|
83
|
+
}, [countdown, cloudData])
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
const initTimerFn = useCallback(() =>{
|
|
88
|
+
setProgressNumber(0)
|
|
89
|
+
setCloudData(null)
|
|
90
|
+
setCloudProgressNumber(0)
|
|
91
|
+
setProgress(0)
|
|
92
|
+
}, [])
|
|
93
|
+
|
|
94
|
+
const getKey = (suffix: string, dpId: string) => {
|
|
95
|
+
const key = dpId + suffix
|
|
96
|
+
return key
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const startTimer = async (time: number, t:string) => {
|
|
100
|
+
setIsTeigger(true)
|
|
101
|
+
await setCountdown(time)
|
|
102
|
+
const putData = { [getKey('Status', dp.dpId)]: true, [getKey('StartTime', dp.dpId)]: t, progressAllNumber: time }
|
|
103
|
+
await NativeApi.putJson(devId, dp.cloudKey, JSON.stringify(putData))
|
|
104
|
+
setCloudProgressNumber(time)
|
|
105
|
+
setProgress(Date.now() + time * 1000)
|
|
106
|
+
setCloudData(putData)
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const endTimer = async () =>{
|
|
110
|
+
setIsTeigger(false)
|
|
111
|
+
await setCountdown(0)
|
|
112
|
+
NativeApi.putJson(devId, dp.cloudKey, JSON.stringify({ [getKey('Status', dp.dpId)]: false, [getKey('StartTime', dp.dpId)]: '', progressAllNumber: 0 })).then(() => {
|
|
113
|
+
initTimerFn()
|
|
114
|
+
})
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return {
|
|
118
|
+
progressNumber,
|
|
119
|
+
countdown,
|
|
120
|
+
startTimer,
|
|
121
|
+
endTimer
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export const useProgress = (dps: dpItem[]) => {
|
|
126
|
+
return dps.map(dp => ({
|
|
127
|
+
progressHook: useFormateProgress(dp),
|
|
128
|
+
enable: useDp(dp.enableDp)[0] as boolean,
|
|
129
|
+
...dp
|
|
130
|
+
}))
|
|
131
|
+
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
export declare const ui_biz_routerKey: {
|
|
2
|
-
ui_biz_time_schedule: string;
|
|
3
|
-
ui_biz_time_schedule_edit: string;
|
|
4
|
-
ui_biz_mood: string;
|
|
5
|
-
ui_biz_mood_add: string;
|
|
6
|
-
ui_biz_static_mood_edit: string;
|
|
7
|
-
ui_biz_dynamic_mood_edit: string;
|
|
8
|
-
ui_biz_timer: string;
|
|
9
|
-
bi_biz_biological: string;
|
|
10
|
-
bi_biz_biological_edit: string;
|
|
11
|
-
bi_biz_biological_icon_select: string;
|
|
12
|
-
ui_biz_sleep_wakeUp: string;
|
|
13
|
-
ui_biz_sleep_wakeUp_edit: string;
|
|
14
|
-
ui_biz_music: string;
|
|
15
|
-
};
|
|
1
|
+
export declare const ui_biz_routerKey: {
|
|
2
|
+
ui_biz_time_schedule: string;
|
|
3
|
+
ui_biz_time_schedule_edit: string;
|
|
4
|
+
ui_biz_mood: string;
|
|
5
|
+
ui_biz_mood_add: string;
|
|
6
|
+
ui_biz_static_mood_edit: string;
|
|
7
|
+
ui_biz_dynamic_mood_edit: string;
|
|
8
|
+
ui_biz_timer: string;
|
|
9
|
+
bi_biz_biological: string;
|
|
10
|
+
bi_biz_biological_edit: string;
|
|
11
|
+
bi_biz_biological_icon_select: string;
|
|
12
|
+
ui_biz_sleep_wakeUp: string;
|
|
13
|
+
ui_biz_sleep_wakeUp_edit: string;
|
|
14
|
+
ui_biz_music: string;
|
|
15
|
+
};
|
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
export const ui_biz_routerKey = {
|
|
2
|
-
'ui_biz_time_schedule': 'ui_biz_time_schedule',
|
|
3
|
-
'ui_biz_time_schedule_edit': 'ui_biz_time_schedule_edit',
|
|
4
|
-
'ui_biz_fantasy_mood': 'ui_biz_fantasy_mood',
|
|
5
|
-
'ui_biz_fantasy_mood_edit': 'ui_biz_fantasy_mood_edit',
|
|
6
|
-
'ui_biz_mood': 'ui_biz_mood',
|
|
7
|
-
'ui_biz_mood_add': 'ui-biz_mood_add',
|
|
8
|
-
'ui_biz_static_mood_edit': 'ui_biz_static_mood_edit',
|
|
9
|
-
'ui_biz_dynamic_mood_edit': 'ui_biz_dynamic_mood_edit',
|
|
10
|
-
'ui_biz_dynamic_mix_mood_edit': 'ui_biz_dynamic_mix_mood_edit',
|
|
11
|
-
'ui_biz_mix_mood': 'ui_biz_mix_mood',
|
|
12
|
-
'ui_biz_mix_mood_edit': 'ui_biz_mix_mood_edit',
|
|
13
|
-
'ui_biz_mix_mood_add': 'ui_biz_mix_mood_add',
|
|
14
|
-
'ui_biz_timer': 'ui_biz_timer',
|
|
15
|
-
'bi_biz_biological': 'bi_biz_biological',
|
|
16
|
-
'bi_biz_biological_edit': 'bi_biz_biological_edit',
|
|
17
|
-
'bi_biz_biological_icon_select': 'bi_biz_biological_icon_select',
|
|
18
|
-
'ui_biz_sleep_wakeUp': 'ui_biz_sleep_wakeUp',
|
|
19
|
-
'ui_biz_sleep_wakeUp_edit': 'ui_biz_sleep_wakeUp_edit',
|
|
20
|
-
'ui_biz_sleep_wakeUp_new': 'ui_biz_sleep_wakeUp_new',
|
|
21
|
-
'ui_biz_sleep_wakeUp_edit_new': 'ui_biz_sleep_wakeUp_edit_new',
|
|
22
|
-
'ui_biz_music': 'ui_biz_music',
|
|
23
|
-
'ui_biz_select_page': 'ui_biz_select_page',
|
|
24
|
-
'ui_biz_fixed_time': 'ui_biz_fixed_time',
|
|
25
|
-
'ui_biz_fixed_time_edit': 'ui_biz_fixed_time_edit',
|
|
26
|
-
'ui_biz_random_time': 'ui_biz_random_time',
|
|
27
|
-
'ui_biz_random_time_edit': 'ui_biz_random_time_edit',
|
|
28
|
-
'ui_biz_history': 'ui_biz_history',
|
|
29
|
-
'ui_biz_power_behavior': 'ui_biz_power_behavior',
|
|
30
|
-
'ui_biz_flag_page': 'ui_biz_flag_page',
|
|
31
|
-
'ui_biz_flag_page_edit': 'ui_biz_flag_page_edit',
|
|
32
|
-
'ui_biz_time_schedule_new': 'ui_biz_time_schedule_new',
|
|
33
|
-
'ui_biz_time_schedule_edit_new': 'ui_biz_time_schedule_edit_new',
|
|
34
|
-
'ui_biz_fixed_time_new': 'ui_biz_fixed_time_new',
|
|
35
|
-
'ui_biz_fixed_time_edit_new': 'ui_biz_fixed_time_edit_new',
|
|
36
|
-
'ui_biz_random_time_new': 'ui_biz_random_time_new',
|
|
37
|
-
'ui_biz_random_time_edit_new': 'ui_biz_random_time_edit_new',
|
|
38
|
-
'ui_biz_energy_consumption': 'ui_biz_energy_consumption',
|
|
39
|
-
'ui_biz_energy_consumption_detail': 'ui_biz_energy_consumption_detail',
|
|
40
|
-
'ui_biz_energy_consumption_chart': 'ui_biz_energy_consumption_chart',
|
|
41
|
-
'ui_biz_power_behavior_plug': 'ui_biz_power_behavior_plug',
|
|
42
|
-
'ui_biz_switch_inching': 'ui_biz_switch_inching',
|
|
43
|
-
'ui_biz_light_mode': 'ui_biz_light_mode',
|
|
44
|
-
'ui_biz_overcharge_switch': 'ui_biz_overcharge_switch',
|
|
45
|
-
'ui_biz_child_lock': 'ui_biz_child_lock',
|
|
46
|
-
}
|
|
1
|
+
export const ui_biz_routerKey = {
|
|
2
|
+
'ui_biz_time_schedule': 'ui_biz_time_schedule',
|
|
3
|
+
'ui_biz_time_schedule_edit': 'ui_biz_time_schedule_edit',
|
|
4
|
+
'ui_biz_fantasy_mood': 'ui_biz_fantasy_mood',
|
|
5
|
+
'ui_biz_fantasy_mood_edit': 'ui_biz_fantasy_mood_edit',
|
|
6
|
+
'ui_biz_mood': 'ui_biz_mood',
|
|
7
|
+
'ui_biz_mood_add': 'ui-biz_mood_add',
|
|
8
|
+
'ui_biz_static_mood_edit': 'ui_biz_static_mood_edit',
|
|
9
|
+
'ui_biz_dynamic_mood_edit': 'ui_biz_dynamic_mood_edit',
|
|
10
|
+
'ui_biz_dynamic_mix_mood_edit': 'ui_biz_dynamic_mix_mood_edit',
|
|
11
|
+
'ui_biz_mix_mood': 'ui_biz_mix_mood',
|
|
12
|
+
'ui_biz_mix_mood_edit': 'ui_biz_mix_mood_edit',
|
|
13
|
+
'ui_biz_mix_mood_add': 'ui_biz_mix_mood_add',
|
|
14
|
+
'ui_biz_timer': 'ui_biz_timer',
|
|
15
|
+
'bi_biz_biological': 'bi_biz_biological',
|
|
16
|
+
'bi_biz_biological_edit': 'bi_biz_biological_edit',
|
|
17
|
+
'bi_biz_biological_icon_select': 'bi_biz_biological_icon_select',
|
|
18
|
+
'ui_biz_sleep_wakeUp': 'ui_biz_sleep_wakeUp',
|
|
19
|
+
'ui_biz_sleep_wakeUp_edit': 'ui_biz_sleep_wakeUp_edit',
|
|
20
|
+
'ui_biz_sleep_wakeUp_new': 'ui_biz_sleep_wakeUp_new',
|
|
21
|
+
'ui_biz_sleep_wakeUp_edit_new': 'ui_biz_sleep_wakeUp_edit_new',
|
|
22
|
+
'ui_biz_music': 'ui_biz_music',
|
|
23
|
+
'ui_biz_select_page': 'ui_biz_select_page',
|
|
24
|
+
'ui_biz_fixed_time': 'ui_biz_fixed_time',
|
|
25
|
+
'ui_biz_fixed_time_edit': 'ui_biz_fixed_time_edit',
|
|
26
|
+
'ui_biz_random_time': 'ui_biz_random_time',
|
|
27
|
+
'ui_biz_random_time_edit': 'ui_biz_random_time_edit',
|
|
28
|
+
'ui_biz_history': 'ui_biz_history',
|
|
29
|
+
'ui_biz_power_behavior': 'ui_biz_power_behavior',
|
|
30
|
+
'ui_biz_flag_page': 'ui_biz_flag_page',
|
|
31
|
+
'ui_biz_flag_page_edit': 'ui_biz_flag_page_edit',
|
|
32
|
+
'ui_biz_time_schedule_new': 'ui_biz_time_schedule_new',
|
|
33
|
+
'ui_biz_time_schedule_edit_new': 'ui_biz_time_schedule_edit_new',
|
|
34
|
+
'ui_biz_fixed_time_new': 'ui_biz_fixed_time_new',
|
|
35
|
+
'ui_biz_fixed_time_edit_new': 'ui_biz_fixed_time_edit_new',
|
|
36
|
+
'ui_biz_random_time_new': 'ui_biz_random_time_new',
|
|
37
|
+
'ui_biz_random_time_edit_new': 'ui_biz_random_time_edit_new',
|
|
38
|
+
'ui_biz_energy_consumption': 'ui_biz_energy_consumption',
|
|
39
|
+
'ui_biz_energy_consumption_detail': 'ui_biz_energy_consumption_detail',
|
|
40
|
+
'ui_biz_energy_consumption_chart': 'ui_biz_energy_consumption_chart',
|
|
41
|
+
'ui_biz_power_behavior_plug': 'ui_biz_power_behavior_plug',
|
|
42
|
+
'ui_biz_switch_inching': 'ui_biz_switch_inching',
|
|
43
|
+
'ui_biz_light_mode': 'ui_biz_light_mode',
|
|
44
|
+
'ui_biz_overcharge_switch': 'ui_biz_overcharge_switch',
|
|
45
|
+
'ui_biz_child_lock': 'ui_biz_child_lock',
|
|
46
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { NavigationProp, ParamListBase } from '@react-navigation/native';
|
|
2
|
-
import { AddMoodPageParams } from 'modules/mood/AddMoodPage';
|
|
3
|
-
import { StaticMoodEditorPageParams } from 'modules/mood/StaticMoodEditorPage';
|
|
4
|
-
import { StackNavigationProp } from '@react-navigation/stack';
|
|
5
|
-
import { SelectPageParams } from 'modules/select/SelectPage';
|
|
6
|
-
export declare function toStaticMoodEditorPage(navigation: NavigationProp<ParamListBase>, params: StaticMoodEditorPageParams): void;
|
|
7
|
-
export declare function toDynamicMoodEditorPage(navigation: NavigationProp<ParamListBase>, params: StaticMoodEditorPageParams): void;
|
|
8
|
-
export declare function toAddMoodPage(navigation: NavigationProp<ParamListBase>, params: AddMoodPageParams): void;
|
|
9
|
-
export declare function toSelectPage<T>(navigation: StackNavigationProp<any>, params: SelectPageParams<T>): void;
|
|
1
|
+
import { NavigationProp, ParamListBase } from '@react-navigation/native';
|
|
2
|
+
import { AddMoodPageParams } from 'modules/mood/AddMoodPage';
|
|
3
|
+
import { StaticMoodEditorPageParams } from 'modules/mood/StaticMoodEditorPage';
|
|
4
|
+
import { StackNavigationProp } from '@react-navigation/stack';
|
|
5
|
+
import { SelectPageParams } from 'modules/select/SelectPage';
|
|
6
|
+
export declare function toStaticMoodEditorPage(navigation: NavigationProp<ParamListBase>, params: StaticMoodEditorPageParams): void;
|
|
7
|
+
export declare function toDynamicMoodEditorPage(navigation: NavigationProp<ParamListBase>, params: StaticMoodEditorPageParams): void;
|
|
8
|
+
export declare function toAddMoodPage(navigation: NavigationProp<ParamListBase>, params: AddMoodPageParams): void;
|
|
9
|
+
export declare function toSelectPage<T>(navigation: StackNavigationProp<any>, params: SelectPageParams<T>): void;
|
package/src/navigation/tools.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import {NavigationProp, ParamListBase} from '@react-navigation/native'
|
|
2
|
-
import { AddMoodPageParams } from 'modules/mood/AddMoodPage'
|
|
3
|
-
import { StaticMoodEditorPageParams } from 'modules/mood/StaticMoodEditorPage'
|
|
4
|
-
import {StackNavigationProp} from '@react-navigation/stack'
|
|
5
|
-
import { SelectPageParams } from 'modules/select/SelectPage'
|
|
6
|
-
import { ui_biz_routerKey } from './Routers'
|
|
7
|
-
|
|
8
|
-
export function toStaticMoodEditorPage(navigation: NavigationProp<ParamListBase>, params: StaticMoodEditorPageParams) {
|
|
9
|
-
navigation.navigate(ui_biz_routerKey.ui_biz_static_mood_edit, params)
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function toDynamicMoodEditorPage(navigation: NavigationProp<ParamListBase>, params: StaticMoodEditorPageParams) {
|
|
13
|
-
navigation.navigate(ui_biz_routerKey.ui_biz_dynamic_mood_edit, params)
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function toAddMoodPage(navigation: NavigationProp<ParamListBase>, params: AddMoodPageParams) {
|
|
17
|
-
navigation.navigate(ui_biz_routerKey.ui_biz_mood_add, params)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export function toSelectPage<T>(navigation: StackNavigationProp<any>, params: SelectPageParams<T>) {
|
|
21
|
-
navigation.push(ui_biz_routerKey.ui_biz_select_page, params)
|
|
1
|
+
import {NavigationProp, ParamListBase} from '@react-navigation/native'
|
|
2
|
+
import { AddMoodPageParams } from 'modules/mood/AddMoodPage'
|
|
3
|
+
import { StaticMoodEditorPageParams } from 'modules/mood/StaticMoodEditorPage'
|
|
4
|
+
import {StackNavigationProp} from '@react-navigation/stack'
|
|
5
|
+
import { SelectPageParams } from 'modules/select/SelectPage'
|
|
6
|
+
import { ui_biz_routerKey } from './Routers'
|
|
7
|
+
|
|
8
|
+
export function toStaticMoodEditorPage(navigation: NavigationProp<ParamListBase>, params: StaticMoodEditorPageParams) {
|
|
9
|
+
navigation.navigate(ui_biz_routerKey.ui_biz_static_mood_edit, params)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function toDynamicMoodEditorPage(navigation: NavigationProp<ParamListBase>, params: StaticMoodEditorPageParams) {
|
|
13
|
+
navigation.navigate(ui_biz_routerKey.ui_biz_dynamic_mood_edit, params)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function toAddMoodPage(navigation: NavigationProp<ParamListBase>, params: AddMoodPageParams) {
|
|
17
|
+
navigation.navigate(ui_biz_routerKey.ui_biz_mood_add, params)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function toSelectPage<T>(navigation: StackNavigationProp<any>, params: SelectPageParams<T>) {
|
|
21
|
+
navigation.push(ui_biz_routerKey.ui_biz_select_page, params)
|
|
22
22
|
}
|
|
@@ -30,7 +30,7 @@ export const useBiorhythm: UseBiorhythmType = (dpKey: string, disabledFeature?:
|
|
|
30
30
|
const deviceId = useDeviceId()
|
|
31
31
|
const [biorhythmState, setBiorhythmState] = useState(dp2Obj(dp))
|
|
32
32
|
|
|
33
|
-
const getBiorhythm = useCallback(() =>{
|
|
33
|
+
const getBiorhythm = useCallback(() => {
|
|
34
34
|
const biorhythm = dp2Obj(dp)
|
|
35
35
|
getRemoteBiorhythm(deviceId, biorhythm).then(res => {
|
|
36
36
|
if (res.success && res.data) {
|
|
@@ -45,28 +45,28 @@ export const useBiorhythm: UseBiorhythmType = (dpKey: string, disabledFeature?:
|
|
|
45
45
|
}, [dp])
|
|
46
46
|
|
|
47
47
|
useEffect(() => {
|
|
48
|
-
if(disabledFeature) return
|
|
49
|
-
biorhythmTimer = setTimeout(() =>{
|
|
48
|
+
if (disabledFeature) return
|
|
49
|
+
biorhythmTimer = setTimeout(() => {
|
|
50
50
|
getBiorhythm()
|
|
51
51
|
}, 250)
|
|
52
52
|
|
|
53
|
-
return () =>{
|
|
53
|
+
return () => {
|
|
54
54
|
clearTimeout(biorhythmTimer)
|
|
55
55
|
}
|
|
56
56
|
}, [])
|
|
57
57
|
|
|
58
|
-
useUpdateEffect(() =>{
|
|
58
|
+
useUpdateEffect(() => {
|
|
59
59
|
getBiorhythm()
|
|
60
60
|
}, [dp])
|
|
61
61
|
|
|
62
|
-
const setBiorhythmFn = async (biorhythmObj: BiorhythmBean, pushFeature: boolean = true) =>{
|
|
62
|
+
const setBiorhythmFn = async (biorhythmObj: BiorhythmBean, pushFeature: boolean = true) => {
|
|
63
63
|
const dpValue = obj2Dp(biorhythmObj)
|
|
64
|
-
if(pushFeature){
|
|
64
|
+
if (pushFeature) {
|
|
65
65
|
const putFeatureRes = await putFeature(deviceId, biorhythmFeatureId, vo2Dto(biorhythmObj))
|
|
66
66
|
if (putFeatureRes.result) {
|
|
67
67
|
return setDp(dpValue)
|
|
68
68
|
}
|
|
69
|
-
}else{
|
|
69
|
+
} else {
|
|
70
70
|
return setDp(dpValue)
|
|
71
71
|
}
|
|
72
72
|
return { success: false }
|
|
@@ -95,10 +95,61 @@ async function getRemoteBiorhythm(deviceId: string, defBiorhythmState: Biorhythm
|
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
|
|
98
|
+
interface RhythmModeSuspendState {
|
|
99
|
+
status: boolean
|
|
100
|
+
suspendTime: string
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export const useRhythmSuspend = (dp: string): [boolean, () => void, (v: string | undefined) => Promise<Result<any>>] => {
|
|
104
|
+
const [suspendTime, setSuspendTime] = useState<string | undefined>()
|
|
105
|
+
const [biorhythm] = useBiorhythm(dp, true)
|
|
106
|
+
const devId = useDeviceId()
|
|
99
107
|
const currentTime = dayjs().format('YYYY-MM-DD')
|
|
100
|
-
|
|
101
|
-
|
|
108
|
+
|
|
109
|
+
useEffect(() => {
|
|
110
|
+
getSuspendTime()
|
|
111
|
+
}, [])
|
|
112
|
+
|
|
113
|
+
useUpdateEffect(() => {
|
|
114
|
+
if (biorhythm.enable) {
|
|
115
|
+
if (suspendTime !== currentTime) {
|
|
116
|
+
getSuspendTime()
|
|
117
|
+
}
|
|
118
|
+
} else {
|
|
119
|
+
if (suspendTime !== undefined) {
|
|
120
|
+
setSuspendTime(undefined)
|
|
121
|
+
putSuspendTime(undefined)
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}, [biorhythm.enable, suspendTime])
|
|
125
|
+
|
|
126
|
+
const getSuspendTime = useCallback(() => {
|
|
127
|
+
if (suspendTime !== currentTime) {
|
|
128
|
+
NativeApi.getJson(devId, 'suspendTime').then(res => {
|
|
129
|
+
if (res.success && res.data) {
|
|
130
|
+
const suspend = JSON.parse(res.data) as RhythmModeSuspendState
|
|
131
|
+
setSuspendTime(suspend.suspendTime)
|
|
132
|
+
}
|
|
133
|
+
})
|
|
134
|
+
}
|
|
135
|
+
}, [suspendTime])
|
|
136
|
+
|
|
137
|
+
const putSuspendTime = async (tiem?: string) => {
|
|
138
|
+
return await NativeApi.putJson(devId, 'suspendTime', JSON.stringify({ status: true, suspendTime: tiem }))
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const setRhythSuspend = useCallback(async (time: string | undefined) => {
|
|
142
|
+
if (time === suspendTime) return { success: true }
|
|
143
|
+
if (!biorhythm.enable) {
|
|
144
|
+
setSuspendTime(undefined)
|
|
145
|
+
return await putSuspendTime(undefined)
|
|
146
|
+
}
|
|
147
|
+
const res = await putSuspendTime(time)
|
|
148
|
+
setSuspendTime(time)
|
|
149
|
+
return res
|
|
150
|
+
}, [suspendTime, biorhythm.enable])
|
|
151
|
+
|
|
152
|
+
return [suspendTime === currentTime, getSuspendTime, setRhythSuspend]
|
|
102
153
|
}
|
|
103
154
|
|
|
104
155
|
export function dp2Obj(dp: string): BiorhythmBean {
|
|
@@ -14,7 +14,6 @@ import { cloneDeep, sortBy } from 'lodash'
|
|
|
14
14
|
import iconList from './iconListData'
|
|
15
15
|
import pIdList from './pIdList'
|
|
16
16
|
import {
|
|
17
|
-
useDeviceId,
|
|
18
17
|
useDeviceInfo,
|
|
19
18
|
useSystemTimeFormate,
|
|
20
19
|
} from '@ledvance/base/src/models/modules/NativePropsSlice'
|
|
@@ -25,7 +24,7 @@ import BiologicalRes from './res/BiologicalRes'
|
|
|
25
24
|
import { cctToColor } from '@ledvance/base/src/utils/cctUtils'
|
|
26
25
|
import { setDataSource } from '@ledvance/base/src/components/weekSelect'
|
|
27
26
|
import { BiorhythmEditPageParams } from './BiorhythmEditPage'
|
|
28
|
-
import { useBiorhythm
|
|
27
|
+
import { useBiorhythm } from './BiorhythmActions'
|
|
29
28
|
import { convertMinutesTo12HourFormat, showDialog as showCommonDialog } from '@ledvance/base/src/utils/common'
|
|
30
29
|
import TimeCircular from './circular/TimeCircular'
|
|
31
30
|
import Page from '@ledvance/base/src/components/Page'
|
|
@@ -62,7 +61,6 @@ const BiorhythmPage = () => {
|
|
|
62
61
|
const params = useParams<BiorhythmPageParams>()
|
|
63
62
|
const navigation = useNavigation()
|
|
64
63
|
const [biorhythm, setBiorhythm] = useBiorhythm(params.biorhythmDpCode)
|
|
65
|
-
const deviceId = useDeviceId()
|
|
66
64
|
const deviceInfo = useDeviceInfo()
|
|
67
65
|
const { productId } = deviceInfo
|
|
68
66
|
const is24Hour = useSystemTimeFormate()
|
|
@@ -102,7 +100,6 @@ const BiorhythmPage = () => {
|
|
|
102
100
|
state.loading = true
|
|
103
101
|
const planList = state.planList?.map(item => { return { ...item, icon: `${item.icon}` } })
|
|
104
102
|
.sort((a, b) => a.time - b.time);
|
|
105
|
-
await userOperation(deviceId, false)
|
|
106
103
|
const res = await setBiorhythm(cloneDeep({ ...state, planList }), pushFeature)
|
|
107
104
|
state.loading = false
|
|
108
105
|
if (res.success) {
|