@ledvance/base 1.2.64 → 1.2.65

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
@@ -4,7 +4,7 @@
4
4
  "name": "@ledvance/base",
5
5
  "pid": [],
6
6
  "uiid": "",
7
- "version": "1.2.64",
7
+ "version": "1.2.65",
8
8
  "scripts": {
9
9
  "prepublishOnly": "python update-localazy.py"
10
10
  },
package/src/api/native.ts CHANGED
@@ -18,6 +18,7 @@ interface LDVDevicePanelManager {
18
18
  getTimeZone: () => string
19
19
  groupControl: (tyGroupId: number, dps: string, config: string) => Promise<NativeResult<any>>
20
20
  groupControlToTuya: (tyGroupId: number, dps: string) => Promise<NativeResult<any>>
21
+ groupControlToEzviz: (tyGroupId: number, config: string) => Promise<NativeResult<any>>
21
22
  getFeature: (deviceId: string, featureId: string, callback: (res: NativeResult<string>) => void) => void
22
23
  putFeature: (deviceId: string, featureId: string, value: any, callback: (res: NativeResult<string>) => void) => void
23
24
  getGroupDevices: (tyGroupId: number) => Promise<NativeResult<string>>
@@ -339,6 +340,15 @@ export class NativeApi {
339
340
  }
340
341
  }
341
342
 
343
+ static async putGroupEzvizConfig(tyGroupId: number, config: string){
344
+ const nativeResult = await devicePanel.groupControlToEzviz(tyGroupId, config)
345
+ return {
346
+ success: nativeResult.result,
347
+ msg: nativeResult.msg,
348
+ data: nativeResult.data,
349
+ }
350
+ }
351
+
342
352
  }
343
353
 
344
354
  // 打开下载文件
@@ -329,6 +329,25 @@ export function putGroupTYDps(tyGroupId: number, dps: Record<string, any>) {
329
329
  return NativeApi.putGroupTYDps(tyGroupId, JSON.stringify(dps))
330
330
  }
331
331
 
332
+ export function useGroupEzvizConfig<T>(featureKey: string): [T, (newConfig: T) => Promise<Result<any>>] {
333
+ const tyGroupId = useUAGroupInfo().tyGroupId
334
+ const config = useUAGroupInfo().config || {}
335
+ const dispatch = useDispatch()
336
+ const { setGroupConfig } = nativePropsSlice.actions
337
+ const setConfig = useCallback(async (newConfig: T) => {
338
+ const configs = {
339
+ [featureKey]: newConfig
340
+ }
341
+ const res = await NativeApi.putGroupEzvizConfig(tyGroupId, JSON.stringify(configs))
342
+ if (res.success) {
343
+ // 只在结果成功时才改变 redux 数据
344
+ dispatch(setGroupConfig(configs))
345
+ }
346
+ return res
347
+ }, [])
348
+ return [config[featureKey], setConfig]
349
+ }
350
+
332
351
  export function useGroupConfig<T>(): [T, (dps: any, newConfig: T) => Promise<Result<any>>] {
333
352
  const tyGroupId = useUAGroupInfo().tyGroupId
334
353
  const config = useUAGroupInfo().config || {}