@ledvance/base 1.3.68 → 1.3.72
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/localazy.json +8 -1
- package/package.json +1 -1
- package/src/api/native.ts +12 -11
- package/src/components/ColorAdjustView.tsx +77 -11
- package/src/components/ColorTempAdjustView.tsx +95 -6
- package/src/components/rect-color-and-bright-picker/ColourPicker.tsx +269 -0
- package/src/components/rect-color-and-bright-picker/RectPicker.tsx +448 -0
- package/src/components/rect-color-and-bright-picker/Slider.tsx +589 -0
- package/src/components/rect-color-and-bright-picker/Thumb.tsx +94 -0
- package/src/components/rect-color-and-bright-picker/WhitePicker.tsx +362 -0
- package/src/components/rect-color-and-bright-picker/brightness-icons/index.ts +8 -0
- package/src/components/rect-color-and-bright-picker/index.tsx +5 -0
- package/src/components/rect-color-and-bright-picker/res/index.ts +3 -0
- package/src/components/rect-color-and-bright-picker/res/thumb-mask@2x.png +0 -0
- package/src/components/rect-color-and-bright-picker/res/thumb-mask@3x.png +0 -0
- package/src/components/rect-color-and-bright-picker/utils/color.ts +73 -0
- package/src/composeLayout.tsx +3 -1
- package/src/i18n/strings.ts +196 -0
- package/src/models/TuyaApi.ts +132 -0
- package/src/models/modules/NativePropsSlice.tsx +13 -2
- package/src/utils/interface.ts +20 -0
- package/translateKey.txt +7 -0
package/src/models/TuyaApi.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import {commonApi} from '@tuya/tuya-panel-api'
|
|
2
2
|
import { IGetDpResultByHourResponse, IGetDpResultByMonthResponse } from '@tuya/tuya-panel-api/lib/common/interface'
|
|
3
3
|
import {sendAppEvent} from "../api/native";
|
|
4
|
+
import {retryWithBackoff} from "../utils/index";
|
|
5
|
+
import {TYSdk} from "tuya-panel-kit";
|
|
4
6
|
|
|
5
7
|
export interface PagingResult<T> {
|
|
6
8
|
data: T
|
|
@@ -148,3 +150,133 @@ export async function getDpResultByHour(
|
|
|
148
150
|
}
|
|
149
151
|
}
|
|
150
152
|
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* 获取设备所有数据点记录(支持失败重试)
|
|
156
|
+
* @param commonApi API实例
|
|
157
|
+
* @param devId 设备ID
|
|
158
|
+
* @param dpIds 数据点ID,如 '19'
|
|
159
|
+
* @param sortType 排序方式
|
|
160
|
+
* @param retryOptions 重试选项
|
|
161
|
+
* @returns 所有数据点记录
|
|
162
|
+
*/
|
|
163
|
+
export async function getAllDpReportLogs(
|
|
164
|
+
devId: string,
|
|
165
|
+
dpIds: string[],
|
|
166
|
+
sortType: 'ASC' | 'DESC' = 'ASC',
|
|
167
|
+
retryOptions: {
|
|
168
|
+
maxRetries?: number;
|
|
169
|
+
initialDelay?: number;
|
|
170
|
+
maxDelay?: number;
|
|
171
|
+
backoffFactor?: number;
|
|
172
|
+
} = {}
|
|
173
|
+
): Promise<DpReportSataData[]> {
|
|
174
|
+
const limit = 100; // 每次请求的数据量
|
|
175
|
+
let offset = 1;
|
|
176
|
+
let hasNext = true;
|
|
177
|
+
const allDps: DpReportSataData[] = [];
|
|
178
|
+
|
|
179
|
+
while (hasNext) {
|
|
180
|
+
try {
|
|
181
|
+
// 使用重试函数包装API调用
|
|
182
|
+
const res: DpReportSataResData = await retryWithBackoff(
|
|
183
|
+
() => commonApi.statApi.getDpReportLog({
|
|
184
|
+
devId,
|
|
185
|
+
dpIds: dpIds.join(','),
|
|
186
|
+
offset,
|
|
187
|
+
limit,
|
|
188
|
+
sortType
|
|
189
|
+
}),
|
|
190
|
+
{
|
|
191
|
+
...retryOptions,
|
|
192
|
+
// 自定义判断哪些错误需要重试
|
|
193
|
+
shouldRetry: (error) => {
|
|
194
|
+
// 网络错误、超时错误或服务器错误(5xx)通常需要重试
|
|
195
|
+
const isNetworkError = error.name === 'NetworkError' ||
|
|
196
|
+
error.name === 'TimeoutError' ||
|
|
197
|
+
(error.response && error.response.status >= 500);
|
|
198
|
+
|
|
199
|
+
// 对于特定的业务错误码也可以在这里添加判断
|
|
200
|
+
return isNetworkError;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
);
|
|
204
|
+
|
|
205
|
+
allDps.push(...res.dps);
|
|
206
|
+
|
|
207
|
+
if (res.hasNext) {
|
|
208
|
+
offset += limit;
|
|
209
|
+
} else {
|
|
210
|
+
hasNext = false;
|
|
211
|
+
}
|
|
212
|
+
} catch (error) {
|
|
213
|
+
console.error('获取数据点记录失败,不再继续获取:', error);
|
|
214
|
+
hasNext = false;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
return allDps;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
export const saveDeviceExtInfo = async (devId: string, key: string, value: string): Promise<boolean> => {
|
|
222
|
+
try {
|
|
223
|
+
return await new Promise<any>((resolve, reject) => {
|
|
224
|
+
TYSdk.native.apiRNRequest(
|
|
225
|
+
{
|
|
226
|
+
v: "1.0",
|
|
227
|
+
postData: {
|
|
228
|
+
value: value,
|
|
229
|
+
key: key,
|
|
230
|
+
devId: devId
|
|
231
|
+
},
|
|
232
|
+
a: "tuya.m.solution.device.storage.save"
|
|
233
|
+
},
|
|
234
|
+
(success: any) => {
|
|
235
|
+
console.log('tuya.m.solution.device.storage.save success', success)
|
|
236
|
+
resolve(success)
|
|
237
|
+
},
|
|
238
|
+
(error: any) => {
|
|
239
|
+
console.log('tuya.m.solution.device.storage.save error', error)
|
|
240
|
+
reject(error)
|
|
241
|
+
}
|
|
242
|
+
)
|
|
243
|
+
})
|
|
244
|
+
} catch (error) {
|
|
245
|
+
console.log('saveDeviceExtInfo error', error)
|
|
246
|
+
return false
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
export const getDeviceExtInfo = async (devId: string, key: string): Promise<string | null> => {
|
|
251
|
+
try {
|
|
252
|
+
const success = await new Promise<any>((resolve, reject) => {
|
|
253
|
+
TYSdk.native.apiRNRequest(
|
|
254
|
+
{
|
|
255
|
+
v: "1.0",
|
|
256
|
+
postData: {
|
|
257
|
+
"key": key,
|
|
258
|
+
"devId": devId
|
|
259
|
+
},
|
|
260
|
+
a: "tuya.m.solution.device.storage.get"
|
|
261
|
+
},
|
|
262
|
+
(success: any) => {
|
|
263
|
+
console.log('tuya.m.solution.device.storage.get success', success)
|
|
264
|
+
resolve(success)
|
|
265
|
+
},
|
|
266
|
+
(error: any) => {
|
|
267
|
+
console.log('tuya.m.solution.device.storage.get error', error)
|
|
268
|
+
reject(error)
|
|
269
|
+
}
|
|
270
|
+
)
|
|
271
|
+
})
|
|
272
|
+
|
|
273
|
+
let data = success
|
|
274
|
+
if (typeof success === 'string') {
|
|
275
|
+
data = JSON.parse(success)
|
|
276
|
+
}
|
|
277
|
+
return data.value
|
|
278
|
+
} catch (error) {
|
|
279
|
+
console.log('getDeviceExtInfo error', error)
|
|
280
|
+
return null
|
|
281
|
+
}
|
|
282
|
+
}
|
|
@@ -24,6 +24,7 @@ export interface NativeProps {
|
|
|
24
24
|
is24HourClock: boolean
|
|
25
25
|
timeZone: string
|
|
26
26
|
gestureControlValues: GestureControlType
|
|
27
|
+
newPalette?: boolean
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
interface FlagModeState {
|
|
@@ -87,7 +88,8 @@ const initialState: NativeProps = {
|
|
|
87
88
|
timeZone: 'Europe/Berlin',
|
|
88
89
|
gestureControlValues: {
|
|
89
90
|
isEnd: false
|
|
90
|
-
}
|
|
91
|
+
},
|
|
92
|
+
newPalette: false
|
|
91
93
|
}
|
|
92
94
|
|
|
93
95
|
// energy generation
|
|
@@ -188,6 +190,9 @@ const nativePropsSlice = createSlice({
|
|
|
188
190
|
keys.forEach(key => {
|
|
189
191
|
state.gestureControlValues[key] = action.payload[key]
|
|
190
192
|
})
|
|
193
|
+
},
|
|
194
|
+
setNewPalette(state, action: PayloadAction<boolean>) {
|
|
195
|
+
state.newPalette = action.payload
|
|
191
196
|
}
|
|
192
197
|
},
|
|
193
198
|
})
|
|
@@ -479,6 +484,10 @@ function useGestureControl<K extends keyof GestureControlType>(key: K): [Gesture
|
|
|
479
484
|
return [value]
|
|
480
485
|
}
|
|
481
486
|
|
|
487
|
+
const useNewPalette = () => {
|
|
488
|
+
return useSelector(store => store.ldvModules.newPalette)
|
|
489
|
+
}
|
|
490
|
+
|
|
482
491
|
export const useFanMaxSpeed = () => {
|
|
483
492
|
const { productId } = useDeviceInfo()
|
|
484
493
|
return fanProductList.includes(productId) ? 20 : 3
|
|
@@ -505,6 +514,7 @@ export const {
|
|
|
505
514
|
setTimeZone,
|
|
506
515
|
setEnergieverbrauch,
|
|
507
516
|
setGestureControlValues,
|
|
517
|
+
setNewPalette,
|
|
508
518
|
} = nativePropsSlice.actions
|
|
509
519
|
|
|
510
520
|
export {
|
|
@@ -531,5 +541,6 @@ export {
|
|
|
531
541
|
useTimeZoneCity,
|
|
532
542
|
useEnergieverbrauch,
|
|
533
543
|
useGestureControl,
|
|
534
|
-
useDeviceCategory
|
|
544
|
+
useDeviceCategory,
|
|
545
|
+
useNewPalette
|
|
535
546
|
}
|
package/src/utils/interface.ts
CHANGED
|
@@ -90,3 +90,23 @@ export interface DiySceneNode {
|
|
|
90
90
|
top: HSV
|
|
91
91
|
bottom: HSV
|
|
92
92
|
}
|
|
93
|
+
|
|
94
|
+
export interface RoutineCondition {
|
|
95
|
+
type: 'DeviceStatusChange' | 'TimeSchedule' | 'WeatherChange' | 'LocationChange'
|
|
96
|
+
targetId: string
|
|
97
|
+
operator: 'Equal' | 'Greater' | 'Less'
|
|
98
|
+
value: string
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export interface RoutineTask {
|
|
102
|
+
type: 'Device' | 'Group' | 'Routine' | 'Notification' | 'Delay'
|
|
103
|
+
targetId: string
|
|
104
|
+
value: string
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export interface RoutineParam {
|
|
108
|
+
pageType: 'Create' | 'List' | 'CreateAndList'
|
|
109
|
+
conditionType?: 'All' | 'Any'
|
|
110
|
+
conditions?: RoutineCondition[]
|
|
111
|
+
tasks?: RoutineTask[]
|
|
112
|
+
}
|
package/translateKey.txt
CHANGED
|
@@ -1186,3 +1186,10 @@ camera_calibration_desc
|
|
|
1186
1186
|
switchstate1selection
|
|
1187
1187
|
switchstate2selection
|
|
1188
1188
|
switchstate3selection
|
|
1189
|
+
soilsensor_R
|
|
1190
|
+
soilsensor_R1
|
|
1191
|
+
soilsensor_R2
|
|
1192
|
+
body_create_your_own_routine
|
|
1193
|
+
setting_cur_passwd
|
|
1194
|
+
setting_set_passwd
|
|
1195
|
+
camera_user
|