@ledvance/group-ui-biz-bundle 1.0.45 → 1.0.47
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 +5 -13
- package/src/modules/biorhythm/BiorhythmBean.ts +6 -6
- package/src/modules/biorhythm/BiorhythmPage.tsx +14 -38
- package/src/modules/biorhythm/Router.ts +34 -0
- package/src/modules/fixedTimeForPlug/Router.ts +25 -0
- package/src/modules/fixedTimingForLight/Router.ts +25 -0
- package/src/modules/flags/Router.ts +25 -0
- package/src/modules/mood_new/AddMoodPage.tsx +197 -0
- package/src/modules/mood_new/DynamicMoodEditorPage.tsx +654 -0
- package/src/modules/mood_new/Interface.ts +219 -0
- package/src/modules/mood_new/MixDynamicMoodEditor.tsx +788 -0
- package/src/modules/mood_new/MoodActions.ts +227 -0
- package/src/modules/mood_new/MoodInfo.ts +2151 -0
- package/src/modules/mood_new/MoodItem.tsx +148 -0
- package/src/modules/mood_new/MoodPage.tsx +374 -0
- package/src/modules/mood_new/MoodParse.ts +442 -0
- package/src/modules/mood_new/RecommendMoodItem.tsx +69 -0
- package/src/modules/mood_new/Router.ts +43 -0
- package/src/modules/mood_new/StaticMoodEditorPage.tsx +293 -0
- package/src/modules/music/Router.ts +16 -0
- package/src/modules/randomTimeForPlug/Router.ts +25 -0
- package/src/modules/randomTimingForLight/Router.ts +25 -0
- package/src/modules/remoteSwitch/Router.ts +16 -0
- package/src/modules/select/Router.ts +16 -0
- package/src/modules/switchGradient/Router.ts +16 -0
- package/src/modules/timeSchedule/Interface.ts +150 -0
- package/src/modules/timeSchedule/Router.ts +25 -0
- package/src/modules/timeSchedule/TimeScheduleActions.ts +140 -0
- package/src/modules/timeSchedule/TimeScheduleDetailPage.tsx +625 -0
- package/src/modules/timeSchedule/TimeSchedulePage.tsx +220 -0
- package/src/modules/timeSchedule/components/ManuaSettings.tsx +376 -0
- package/src/modules/timeSchedule/components/ScheduleCard.tsx +109 -0
- package/src/modules/timeSchedule/components/Summary.tsx +124 -0
- package/src/modules/timer/Router.ts +16 -0
- package/src/navigation/Routers.ts +1 -0
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { NativeApi } from '@ledvance/base/src/api/native';
|
|
2
|
+
import {
|
|
3
|
+
DefMoodOption,
|
|
4
|
+
LightCategory,
|
|
5
|
+
MixRemoteMoodInfo,
|
|
6
|
+
MoodUIInfo,
|
|
7
|
+
RemoteMoodInfo,
|
|
8
|
+
} from './Interface';
|
|
9
|
+
import { parseJSON } from '@tuya/tuya-panel-lamp-sdk/lib/utils';
|
|
10
|
+
import { getDefMoodList } from './MoodInfo';
|
|
11
|
+
import {
|
|
12
|
+
MixCeilingDpObj,
|
|
13
|
+
MixDp2Obj,
|
|
14
|
+
MixObj2Dp,
|
|
15
|
+
dp2Obj,
|
|
16
|
+
obj2Dp,
|
|
17
|
+
stripDp2Obj,
|
|
18
|
+
stripObj2Dp,
|
|
19
|
+
} from './MoodParse';
|
|
20
|
+
import { useFeatureHook, useGroupDp } from '@ledvance/base/src/models/modules/NativePropsSlice';
|
|
21
|
+
import { WorkMode } from '@ledvance/base/src/utils/interface';
|
|
22
|
+
import { getGlobalParamsDp } from '@ledvance/base/src/utils/common';
|
|
23
|
+
import { Result } from '@ledvance/base/src/models/modules/Result';
|
|
24
|
+
|
|
25
|
+
const SceneFeatureId = 'SimplifyScene';
|
|
26
|
+
|
|
27
|
+
interface SceneDataType {
|
|
28
|
+
scene?: MoodUIInfo
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface SceneDataConfigType {
|
|
32
|
+
sceneConfig?: SceneDataType
|
|
33
|
+
work_mode: WorkMode
|
|
34
|
+
rgbic_work_mode: WorkMode
|
|
35
|
+
switch_led: boolean
|
|
36
|
+
colour_switch: boolean
|
|
37
|
+
white_switch: boolean
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
interface LightType {
|
|
41
|
+
isStringLight?: boolean
|
|
42
|
+
isStripLight?: boolean
|
|
43
|
+
isCeilingLight?: boolean
|
|
44
|
+
isFanLight?: boolean
|
|
45
|
+
isMixLight?: boolean
|
|
46
|
+
isUVCFan?: boolean
|
|
47
|
+
isMatterLight?: boolean
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function useWorkMode(): WorkMode {
|
|
51
|
+
const [workMode] = useGroupDp<WorkMode>(getGlobalParamsDp('work_mode'))
|
|
52
|
+
return workMode
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function useRgbicWorkMode(): WorkMode {
|
|
56
|
+
const [rgbicWorkMode] = useGroupDp<WorkMode>(getGlobalParamsDp('rgbic_work_mode'))
|
|
57
|
+
return rgbicWorkMode
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function useMoodScene(params: LightType): [SceneDataType, (value: SceneDataType) => Promise<Result<any>>] {
|
|
61
|
+
const defConfig = {
|
|
62
|
+
scene: undefined
|
|
63
|
+
}
|
|
64
|
+
// const [] = useGroupDp<MoodUIInfo>(getGlobalParamsDp('scene_data'))
|
|
65
|
+
// const [] = useGroupDp<MoodUIInfo>(getGlobalParamsDp(''))
|
|
66
|
+
const [config, setConfig] = useFeatureHook<SceneDataConfigType, SceneDataType>('sceneConfig', defConfig, undefined,
|
|
67
|
+
(moodInfo) => {
|
|
68
|
+
if (moodInfo?.scene) {
|
|
69
|
+
console.log(moodInfo.scene, '< --- moodInfo.scene')
|
|
70
|
+
const dps = {}
|
|
71
|
+
const { mainLamp, secondaryLamp } = moodInfo.scene
|
|
72
|
+
if (mainLamp?.nodes?.length) {
|
|
73
|
+
const mainDp = getMoodDp(params.isCeilingLight ? ({...moodInfo.scene, id: mainLamp.id!}) : moodInfo.scene, params)
|
|
74
|
+
if (mainDp && getGlobalParamsDp('scene_data')) {
|
|
75
|
+
dps[getGlobalParamsDp('scene_data')] = mainDp
|
|
76
|
+
dps[getGlobalParamsDp('work_mode')] = WorkMode.Scene
|
|
77
|
+
if (params.isCeilingLight) {
|
|
78
|
+
dps[getGlobalParamsDp('white_switch')] = true
|
|
79
|
+
} else {
|
|
80
|
+
dps[getGlobalParamsDp('switch_led')] = true
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (secondaryLamp.nodes.length && params.isCeilingLight) {
|
|
85
|
+
const secondaryDp = stripObj2Dp({
|
|
86
|
+
...moodInfo.scene,
|
|
87
|
+
mainLamp: secondaryLamp,
|
|
88
|
+
id: secondaryLamp.id!
|
|
89
|
+
});
|
|
90
|
+
if (secondaryDp && getGlobalParamsDp('dreamlight_scene_mode')) {
|
|
91
|
+
dps[getGlobalParamsDp('dreamlight_scene_mode')] = secondaryDp
|
|
92
|
+
dps[getGlobalParamsDp('rgbic_work_mode')] = WorkMode.Scene
|
|
93
|
+
dps[getGlobalParamsDp('colour_switch')] = true
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return dps
|
|
97
|
+
}
|
|
98
|
+
}, (moodInfo) => {
|
|
99
|
+
if (moodInfo?.scene) {
|
|
100
|
+
const { mainLamp, secondaryLamp } = moodInfo.scene
|
|
101
|
+
const config = {} as SceneDataConfigType
|
|
102
|
+
if (mainLamp?.nodes?.length) {
|
|
103
|
+
config.work_mode = WorkMode.Scene
|
|
104
|
+
if (params.isCeilingLight) {
|
|
105
|
+
config.white_switch = true
|
|
106
|
+
} else {
|
|
107
|
+
config.switch_led = true
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
if (secondaryLamp?.nodes?.length) {
|
|
111
|
+
if (params.isCeilingLight) {
|
|
112
|
+
config.rgbic_work_mode = WorkMode.Scene
|
|
113
|
+
config.colour_switch = true
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return config
|
|
117
|
+
}
|
|
118
|
+
})
|
|
119
|
+
return [config, setConfig]
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export const setRemoteMoodList = (
|
|
123
|
+
devId: string,
|
|
124
|
+
remoteSceneList: RemoteMoodInfo[] | MixRemoteMoodInfo[],
|
|
125
|
+
featureId: string
|
|
126
|
+
) => {
|
|
127
|
+
return NativeApi.putJson(devId, featureId, JSON.stringify(remoteSceneList));
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
const getMoodInfo = (mainDp: string, option: LightCategory, secondaryDp: string) => {
|
|
131
|
+
const moodInfo = !!(option.isStringLight || option.isStripLight)
|
|
132
|
+
? stripDp2Obj(mainDp, option.isStringLight)
|
|
133
|
+
: option.isMixLight
|
|
134
|
+
? MixDp2Obj(mainDp)
|
|
135
|
+
: option.isCeilingLight
|
|
136
|
+
? MixCeilingDpObj(mainDp, secondaryDp)
|
|
137
|
+
: dp2Obj(mainDp, option.isFanLight, option.isUVCFan);
|
|
138
|
+
return moodInfo;
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
const getMoodDp = (moodInfo: MoodUIInfo, option: LightCategory) => {
|
|
142
|
+
const moodDp = !!(option.isStringLight || option.isStripLight)
|
|
143
|
+
? stripObj2Dp(moodInfo, option.isStringLight)
|
|
144
|
+
: option.isMixLight
|
|
145
|
+
? MixObj2Dp(moodInfo)
|
|
146
|
+
: obj2Dp(moodInfo, option.isFanLight, option.isUVCFan);
|
|
147
|
+
return moodDp;
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
const remoteMoodInfo2MoodUIState = (
|
|
151
|
+
remoteMoodInfo,
|
|
152
|
+
index: number,
|
|
153
|
+
option: DefMoodOption
|
|
154
|
+
): MoodUIInfo => {
|
|
155
|
+
const moodInfo = option.isMixLight
|
|
156
|
+
? MixDp2Obj(remoteMoodInfo.value)
|
|
157
|
+
: getMoodInfo(remoteMoodInfo.i, option, remoteMoodInfo.s);
|
|
158
|
+
return {
|
|
159
|
+
name: option.isMixLight ? remoteMoodInfo.name : remoteMoodInfo.n,
|
|
160
|
+
image: '',
|
|
161
|
+
...moodInfo,
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
export const getRemoteMoodList = async (
|
|
166
|
+
devId: string,
|
|
167
|
+
option: DefMoodOption,
|
|
168
|
+
) => {
|
|
169
|
+
// const defaultScene = getDefMoodList(option);
|
|
170
|
+
// await setRemoteMoodList(devId, defaultScene, SceneFeatureId);
|
|
171
|
+
const res = await NativeApi.getJson(devId, SceneFeatureId);
|
|
172
|
+
const isNormalData = Array.isArray(parseJSON(res?.data));
|
|
173
|
+
if (res.success && isNormalData) {
|
|
174
|
+
return {
|
|
175
|
+
success: true,
|
|
176
|
+
data:
|
|
177
|
+
res.data &&
|
|
178
|
+
parseJSON(res.data).map((item, index) => remoteMoodInfo2MoodUIState(item, index, option)),
|
|
179
|
+
};
|
|
180
|
+
} else {
|
|
181
|
+
if (res.msg?.includes('资源未找到') || !isNormalData) {
|
|
182
|
+
const defaultScene = getDefMoodList(option);
|
|
183
|
+
const res = await setRemoteMoodList(devId, defaultScene, SceneFeatureId);
|
|
184
|
+
if (res.success) {
|
|
185
|
+
return {
|
|
186
|
+
success: true,
|
|
187
|
+
data: defaultScene.map((item, index) =>
|
|
188
|
+
remoteMoodInfo2MoodUIState(item, index, option)
|
|
189
|
+
),
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
return { success: false };
|
|
193
|
+
}
|
|
194
|
+
return { success: false };
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
export const saveMoodList = (
|
|
199
|
+
devId: string,
|
|
200
|
+
moodList: MoodUIInfo[],
|
|
201
|
+
option: LightCategory,
|
|
202
|
+
) => {
|
|
203
|
+
const remoteMoods: any = moodList.map(s => {
|
|
204
|
+
if (option.isMixLight) {
|
|
205
|
+
return {
|
|
206
|
+
name: s.name,
|
|
207
|
+
image: '',
|
|
208
|
+
value: MixObj2Dp(s),
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
return {
|
|
212
|
+
n: s.name,
|
|
213
|
+
i: getMoodDp(option.isCeilingLight ? {...s, id: s.mainLamp.id!} : s, option),
|
|
214
|
+
s: s.secondaryLamp?.nodes?.length && option.isCeilingLight
|
|
215
|
+
? stripObj2Dp({
|
|
216
|
+
...s,
|
|
217
|
+
mainLamp: s.secondaryLamp,
|
|
218
|
+
id: s.secondaryLamp.id!
|
|
219
|
+
})
|
|
220
|
+
: '',
|
|
221
|
+
t: 0,
|
|
222
|
+
e: false,
|
|
223
|
+
};
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
return setRemoteMoodList(devId, remoteMoods, SceneFeatureId);
|
|
227
|
+
};
|