@ledvance/base 1.2.24 → 1.2.25
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
package/src/composeLayout.tsx
CHANGED
|
@@ -4,13 +4,14 @@ import { Provider } from 'react-redux'
|
|
|
4
4
|
import { DevInfo, DpValue, Theme, TYSdk } from 'tuya-panel-kit'
|
|
5
5
|
import { actions, store } from './models'
|
|
6
6
|
import { addListener, removeListener } from 'api/nativeEventEmitter'
|
|
7
|
-
import { NativeApi } from 'api/native'
|
|
7
|
+
import { getSystemTimeFormat, NativeApi } from 'api/native'
|
|
8
8
|
import {
|
|
9
9
|
DeviceInfo,
|
|
10
10
|
NativeProps,
|
|
11
11
|
setGroupDevices,
|
|
12
12
|
setGroupNativeProps,
|
|
13
13
|
setNativeProps,
|
|
14
|
+
setSystemTimeFormat,
|
|
14
15
|
UAGroupInfo,
|
|
15
16
|
} from './models/modules/NativePropsSlice'
|
|
16
17
|
import { DpSchema, GlobalParams } from './models/GlobalParams'
|
|
@@ -117,6 +118,9 @@ const composeLayout = (component: React.ComponentType) => {
|
|
|
117
118
|
this.initReduxGroupNativeProps(props.uaGroupInfo)
|
|
118
119
|
this.initGroupDevices(props.uaGroupInfo?.tyGroupId)
|
|
119
120
|
}
|
|
121
|
+
getSystemTimeFormat().then(time => {
|
|
122
|
+
dispatch(setSystemTimeFormat(time === 24))
|
|
123
|
+
})
|
|
120
124
|
}
|
|
121
125
|
|
|
122
126
|
initReduxDeviceNativeProps(ldvDevInfo: LdvDevInfo) {
|
|
@@ -138,7 +142,8 @@ const composeLayout = (component: React.ComponentType) => {
|
|
|
138
142
|
},
|
|
139
143
|
familyName: ldvDevInfo.familyName,
|
|
140
144
|
role: ldvDevInfo.role,
|
|
141
|
-
moods: []
|
|
145
|
+
moods: [],
|
|
146
|
+
is24HourClock: true
|
|
142
147
|
}
|
|
143
148
|
NativeApi.showObj(nativeProps)
|
|
144
149
|
console.log('Redux 初始数据:', JSON.stringify(nativeProps))
|
|
@@ -167,7 +172,8 @@ const composeLayout = (component: React.ComponentType) => {
|
|
|
167
172
|
},
|
|
168
173
|
familyName: uaGroupInfo.familyName,
|
|
169
174
|
role: uaGroupInfo.role,
|
|
170
|
-
moods: []
|
|
175
|
+
moods: [],
|
|
176
|
+
is24HourClock: true
|
|
171
177
|
}
|
|
172
178
|
NativeApi.showObj(nativeProps)
|
|
173
179
|
console.log('Redux 初始数据:', JSON.stringify(nativeProps))
|
|
@@ -8,6 +8,7 @@ import { useDispatch } from 'react-redux'
|
|
|
8
8
|
import { GlobalParams } from '../GlobalParams'
|
|
9
9
|
import { isNumber, snakeCase } from 'lodash'
|
|
10
10
|
import { PropertyValueTypes } from '../../utils/TypeUtils'
|
|
11
|
+
import { DeviceInfo as GroupDeviceInfo } from '../../api/native'
|
|
11
12
|
|
|
12
13
|
export interface NativeProps {
|
|
13
14
|
familyName: string
|
|
@@ -17,6 +18,7 @@ export interface NativeProps {
|
|
|
17
18
|
timeSchedule?: boolean
|
|
18
19
|
energieverbrauch?: object
|
|
19
20
|
moods: any[]
|
|
21
|
+
is24HourClock: boolean
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
export interface DeviceInfo {
|
|
@@ -30,7 +32,7 @@ export interface UAGroupInfo {
|
|
|
30
32
|
pId: string
|
|
31
33
|
dps: any
|
|
32
34
|
config: any
|
|
33
|
-
groupDevices:
|
|
35
|
+
groupDevices: GroupDeviceInfo[]
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
const initialState: NativeProps = {
|
|
@@ -51,6 +53,7 @@ const initialState: NativeProps = {
|
|
|
51
53
|
timeSchedule: false,
|
|
52
54
|
energieverbrauch: {},
|
|
53
55
|
moods: [],
|
|
56
|
+
is24HourClock: true
|
|
54
57
|
}
|
|
55
58
|
|
|
56
59
|
// energy generation
|
|
@@ -114,6 +117,9 @@ const nativePropsSlice = createSlice({
|
|
|
114
117
|
setGroupDevices(state, action: PayloadAction<any>) {
|
|
115
118
|
state.uaGroupInfo.groupDevices = action.payload
|
|
116
119
|
},
|
|
120
|
+
setSystemTimeFormat(state, action: PayloadAction<any>) {
|
|
121
|
+
state.is24HourClock = action.payload
|
|
122
|
+
}
|
|
117
123
|
},
|
|
118
124
|
})
|
|
119
125
|
|
|
@@ -224,15 +230,19 @@ const useMoods = (): [any[], (v: any[]) => void] => {
|
|
|
224
230
|
return [dps, setMoodsFn]
|
|
225
231
|
}
|
|
226
232
|
|
|
227
|
-
const useGroupDevices = (): [
|
|
233
|
+
const useGroupDevices = (): [GroupDeviceInfo[], (v: GroupDeviceInfo[]) => void] => {
|
|
228
234
|
const dps = useSelector(store => store.ldvModules.uaGroupInfo.groupDevices)
|
|
229
235
|
const dispatch = useDispatch()
|
|
230
|
-
const setGroupDevicesFn = (value:
|
|
236
|
+
const setGroupDevicesFn = (value: GroupDeviceInfo[]) => {
|
|
231
237
|
dispatch(setGroupDevices(value))
|
|
232
238
|
}
|
|
233
239
|
return [dps, setGroupDevicesFn]
|
|
234
240
|
}
|
|
235
241
|
|
|
242
|
+
const useSystemTimeFormate = (): boolean => {
|
|
243
|
+
return useSelector(store => store.ldvModules.is24HourClock)
|
|
244
|
+
}
|
|
245
|
+
|
|
236
246
|
const useEnergieverbrauch = () => {
|
|
237
247
|
const dps = useSelector(store => store.ldvModules.energieverbrauch)
|
|
238
248
|
const dispatch = useDispatch()
|
|
@@ -314,7 +324,7 @@ export function useFeatureHook<GC, T extends PropertyValueTypes<GC>>(
|
|
|
314
324
|
const extraConfig = getExtraConfig ? getExtraConfig(value) : undefined
|
|
315
325
|
return await setFH(value, dpValue, extraDps, extraConfig)
|
|
316
326
|
}, [setFH])
|
|
317
|
-
return [featureHook
|
|
327
|
+
return [featureHook || defValue, setFeatureHook]
|
|
318
328
|
}
|
|
319
329
|
|
|
320
330
|
export const useFanMaxSpeed = () => {
|
|
@@ -336,6 +346,7 @@ export const {
|
|
|
336
346
|
setTimeSchedule,
|
|
337
347
|
setMoods,
|
|
338
348
|
setGroupDevices,
|
|
349
|
+
setSystemTimeFormat,
|
|
339
350
|
setEnergieverbrauch,
|
|
340
351
|
} = nativePropsSlice.actions
|
|
341
352
|
|
|
@@ -353,5 +364,6 @@ export {
|
|
|
353
364
|
useTimeSchedule,
|
|
354
365
|
useMoods,
|
|
355
366
|
useGroupDevices,
|
|
367
|
+
useSystemTimeFormate,
|
|
356
368
|
useEnergieverbrauch,
|
|
357
369
|
}
|