@ledvance/group-ui-biz-bundle 1.0.36 → 1.0.38
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/package.json +1 -1
- package/src/modules/biorhythm/BiorhythmActions.ts +216 -0
- package/src/modules/biorhythm/BiorhythmBean.ts +230 -0
- package/src/modules/biorhythm/BiorhythmDetailPage.tsx +261 -0
- package/src/modules/biorhythm/BiorhythmPage.tsx +706 -0
- package/src/modules/biorhythm/IconSelect.tsx +84 -0
- package/src/modules/biorhythm/circular/ItemIcon.d.ts +22 -0
- package/src/modules/biorhythm/circular/ItemIcon.tsx +173 -0
- package/src/modules/biorhythm/circular/Progress.d.ts +24 -0
- package/src/modules/biorhythm/circular/Progress.tsx +412 -0
- package/src/modules/biorhythm/circular/TimeCircular.d.ts +11 -0
- package/src/modules/biorhythm/circular/TimeCircular.tsx +70 -0
- package/src/modules/biorhythm/circular/biorhythm_plantimer.png +0 -0
- package/src/modules/biorhythm/circular/rhythm_icon.png +0 -0
- package/src/modules/biorhythm/iconListData.ts +30 -0
- package/src/modules/biorhythm/pIdList.ts +36 -0
- package/src/modules/biorhythm/res/BiologicalRes.d.ts +43 -0
- package/src/modules/biorhythm/res/BiologicalRes.ts +42 -0
- package/src/modules/biorhythm/res/Biological_Rhythm.png +0 -0
- package/src/modules/biorhythm/res/Biological_Rhythm_12.png +0 -0
- package/src/modules/biorhythm/res/Biological_Rhythm_new.png +0 -0
- package/src/modules/biorhythm/res/Biological_Rhythm_new_12.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedAccountGroups.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedAccountGroups@2x.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedAccountGroups@3x.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedArrowsNavAdd.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedArrowsNavAdd@2x.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedArrowsNavAdd@3x.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedArrowsNavArrowForwardIos.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedArrowsNavArrowForwardIos@2x.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedArrowsNavArrowForwardIos@3x.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedBuildingsHome.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedBuildingsHome@2x.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedBuildingsHome@3x.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedEditorFavoriteBorder.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedEditorFavoriteBorder@2x.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedEditorFavoriteBorder@3x.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedOtherBed.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedOtherBed@2x.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedOtherBed@3x.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedOtherBusinessCenter.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedOtherBusinessCenter@2x.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedOtherBusinessCenter@3x.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedOtherChair.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedOtherChair@2x.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedOtherChair@3x.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedOtherCoffee.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedOtherCoffee@2x.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedOtherCoffee@3x.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedOtherDirectionsCar.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedOtherDirectionsCar@2x.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedOtherDirectionsCar@3x.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedOtherFitnessCenter.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedOtherFitnessCenter@2x.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedOtherFitnessCenter@3x.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedOtherHeadphones.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedOtherHeadphones@2x.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedOtherHeadphones@3x.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedOtherMenuBook.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedOtherMenuBook@2x.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedOtherMenuBook@3x.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedOtherMusicNote.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedOtherMusicNote@2x.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedOtherMusicNote@3x.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedOtherNotificationsNone.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedOtherNotificationsNone@2x.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedOtherNotificationsNone@3x.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedOtherPottedPlant.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedOtherPottedPlant@2x.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedOtherPottedPlant@3x.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedOtherRestaurant.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedOtherRestaurant@2x.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedOtherRestaurant@3x.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedOtherSentimentSatisfied.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedOtherSentimentSatisfied@2x.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedOtherSentimentSatisfied@3x.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedOtherSportsEsports.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedOtherSportsEsports@2x.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedOtherSportsEsports@3x.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedOtherTv.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedOtherTv@2x.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedOtherTv@3x.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedTimeAccessAlarm.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedTimeAccessAlarm@2x.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedTimeAccessAlarm@3x.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedWheatherBedtime.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedWheatherBedtime@2x.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedWheatherBedtime@3x.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedWheatherPartlyCloudyDay.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedWheatherPartlyCloudyDay@2x.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedWheatherPartlyCloudyDay@3x.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedWheatherStarOutline.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedWheatherStarOutline@2x.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedWheatherStarOutline@3x.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedWheatherWbSunny.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedWheatherWbSunny@2x.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedWheatherWbSunny@3x.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedWheatherWbTwilight.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedWheatherWbTwilight@2x.png +0 -0
- package/src/modules/biorhythm/res/iconsMaterialOutlinedWheatherWbTwilight@3x.png +0 -0
- package/src/modules/music/MusicActions.ts +61 -0
- package/src/modules/music/MusicDataBean.ts +292 -0
- package/src/modules/music/MusicManager.ts +206 -0
- package/src/modules/music/MusicPage.tsx +202 -0
- package/src/modules/music/res/app_music_ball@2x.png +0 -0
- package/src/modules/music/res/app_music_ball@3x.png +0 -0
- package/src/modules/music/res/app_music_game@2x.png +0 -0
- package/src/modules/music/res/app_music_game@3x.png +0 -0
- package/src/modules/music/res/app_music_music@2x.png +0 -0
- package/src/modules/music/res/app_music_music@3x.png +0 -0
- package/src/modules/music/res/app_music_romantic@2x.png +0 -0
- package/src/modules/music/res/app_music_romantic@3x.png +0 -0
- package/src/modules/music/res/iconsMaterialOutlinedArrowsNavCheck.png +0 -0
- package/src/modules/music/res/iconsMaterialOutlinedArrowsNavCheck@2x.png +0 -0
- package/src/modules/music/res/iconsMaterialOutlinedArrowsNavCheck@3x.png +0 -0
- package/src/modules/music/res/illustrationsFeaturesMusic.png +0 -0
- package/src/modules/music/res/illustrationsFeaturesMusic@2x.png +0 -0
- package/src/modules/music/res/illustrationsFeaturesMusic@3x.png +0 -0
- package/src/modules/music/res/illustrationsFeaturesMusicDisabled.png +0 -0
- package/src/modules/music/res/illustrationsFeaturesMusicDisabled@2x.png +0 -0
- package/src/modules/music/res/illustrationsFeaturesMusicDisabled@3x.png +0 -0
- package/src/modules/music/res/index.d.ts +10 -0
- package/src/modules/music/res/index.ts +9 -0
- package/src/modules/randomTimingForLight/RandomTimingForLightPage.tsx +1 -1
- package/src/navigation/Routers.ts +46 -0
package/package.json
CHANGED
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BiorhythmBean,
|
|
3
|
+
BiorhythmGradientType,
|
|
4
|
+
colorTemperatureValue,
|
|
5
|
+
getDefBiorhythmUIState,
|
|
6
|
+
Period,
|
|
7
|
+
Plan,
|
|
8
|
+
} from './BiorhythmBean'
|
|
9
|
+
import { useFeatureHook} from '@ledvance/base/src/models/modules/NativePropsSlice'
|
|
10
|
+
import { NativeApi } from '@ledvance/base/src/api/native'
|
|
11
|
+
import {hex2Int, spliceByStep} from '@ledvance/base/src/utils/common'
|
|
12
|
+
import I18n from '@ledvance/base/src/i18n'
|
|
13
|
+
import BiologicalRes from './res/BiologicalRes'
|
|
14
|
+
import dayjs from 'dayjs'
|
|
15
|
+
|
|
16
|
+
interface BiorhythmConfig {
|
|
17
|
+
rhythm_mode: BiorhythmBean
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const useBiorhythm = () => {
|
|
21
|
+
return useFeatureHook<BiorhythmConfig, BiorhythmBean>('rhythm_mode', getDefBiorhythmUIState(), (val) => {
|
|
22
|
+
return obj2Dp(val)
|
|
23
|
+
})
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const userOperation = async (deviceId: string, value: boolean) => {
|
|
27
|
+
const currentTime = dayjs().format('YYYY-MM-DD')
|
|
28
|
+
const json = JSON.stringify({status: value, suspendTime: value && currentTime || ''})
|
|
29
|
+
return await NativeApi.putJson(deviceId, 'suspendTime', json)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function dp2Obj(dp: string): BiorhythmBean {
|
|
33
|
+
if (!dp || dp === '0000000000') {
|
|
34
|
+
return dp2Obj('0000007f0501060000000000000001061e00000000141901090000000000646401140000000000503201171e000000000000')
|
|
35
|
+
}
|
|
36
|
+
let dpCopy = dp
|
|
37
|
+
// 版本
|
|
38
|
+
hex2Int(dpCopy.slice(0, 2))
|
|
39
|
+
dpCopy = dpCopy.slice(2)
|
|
40
|
+
// 开关
|
|
41
|
+
const enable = hex2Int(dpCopy.slice(0, 2)) === 1
|
|
42
|
+
dpCopy = dpCopy.slice(2)
|
|
43
|
+
// 模式:00 全程渐变,0F 直接渐变
|
|
44
|
+
const gradient =
|
|
45
|
+
dpCopy.slice(0, 2).toLowerCase() === '00'
|
|
46
|
+
? BiorhythmGradientType.EntireGradient
|
|
47
|
+
: BiorhythmGradientType.DirectGradient
|
|
48
|
+
dpCopy = dpCopy.slice(2)
|
|
49
|
+
// 重复周期
|
|
50
|
+
const repeatPeriod: Period[] = hex2Int(dpCopy.slice(0, 2))
|
|
51
|
+
.toString(2)
|
|
52
|
+
.padStart(7, '0')
|
|
53
|
+
.split('')
|
|
54
|
+
.reverse()
|
|
55
|
+
.map((p, index) => {
|
|
56
|
+
return {
|
|
57
|
+
index: index === 0 ? 7 : index,
|
|
58
|
+
title: getRepeatPeriodTitleByIndex(index),
|
|
59
|
+
enabled: p === '1',
|
|
60
|
+
}
|
|
61
|
+
})
|
|
62
|
+
dpCopy = dpCopy.slice(2)
|
|
63
|
+
// 节点个数 (每个节点长度18),最多8个节点
|
|
64
|
+
hex2Int(dpCopy.slice(0, 2))
|
|
65
|
+
dpCopy = dpCopy.slice(2)
|
|
66
|
+
// 节点列表
|
|
67
|
+
const planList: Plan[] = dpCopy === '00' ? [] : spliceByStep(dpCopy, 18).map((planHex, index) => {
|
|
68
|
+
let hex = planHex
|
|
69
|
+
// 节点开关
|
|
70
|
+
const enable = hex2Int(hex.slice(0, 2)) === 1
|
|
71
|
+
hex = hex.slice(2)
|
|
72
|
+
// 小时
|
|
73
|
+
const hour = hex2Int(hex.slice(0, 2)).toString().padStart(2, '0')
|
|
74
|
+
hex = hex.slice(2)
|
|
75
|
+
// 分钟
|
|
76
|
+
const minute = hex2Int(hex.slice(0, 2)).toString().padStart(2, '0')
|
|
77
|
+
hex = hex.slice(2)
|
|
78
|
+
const startTime = `${hour}:${minute}`
|
|
79
|
+
// 色调 (色相)
|
|
80
|
+
hex2Int(hex.slice(0, 4))
|
|
81
|
+
hex = hex.slice(4)
|
|
82
|
+
// 饱和度
|
|
83
|
+
hex2Int(hex.slice(0, 2))
|
|
84
|
+
hex = hex.slice(2)
|
|
85
|
+
// 明度
|
|
86
|
+
hex2Int(hex.slice(0, 2))
|
|
87
|
+
hex = hex.slice(2)
|
|
88
|
+
// 亮度
|
|
89
|
+
const brightness = hex2Int(hex.slice(0, 2))
|
|
90
|
+
hex = hex.slice(2)
|
|
91
|
+
// 色温
|
|
92
|
+
const colorTemperature = hex2Int(hex.slice(0, 2))
|
|
93
|
+
return {
|
|
94
|
+
id: index,
|
|
95
|
+
enable: enable,
|
|
96
|
+
icon: getNodeIconByIndex(index),
|
|
97
|
+
startTime: startTime,
|
|
98
|
+
name: getNodeNameByIndex(index),
|
|
99
|
+
colorTemperature: colorTemperature,
|
|
100
|
+
brightness: brightness,
|
|
101
|
+
action: [
|
|
102
|
+
{
|
|
103
|
+
uri: 'model/attribute/set/LightCtrl/ColorTemperature',
|
|
104
|
+
startValue: `${colorTemperatureValue(colorTemperature)}`,
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
uri: 'model/attribute/set/LightCtrl/Brightness',
|
|
108
|
+
startValue: `${brightness}`,
|
|
109
|
+
},
|
|
110
|
+
],
|
|
111
|
+
}
|
|
112
|
+
})
|
|
113
|
+
return {
|
|
114
|
+
enable: enable,
|
|
115
|
+
gradient: gradient,
|
|
116
|
+
repeatPeriod: repeatPeriod,
|
|
117
|
+
planList: planList,
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function getNodeNameByIndex(index: number): string {
|
|
122
|
+
switch (index) {
|
|
123
|
+
case 0:
|
|
124
|
+
return I18n.getLang('bio_ryhthm_default_field_text')
|
|
125
|
+
case 1:
|
|
126
|
+
return I18n.getLang('bio_ryhthm_default_field_text2')
|
|
127
|
+
case 2:
|
|
128
|
+
return I18n.getLang('bio_ryhthm_default_field_text3')
|
|
129
|
+
case 3:
|
|
130
|
+
return I18n.getLang('bio_ryhthm_default_field_text4')
|
|
131
|
+
case 4:
|
|
132
|
+
return I18n.getLang('bio_ryhthm_default_field_text5')
|
|
133
|
+
default:
|
|
134
|
+
return `Node ${index + 1}`
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function getNodeIconByIndex(index: number): string {
|
|
139
|
+
switch (index) {
|
|
140
|
+
case 0:
|
|
141
|
+
return BiologicalRes.rhythm_icon1
|
|
142
|
+
case 1:
|
|
143
|
+
return BiologicalRes.rhythm_icon2
|
|
144
|
+
case 2:
|
|
145
|
+
return BiologicalRes.rhythm_icon3
|
|
146
|
+
case 3:
|
|
147
|
+
return BiologicalRes.rhythm_icon4
|
|
148
|
+
case 4:
|
|
149
|
+
return BiologicalRes.rhythm_icon12
|
|
150
|
+
case 5:
|
|
151
|
+
return BiologicalRes.rhythm_icon1
|
|
152
|
+
case 6:
|
|
153
|
+
return BiologicalRes.rhythm_icon2
|
|
154
|
+
case 7:
|
|
155
|
+
return BiologicalRes.rhythm_icon3
|
|
156
|
+
default:
|
|
157
|
+
return BiologicalRes.rhythm_icon1
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function getRepeatPeriodTitleByIndex(index: number): string {
|
|
162
|
+
let title = ''
|
|
163
|
+
switch (index) {
|
|
164
|
+
case 0:
|
|
165
|
+
title = I18n.getLang('bio_ryhthm_default_weekday7_text')
|
|
166
|
+
break
|
|
167
|
+
case 1:
|
|
168
|
+
title = I18n.getLang('bio_ryhthm_default_weekday1_text')
|
|
169
|
+
break
|
|
170
|
+
case 2:
|
|
171
|
+
title = I18n.getLang('bio_ryhthm_default_weekday2_text')
|
|
172
|
+
break
|
|
173
|
+
case 3:
|
|
174
|
+
title = I18n.getLang('bio_ryhthm_default_weekday3_text')
|
|
175
|
+
break
|
|
176
|
+
case 4:
|
|
177
|
+
title = I18n.getLang('bio_ryhthm_default_weekday4_text')
|
|
178
|
+
break
|
|
179
|
+
case 5:
|
|
180
|
+
title = I18n.getLang('bio_ryhthm_default_weekday5_text')
|
|
181
|
+
break
|
|
182
|
+
case 6:
|
|
183
|
+
title = I18n.getLang('bio_ryhthm_default_weekday6_text')
|
|
184
|
+
break
|
|
185
|
+
}
|
|
186
|
+
return title
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function obj2Dp(obj: BiorhythmBean): string {
|
|
190
|
+
const versionHex = '00'
|
|
191
|
+
const enableHex = obj.enable ? '01' : '00'
|
|
192
|
+
const gradientHex = obj.gradient === BiorhythmGradientType.EntireGradient ? '00' : '0F'
|
|
193
|
+
const repeatPeriodHex = parseInt(
|
|
194
|
+
obj.repeatPeriod
|
|
195
|
+
.map(p => (p.enabled ? '1' : '0'))
|
|
196
|
+
.reverse()
|
|
197
|
+
.join(''),
|
|
198
|
+
2,
|
|
199
|
+
)
|
|
200
|
+
.toString(16)
|
|
201
|
+
.padStart(2, '0')
|
|
202
|
+
const planCountHex = obj.planList.length.toString(16).padStart(2, '0')
|
|
203
|
+
const planListHex = obj.planList
|
|
204
|
+
.map(plan => {
|
|
205
|
+
const enableHex = plan.enable ? '01' : '00'
|
|
206
|
+
const startTime = plan.startTime.split(':')
|
|
207
|
+
const hourHex = parseInt(startTime[0]).toString(16).padStart(2, '0')
|
|
208
|
+
const minuteHex = parseInt(startTime[1]).toString(16).padStart(2, '0')
|
|
209
|
+
const hsvHex = '00000000'
|
|
210
|
+
const brightnessHex = plan.brightness.toString(16).padStart(2, '0')
|
|
211
|
+
const colorTemperatureHex = plan.colorTemperature.toString(16).padStart(2, '0')
|
|
212
|
+
return enableHex + hourHex + minuteHex + hsvHex + brightnessHex + colorTemperatureHex
|
|
213
|
+
})
|
|
214
|
+
.join('')
|
|
215
|
+
return versionHex + enableHex + gradientHex + repeatPeriodHex + planCountHex + planListHex
|
|
216
|
+
}
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import I18n from '@ledvance/base/src/i18n'
|
|
2
|
+
import BiologicalRes from './res/BiologicalRes'
|
|
3
|
+
|
|
4
|
+
export enum BiorhythmGradientType {
|
|
5
|
+
// 全程渐变
|
|
6
|
+
EntireGradient,
|
|
7
|
+
// 直接渐变
|
|
8
|
+
DirectGradient,
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const BiorhythmGradientTypeMap = {
|
|
12
|
+
[BiorhythmGradientType.EntireGradient]: 'entireGradient',
|
|
13
|
+
[BiorhythmGradientType.DirectGradient]: 'directGradient',
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const BiorhythmGradientTypeMap2 = {
|
|
17
|
+
entireGradient: BiorhythmGradientType.EntireGradient,
|
|
18
|
+
directGradient: BiorhythmGradientType.DirectGradient,
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface BiorhythmBean {
|
|
22
|
+
enable: boolean;
|
|
23
|
+
repeatPeriod: Period[];
|
|
24
|
+
gradient: BiorhythmGradientType;
|
|
25
|
+
planList: Plan[];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface Plan {
|
|
29
|
+
id: number;
|
|
30
|
+
enable: boolean;
|
|
31
|
+
icon: string;
|
|
32
|
+
startTime: string;
|
|
33
|
+
name: string;
|
|
34
|
+
colorTemperature: number;
|
|
35
|
+
brightness: number;
|
|
36
|
+
action: Action[];
|
|
37
|
+
iconId?: any;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface Action {
|
|
41
|
+
uri: string;
|
|
42
|
+
startValue: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface Period {
|
|
46
|
+
index: number;
|
|
47
|
+
title: string;
|
|
48
|
+
enabled: boolean;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function colorTemperatureValue(percentageValue) {
|
|
52
|
+
// 38 = (6500 - 2700) / 100
|
|
53
|
+
return 2700 + 38 * percentageValue
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function colorTempPercent(colorTemp: number): number {
|
|
57
|
+
return Math.round((colorTemp - 2700) / 38)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function getDefBiorhythmUIState(): BiorhythmBean {
|
|
61
|
+
const icon1 = BiologicalRes.biorhythom_Icon1
|
|
62
|
+
const icon12 = BiologicalRes.biorhythom_Icon3
|
|
63
|
+
const icon2 = BiologicalRes.biorhythom_Icon5
|
|
64
|
+
const icon3 = BiologicalRes.biorhythom_Icon2
|
|
65
|
+
const icon4 = BiologicalRes.biorhythom_Icon9
|
|
66
|
+
return {
|
|
67
|
+
enable: false, // 生物节律默认为关
|
|
68
|
+
repeatPeriod: getDefRepeatPeriod(),
|
|
69
|
+
gradient: BiorhythmGradientType.EntireGradient,
|
|
70
|
+
planList: [
|
|
71
|
+
{
|
|
72
|
+
id: 0,
|
|
73
|
+
icon: icon1,
|
|
74
|
+
startTime: '06:00',
|
|
75
|
+
name: I18n.getLang('bio_ryhthm_default_field_text'),
|
|
76
|
+
colorTemperature: 0,
|
|
77
|
+
brightness: 0,
|
|
78
|
+
action: [
|
|
79
|
+
{
|
|
80
|
+
uri: 'model/attribute/set/LightCtrl/ColorTemperature',
|
|
81
|
+
startValue: `${colorTemperatureValue(0)}`,
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
uri: 'model/attribute/set/LightCtrl/Brightness',
|
|
85
|
+
startValue: '0',
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
enable: true,
|
|
89
|
+
iconId: 1,
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
id: 1,
|
|
93
|
+
icon: icon12,
|
|
94
|
+
startTime: '06:30',
|
|
95
|
+
name: I18n.getLang('bio_ryhthm_default_field_text2'),
|
|
96
|
+
colorTemperature: 25,
|
|
97
|
+
brightness: 20,
|
|
98
|
+
action: [
|
|
99
|
+
{
|
|
100
|
+
uri: 'model/attribute/set/LightCtrl/ColorTemperature',
|
|
101
|
+
startValue: `${colorTemperatureValue(25)}`,
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
uri: 'model/attribute/set/LightCtrl/Brightness',
|
|
105
|
+
startValue: '20',
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
enable: true,
|
|
109
|
+
iconId: 5,
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
id: 2,
|
|
113
|
+
icon: icon2,
|
|
114
|
+
startTime: '09:00',
|
|
115
|
+
name: I18n.getLang('bio_ryhthm_default_field_text3'),
|
|
116
|
+
colorTemperature: 100,
|
|
117
|
+
brightness: 100,
|
|
118
|
+
action: [
|
|
119
|
+
{
|
|
120
|
+
uri: 'model/attribute/set/LightCtrl/ColorTemperature',
|
|
121
|
+
startValue: `${colorTemperatureValue(100)}`,
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
uri: 'model/attribute/set/LightCtrl/Brightness',
|
|
125
|
+
startValue: '100',
|
|
126
|
+
},
|
|
127
|
+
],
|
|
128
|
+
enable: true,
|
|
129
|
+
iconId: 2,
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
id: 3,
|
|
133
|
+
icon: icon3,
|
|
134
|
+
startTime: '20:00',
|
|
135
|
+
name: I18n.getLang('bio_ryhthm_default_field_text4'),
|
|
136
|
+
colorTemperature: 50,
|
|
137
|
+
brightness: 80,
|
|
138
|
+
action: [
|
|
139
|
+
{
|
|
140
|
+
uri: 'model/attribute/set/LightCtrl/ColorTemperature',
|
|
141
|
+
startValue: `${colorTemperatureValue(50)}`,
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
uri: 'model/attribute/set/LightCtrl/Brightness',
|
|
145
|
+
startValue: '80',
|
|
146
|
+
},
|
|
147
|
+
],
|
|
148
|
+
enable: true,
|
|
149
|
+
iconId: 9,
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
id: 4,
|
|
153
|
+
icon: icon4,
|
|
154
|
+
startTime: '23:30',
|
|
155
|
+
name: I18n.getLang('bio_ryhthm_default_field_text5'),
|
|
156
|
+
colorTemperature: 0,
|
|
157
|
+
brightness: 0,
|
|
158
|
+
action: [
|
|
159
|
+
{
|
|
160
|
+
uri: 'model/attribute/set/LightCtrl/ColorTemperature',
|
|
161
|
+
startValue: `${colorTemperatureValue(0)}`,
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
uri: 'model/attribute/set/LightCtrl/Brightness',
|
|
165
|
+
startValue: '0',
|
|
166
|
+
},
|
|
167
|
+
],
|
|
168
|
+
enable: true,
|
|
169
|
+
iconId: 3,
|
|
170
|
+
},
|
|
171
|
+
],
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export function getDefRepeatPeriod(): Period[] {
|
|
176
|
+
return [
|
|
177
|
+
{
|
|
178
|
+
index: 7,
|
|
179
|
+
title: I18n.getLang('bio_ryhthm_default_weekday7_text'),
|
|
180
|
+
enabled: true,
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
index: 1,
|
|
184
|
+
title: I18n.getLang('bio_ryhthm_default_weekday1_text'),
|
|
185
|
+
enabled: true,
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
index: 2,
|
|
189
|
+
title: I18n.getLang('bio_ryhthm_default_weekday2_text'),
|
|
190
|
+
enabled: true,
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
index: 3,
|
|
194
|
+
title: I18n.getLang('bio_ryhthm_default_weekday3_text'),
|
|
195
|
+
enabled: true,
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
index: 4,
|
|
199
|
+
title: I18n.getLang('bio_ryhthm_default_weekday4_text'),
|
|
200
|
+
enabled: true,
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
index: 5,
|
|
204
|
+
title: I18n.getLang('bio_ryhthm_default_weekday5_text'),
|
|
205
|
+
enabled: true,
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
index: 6,
|
|
209
|
+
title: I18n.getLang('bio_ryhthm_default_weekday6_text'),
|
|
210
|
+
enabled: true,
|
|
211
|
+
},
|
|
212
|
+
]
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
export interface RemoteBiorhythmBean {
|
|
216
|
+
enable: boolean;
|
|
217
|
+
repeatPeriod: number[];
|
|
218
|
+
gradientWay: string;
|
|
219
|
+
rhythmPlan: RemoteBiorhythmPlan[];
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
interface RemoteBiorhythmPlan {
|
|
223
|
+
iconId: any;
|
|
224
|
+
name: string;
|
|
225
|
+
rhythmIcon: string;
|
|
226
|
+
enable: boolean;
|
|
227
|
+
startTime: string;
|
|
228
|
+
sustain: number; // 持续时间涂鸦这边没有,直接用来存ID
|
|
229
|
+
action: Action[];
|
|
230
|
+
}
|