diff --git a/uni_modules/uni-getbatteryinfo/index.d.ts b/uni_modules/uni-getbatteryinfo/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..38b6f5e9e3b045d501fc7fd421b56153d120a501 --- /dev/null +++ b/uni_modules/uni-getbatteryinfo/index.d.ts @@ -0,0 +1,35 @@ +interface GetBatteryInfoSuccessCallbackResult { + /** + * 是否正在充电中 + */ + isCharging: boolean; + /** + * 设备电量,范围 1 - 100 + */ + level: string; + errMsg: string; +} + +interface GetBatteryInfoOption { + /** + * 接口调用结束的回调函数(调用成功、失败都会执行) + */ + complete?: Function + /** + * 接口调用失败的回调函数 + */ + fail?: Function + /** + * 接口调用成功的回调函数 + */ + success?: (result: GetBatteryInfoSuccessCallbackResult) => void +} + +declare class Uni { + /** + * 获取设备电量 + * + * 文档: [https://uniapp.dcloud.net.cn/api/system/batteryInfo.html) + */ + getBatteryInfo(option?: GetBatteryInfoOption): void; +}