@ledvance/ui-biz-bundle 1.1.94 → 1.1.96
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
CHANGED
|
@@ -19,6 +19,7 @@ import { SelectPageParams } from '../select/SelectPage'
|
|
|
19
19
|
import { ui_biz_routerKey } from '../../navigation/Routers'
|
|
20
20
|
import { cloneDeep } from 'lodash'
|
|
21
21
|
import ThemeType from '@ledvance/base/src/config/themeType'
|
|
22
|
+
import { WorkMode } from '@ledvance/base/src/utils/interface'
|
|
22
23
|
|
|
23
24
|
const { convertX: cx } = Utils.RatioUtils
|
|
24
25
|
const { withTheme } = Utils.ThemeUtils
|
|
@@ -30,6 +31,7 @@ export interface MusicPageRouterParams extends JudgeTimeScheduleProps {
|
|
|
30
31
|
mix_light_scene: string
|
|
31
32
|
music_data: string
|
|
32
33
|
dreamMusicDp?: string
|
|
34
|
+
isFeatureMode?: boolean
|
|
33
35
|
}
|
|
34
36
|
|
|
35
37
|
const MusicPage = (props: { theme?: ThemeType }) => {
|
|
@@ -37,7 +39,7 @@ const MusicPage = (props: { theme?: ThemeType }) => {
|
|
|
37
39
|
const deviceId = useDeviceId()
|
|
38
40
|
const navigation = useNavigation()
|
|
39
41
|
const params = useRoute().params as MusicPageRouterParams
|
|
40
|
-
const [workMode, setWorkMode] = useWorkMode(params.work_mode)
|
|
42
|
+
const [workMode, setWorkMode] = useWorkMode(params.work_mode, params.isFeatureMode)
|
|
41
43
|
const [mixLight] = useMixRgbcw(params.mix_rgbcw, params.switch_led)
|
|
42
44
|
const [, setMixScene] = useMixScene(params.mix_light_scene, params.work_mode)
|
|
43
45
|
const [, setMusicData] = useMusicData(params.music_data)
|
|
@@ -110,7 +112,7 @@ const MusicPage = (props: { theme?: ThemeType }) => {
|
|
|
110
112
|
power: true
|
|
111
113
|
}, extraDp).then()
|
|
112
114
|
} else {
|
|
113
|
-
if (workMode !== 'music') await setWorkMode(
|
|
115
|
+
if (workMode !== 'music') await setWorkMode(WorkMode.Music)
|
|
114
116
|
if (!switchLed) setSwitchLed(true)
|
|
115
117
|
await MusicManager.open(
|
|
116
118
|
musicDefalutDatasource[state.phoneGenreMode],
|
|
@@ -193,8 +195,7 @@ const MusicPage = (props: { theme?: ThemeType }) => {
|
|
|
193
195
|
}
|
|
194
196
|
|
|
195
197
|
const changeMusic = async (id: number) => {
|
|
196
|
-
|
|
197
|
-
if (workMode !== 'music') await setWorkMode('music')
|
|
198
|
+
if (workMode !== 'music') await setWorkMode(WorkMode.Music)
|
|
198
199
|
if (!switchLed) setSwitchLed(true)
|
|
199
200
|
await saveSelect(id)
|
|
200
201
|
await MusicManager.close()
|
|
@@ -210,13 +211,12 @@ const MusicPage = (props: { theme?: ThemeType }) => {
|
|
|
210
211
|
}
|
|
211
212
|
|
|
212
213
|
const putMusicDataFn = (data: any, extraDp = {}) => {
|
|
213
|
-
console.log(data, '< --- data')
|
|
214
214
|
setMusicData(data, extraDp).then()
|
|
215
215
|
}
|
|
216
216
|
|
|
217
217
|
useEffect(() => {
|
|
218
218
|
getSelect().then()
|
|
219
|
-
}, [])
|
|
219
|
+
}, [workMode])
|
|
220
220
|
|
|
221
221
|
const getSelectModeData = useCallback((): [string | undefined, any[]] => {
|
|
222
222
|
const genreModeData = params.dreamMusicDp && state.musicType === 0 ? state.musicModeData : musicDefalutDatasource
|
|
@@ -1,21 +1,38 @@
|
|
|
1
|
-
import { useState } from 'react'
|
|
1
|
+
import { useEffect, useState } from 'react'
|
|
2
2
|
import { useUpdateEffect } from "ahooks"
|
|
3
|
-
import { useDp, useDps } from '@ledvance/base/src/models/modules/NativePropsSlice'
|
|
3
|
+
import { useDeviceId, useDp, useDps } from '@ledvance/base/src/models/modules/NativePropsSlice'
|
|
4
4
|
import { ColorParser } from '@ledvance/base/src/utils/ColorParser'
|
|
5
5
|
import { dp2Obj, obj2Dp } from '@ledvance/ui-biz-bundle/src/modules/timeSchedule/mix/MixLightActions'
|
|
6
6
|
import { MixLightBean } from '@ledvance/ui-biz-bundle/src/modules/timeSchedule/mix/MixLightBean'
|
|
7
7
|
import { Formatter } from '@tuya/tuya-panel-lamp-sdk'
|
|
8
8
|
import { DreamMusicDataType, dreamMusicData } from './MusicDataBean'
|
|
9
9
|
import { Result } from '@ledvance/base/src/models/modules/Result'
|
|
10
|
-
import { NativeApi } from '@ledvance/base/src/api/native'
|
|
10
|
+
import { getFeature, NativeApi } from '@ledvance/base/src/api/native'
|
|
11
11
|
import { parseJSON } from '@tuya/tuya-panel-lamp-sdk/lib/utils'
|
|
12
|
+
import { WorkMode } from '@ledvance/base/src/utils/interface'
|
|
12
13
|
const DreamMusicFormatter = new Formatter.DreamLightMicMusicFormatter()
|
|
13
14
|
export const useEnable = (dpKey: string) => {
|
|
14
15
|
return useDp(dpKey)
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
export const useWorkMode = (dpKey: string) => {
|
|
18
|
-
|
|
18
|
+
export const useWorkMode = (dpKey: string, isFeatureMode?: boolean): [WorkMode, (v: WorkMode) => Promise<Result<any>>] => {
|
|
19
|
+
const [workMode, setWorkMode] = useDp<WorkMode, any>(dpKey);
|
|
20
|
+
const [mode, setMode] = useState<WorkMode>(workMode);
|
|
21
|
+
const devId = useDeviceId()
|
|
22
|
+
useEffect(() =>{
|
|
23
|
+
if (isFeatureMode){
|
|
24
|
+
getFeature(devId, 'work_mode').then(res => {
|
|
25
|
+
if (res.result && res.data){
|
|
26
|
+
setMode(res.data)
|
|
27
|
+
}
|
|
28
|
+
})
|
|
29
|
+
}
|
|
30
|
+
}, [])
|
|
31
|
+
|
|
32
|
+
useUpdateEffect(() =>{
|
|
33
|
+
setMode(workMode)
|
|
34
|
+
}, [workMode])
|
|
35
|
+
return [mode, setWorkMode]
|
|
19
36
|
}
|
|
20
37
|
|
|
21
38
|
export const useMixRgbcw = (mixRgbcwDp: string, mixSwitchDp: string) => {
|