@ledvance/base 1.1.74 → 1.1.76
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
|
@@ -25,11 +25,13 @@ interface Props {
|
|
|
25
25
|
interface LdvDevInfo extends DeviceInfo {
|
|
26
26
|
schema: any
|
|
27
27
|
familyName: string
|
|
28
|
+
role: 0 | 1 | 2 | 3
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
interface UAGroupInfoProps extends UAGroupInfo {
|
|
31
32
|
schema: any
|
|
32
33
|
familyName: string
|
|
34
|
+
role: 0 | 1 | 2 | 3
|
|
33
35
|
}
|
|
34
36
|
|
|
35
37
|
const TYEvent = TYSdk.event
|
|
@@ -132,6 +134,7 @@ const composeLayout = (component: React.ComponentType) => {
|
|
|
132
134
|
config: {},
|
|
133
135
|
},
|
|
134
136
|
familyName: ldvDevInfo.familyName,
|
|
137
|
+
role: ldvDevInfo.role
|
|
135
138
|
}
|
|
136
139
|
NativeApi.showObj(nativeProps)
|
|
137
140
|
console.log('Redux 初始数据:', JSON.stringify(nativeProps))
|
|
@@ -156,6 +159,7 @@ const composeLayout = (component: React.ComponentType) => {
|
|
|
156
159
|
config: JSON.parse(uaGroupInfo.config || '{}'),
|
|
157
160
|
},
|
|
158
161
|
familyName: uaGroupInfo.familyName,
|
|
162
|
+
role: uaGroupInfo.role
|
|
159
163
|
}
|
|
160
164
|
NativeApi.showObj(nativeProps)
|
|
161
165
|
console.log('Redux 初始数据:', JSON.stringify(nativeProps))
|
|
@@ -6,10 +6,11 @@ import {DevInfo, DpValue} from 'tuya-panel-kit'
|
|
|
6
6
|
import {NativeApi} from '../../api/native'
|
|
7
7
|
import {useDispatch} from 'react-redux'
|
|
8
8
|
import {GlobalParams} from '../GlobalParams'
|
|
9
|
-
import {snakeCase} from 'lodash'
|
|
9
|
+
import {isNumber, snakeCase} from 'lodash'
|
|
10
10
|
|
|
11
11
|
export interface NativeProps {
|
|
12
12
|
familyName: string
|
|
13
|
+
role: 0 | 1 | 2 | 3
|
|
13
14
|
deviceInfo: DeviceInfo
|
|
14
15
|
uaGroupInfo: UAGroupInfo
|
|
15
16
|
timeSchedule?: boolean
|
|
@@ -31,6 +32,7 @@ export interface UAGroupInfo {
|
|
|
31
32
|
|
|
32
33
|
const initialState: NativeProps = {
|
|
33
34
|
familyName: '',
|
|
35
|
+
role: 2,
|
|
34
36
|
deviceInfo: {
|
|
35
37
|
devId: '',
|
|
36
38
|
pId: '',
|
|
@@ -64,6 +66,9 @@ const nativePropsSlice = createSlice({
|
|
|
64
66
|
if (!!action.payload.familyName) {
|
|
65
67
|
state.familyName = action.payload.familyName
|
|
66
68
|
}
|
|
69
|
+
if (isNumber(action.payload.role)) {
|
|
70
|
+
state.role = action.payload.role
|
|
71
|
+
}
|
|
67
72
|
if (!!action.payload.deviceInfo.pId) {
|
|
68
73
|
state.deviceInfo.pId = action.payload.deviceInfo.pId
|
|
69
74
|
}
|
|
@@ -145,6 +150,10 @@ const useFamilyName: () => string = () => {
|
|
|
145
150
|
return useSelector(store => store.ldvModules.familyName)
|
|
146
151
|
}
|
|
147
152
|
|
|
153
|
+
const useRole: () => 0 | 1 | 2 | 3 = () => {
|
|
154
|
+
return useSelector(store => store.ldvModules.role)
|
|
155
|
+
}
|
|
156
|
+
|
|
148
157
|
function useDp<T, R extends any>(dp: string): [T, (value: T) => Promise<Result<R>>] {
|
|
149
158
|
const deviceId = useDeviceId()
|
|
150
159
|
const dispatch = useDispatch()
|
|
@@ -281,6 +290,7 @@ export {
|
|
|
281
290
|
useScaledDp,
|
|
282
291
|
useDps,
|
|
283
292
|
useFamilyName,
|
|
293
|
+
useRole,
|
|
284
294
|
useTimeSchedule,
|
|
285
295
|
useEnergieverbrauch,
|
|
286
296
|
}
|