index.d.ts 1016 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. declare namespace UniNamespace {
  2. interface GetBatteryInfoSuccessCallbackResult {
  3. /**
  4. * 是否正在充电中
  5. */
  6. isCharging: boolean;
  7. /**
  8. * 设备电量,范围 1 - 100
  9. */
  10. level: number;
  11. errMsg: string;
  12. }
  13. interface GetBatteryInfoOption {
  14. /**
  15. * 接口调用结束的回调函数(调用成功、失败都会执行)
  16. */
  17. complete?: Function
  18. /**
  19. * 接口调用失败的回调函数
  20. */
  21. fail?: Function
  22. /**
  23. * 接口调用成功的回调函数
  24. */
  25. success?: (result: GetBatteryInfoSuccessCallbackResult) => void
  26. }
  27. }
  28. declare interface Uni {
  29. /**
  30. * 获取设备电量
  31. *
  32. * @tutorial https://uniapp.dcloud.net.cn/api/system/batteryInfo.html
  33. */
  34. getBatteryInfo(option?: UniNamespace.GetBatteryInfoOption): void;
  35. /**
  36. * 同步获取电池电量信息
  37. * @tutorial https://uniapp.dcloud.net.cn/api/system/batteryInfo.html
  38. */
  39. getBatteryInfoSync(): UniNamespace.GetBatteryInfoSuccessCallbackResult;
  40. }