@ledvance/base 1.2.23 → 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,12 +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
|
+
setGroupDevices,
|
|
11
12
|
setGroupNativeProps,
|
|
12
13
|
setNativeProps,
|
|
14
|
+
setSystemTimeFormat,
|
|
13
15
|
UAGroupInfo,
|
|
14
16
|
} from './models/modules/NativePropsSlice'
|
|
15
17
|
import { DpSchema, GlobalParams } from './models/GlobalParams'
|
|
@@ -114,7 +116,11 @@ const composeLayout = (component: React.ComponentType) => {
|
|
|
114
116
|
this.initReduxDeviceNativeProps(props.ldvDevInfo)
|
|
115
117
|
} else {
|
|
116
118
|
this.initReduxGroupNativeProps(props.uaGroupInfo)
|
|
119
|
+
this.initGroupDevices(props.uaGroupInfo?.tyGroupId)
|
|
117
120
|
}
|
|
121
|
+
getSystemTimeFormat().then(time => {
|
|
122
|
+
dispatch(setSystemTimeFormat(time === 24))
|
|
123
|
+
})
|
|
118
124
|
}
|
|
119
125
|
|
|
120
126
|
initReduxDeviceNativeProps(ldvDevInfo: LdvDevInfo) {
|
|
@@ -132,9 +138,12 @@ const composeLayout = (component: React.ComponentType) => {
|
|
|
132
138
|
dps: {},
|
|
133
139
|
pId: '',
|
|
134
140
|
config: {},
|
|
141
|
+
groupDevices: []
|
|
135
142
|
},
|
|
136
143
|
familyName: ldvDevInfo.familyName,
|
|
137
144
|
role: ldvDevInfo.role,
|
|
145
|
+
moods: [],
|
|
146
|
+
is24HourClock: true
|
|
138
147
|
}
|
|
139
148
|
NativeApi.showObj(nativeProps)
|
|
140
149
|
console.log('Redux 初始数据:', JSON.stringify(nativeProps))
|
|
@@ -159,9 +168,12 @@ const composeLayout = (component: React.ComponentType) => {
|
|
|
159
168
|
config: {
|
|
160
169
|
...JSON.parse(uaGroupInfo.config || '{}'),
|
|
161
170
|
},
|
|
171
|
+
groupDevices: []
|
|
162
172
|
},
|
|
163
173
|
familyName: uaGroupInfo.familyName,
|
|
164
174
|
role: uaGroupInfo.role,
|
|
175
|
+
moods: [],
|
|
176
|
+
is24HourClock: true
|
|
165
177
|
}
|
|
166
178
|
NativeApi.showObj(nativeProps)
|
|
167
179
|
console.log('Redux 初始数据:', JSON.stringify(nativeProps))
|
|
@@ -169,6 +181,14 @@ const composeLayout = (component: React.ComponentType) => {
|
|
|
169
181
|
dispatch(setGroupNativeProps(nativeProps))
|
|
170
182
|
}
|
|
171
183
|
|
|
184
|
+
async initGroupDevices(tyGroupId: number){
|
|
185
|
+
if(!tyGroupId) return
|
|
186
|
+
const res = await NativeApi.getGroupDevices(tyGroupId)
|
|
187
|
+
if(res.success && Array.isArray(res.data)){
|
|
188
|
+
dispatch(setGroupDevices(res.data))
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
172
192
|
setDpSchemaMap(schema: string): any {
|
|
173
193
|
// 处理物模型协议和dps
|
|
174
194
|
const dpSchemaMap: Record<string, DpSchema> = {}
|
|
@@ -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,7 +18,7 @@ export interface NativeProps {
|
|
|
17
18
|
timeSchedule?: boolean
|
|
18
19
|
energieverbrauch?: object
|
|
19
20
|
moods: any[]
|
|
20
|
-
|
|
21
|
+
is24HourClock: boolean
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
export interface DeviceInfo {
|
|
@@ -31,6 +32,7 @@ export interface UAGroupInfo {
|
|
|
31
32
|
pId: string
|
|
32
33
|
dps: any
|
|
33
34
|
config: any
|
|
35
|
+
groupDevices: GroupDeviceInfo[]
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
const initialState: NativeProps = {
|
|
@@ -46,11 +48,12 @@ const initialState: NativeProps = {
|
|
|
46
48
|
pId: '',
|
|
47
49
|
dps: {},
|
|
48
50
|
config: {},
|
|
51
|
+
groupDevices: []
|
|
49
52
|
},
|
|
50
53
|
timeSchedule: false,
|
|
51
54
|
energieverbrauch: {},
|
|
52
55
|
moods: [],
|
|
53
|
-
|
|
56
|
+
is24HourClock: true
|
|
54
57
|
}
|
|
55
58
|
|
|
56
59
|
// energy generation
|
|
@@ -84,6 +87,9 @@ const nativePropsSlice = createSlice({
|
|
|
84
87
|
if (!!action.payload.familyName) {
|
|
85
88
|
state.familyName = action.payload.familyName
|
|
86
89
|
}
|
|
90
|
+
if (isNumber(action.payload.role)) {
|
|
91
|
+
state.role = action.payload.role
|
|
92
|
+
}
|
|
87
93
|
if (!!action.payload.uaGroupInfo.pId) {
|
|
88
94
|
state.uaGroupInfo.pId = action.payload.uaGroupInfo.pId
|
|
89
95
|
}
|
|
@@ -109,8 +115,11 @@ const nativePropsSlice = createSlice({
|
|
|
109
115
|
state.moods = action.payload
|
|
110
116
|
},
|
|
111
117
|
setGroupDevices(state, action: PayloadAction<any>) {
|
|
112
|
-
state.groupDevices = action.payload
|
|
118
|
+
state.uaGroupInfo.groupDevices = action.payload
|
|
113
119
|
},
|
|
120
|
+
setSystemTimeFormat(state, action: PayloadAction<any>) {
|
|
121
|
+
state.is24HourClock = action.payload
|
|
122
|
+
}
|
|
114
123
|
},
|
|
115
124
|
})
|
|
116
125
|
|
|
@@ -221,15 +230,19 @@ const useMoods = (): [any[], (v: any[]) => void] => {
|
|
|
221
230
|
return [dps, setMoodsFn]
|
|
222
231
|
}
|
|
223
232
|
|
|
224
|
-
const useGroupDevices = (): [
|
|
225
|
-
const dps = useSelector(store => store.ldvModules.groupDevices)
|
|
233
|
+
const useGroupDevices = (): [GroupDeviceInfo[], (v: GroupDeviceInfo[]) => void] => {
|
|
234
|
+
const dps = useSelector(store => store.ldvModules.uaGroupInfo.groupDevices)
|
|
226
235
|
const dispatch = useDispatch()
|
|
227
|
-
const setGroupDevicesFn = (value:
|
|
236
|
+
const setGroupDevicesFn = (value: GroupDeviceInfo[]) => {
|
|
228
237
|
dispatch(setGroupDevices(value))
|
|
229
238
|
}
|
|
230
239
|
return [dps, setGroupDevicesFn]
|
|
231
240
|
}
|
|
232
241
|
|
|
242
|
+
const useSystemTimeFormate = (): boolean => {
|
|
243
|
+
return useSelector(store => store.ldvModules.is24HourClock)
|
|
244
|
+
}
|
|
245
|
+
|
|
233
246
|
const useEnergieverbrauch = () => {
|
|
234
247
|
const dps = useSelector(store => store.ldvModules.energieverbrauch)
|
|
235
248
|
const dispatch = useDispatch()
|
|
@@ -333,6 +346,7 @@ export const {
|
|
|
333
346
|
setTimeSchedule,
|
|
334
347
|
setMoods,
|
|
335
348
|
setGroupDevices,
|
|
349
|
+
setSystemTimeFormat,
|
|
336
350
|
setEnergieverbrauch,
|
|
337
351
|
} = nativePropsSlice.actions
|
|
338
352
|
|
|
@@ -350,5 +364,6 @@ export {
|
|
|
350
364
|
useTimeSchedule,
|
|
351
365
|
useMoods,
|
|
352
366
|
useGroupDevices,
|
|
367
|
+
useSystemTimeFormate,
|
|
353
368
|
useEnergieverbrauch,
|
|
354
369
|
}
|
package/.temp/uaDevInfo.txt
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
@ColumnInfo(name = "device_id")
|
|
2
|
-
val deviceId: String,
|
|
3
|
-
@ColumnInfo(name = "device_name")
|
|
4
|
-
val deviceName: String,
|
|
5
|
-
@ColumnInfo(name = "cat_id")
|
|
6
|
-
val catId: String,
|
|
7
|
-
@ColumnInfo(name = "channel_no")
|
|
8
|
-
val channelNo: Int,
|
|
9
|
-
@ColumnInfo(name = "device_category")
|
|
10
|
-
val deviceCategory: String,
|
|
11
|
-
@ColumnInfo(name = "device_image")
|
|
12
|
-
val deviceImage: String,
|
|
13
|
-
@ColumnInfo(name = "tuya_device_id")
|
|
14
|
-
val tuyaDeviceId: String,
|
|
15
|
-
// deviceType 对应 ProductInfo 的 productId
|
|
16
|
-
@ColumnInfo(name = "device_type")
|
|
17
|
-
val deviceType: String,
|
|
18
|
-
@ColumnInfo(name = "offline_time")
|
|
19
|
-
val offlineTime: String,
|
|
20
|
-
@ColumnInfo(name = "rn_package")
|
|
21
|
-
val rnPackage: String?,
|
|
22
|
-
@ColumnInfo(name = "status")
|
|
23
|
-
val status: Int,
|
|
24
|
-
@ColumnInfo(name = "create_time")
|
|
25
|
-
val createTime: String,
|
|
26
|
-
@ColumnInfo(name = "version")
|
|
27
|
-
val version: String,
|
|
28
|
-
@ColumnInfo(name = "user_id")
|
|
29
|
-
val userId: String,
|
|
30
|
-
@ColumnInfo(name = "family_id")
|
|
31
|
-
val familyId: Long,
|
|
32
|
-
@ColumnInfo(name = "room_id")
|
|
33
|
-
val roomId: Long,
|
|
34
|
-
@ColumnInfo(name = "room_name")
|
|
35
|
-
val roomName: String,
|
|
36
|
-
@ColumnInfo(name = "is_shared")
|
|
37
|
-
val isShared: Int,
|
|
38
|
-
@ColumnInfo(name = "local_index")
|
|
39
|
-
val localIndex: String,
|
|
40
|
-
@ColumnInfo(name = "resource_category")
|
|
41
|
-
val resourceCategory: String,
|
|
42
|
-
@ColumnInfo(name = "resource_id")
|
|
43
|
-
val resourceId: String,
|
|
44
|
-
@ColumnInfo(name = "resource_identifier")
|
|
45
|
-
val resourceIdentifier: String,
|
|
46
|
-
@ColumnInfo(name = "resource_type")
|
|
47
|
-
val resourceType: Int,
|
|
48
|
-
@ColumnInfo(name = "index")
|
|
49
|
-
val index: Int = 0,
|
|
50
|
-
@ColumnInfo(name = "switch_state")
|
|
51
|
-
val switchState: Boolean = true
|