From 014825784e63bfe025a5d91d5746954557b40779 Mon Sep 17 00:00:00 2001 From: yanyilin Date: Fri, 15 Sep 2023 22:20:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=81=A2=E5=A4=8Dindex.d.ts=20for=20HBuilderX?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- uni_modules/uni-getbatteryinfo/package.json | 2 +- .../utssdk/app-android/index.uts | 5 ++- .../uni-getbatteryinfo/utssdk/index.d.ts | 42 +++++++++++++++++++ 3 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 uni_modules/uni-getbatteryinfo/utssdk/index.d.ts diff --git a/uni_modules/uni-getbatteryinfo/package.json b/uni_modules/uni-getbatteryinfo/package.json index ea26d523..0fc760c9 100644 --- a/uni_modules/uni-getbatteryinfo/package.json +++ b/uni_modules/uni-getbatteryinfo/package.json @@ -1,7 +1,7 @@ { "id": "uni-getbatteryinfo", "displayName": "uni-getbatteryinfo", - "version": "1.3.0", + "version": "1.3.1", "description": "使用uts开发,实现在多个平台获取电池电量功能", "keywords": [ "battery" diff --git a/uni_modules/uni-getbatteryinfo/utssdk/app-android/index.uts b/uni_modules/uni-getbatteryinfo/utssdk/app-android/index.uts index 98192f2f..de7e2c1f 100644 --- a/uni_modules/uni-getbatteryinfo/utssdk/app-android/index.uts +++ b/uni_modules/uni-getbatteryinfo/utssdk/app-android/index.uts @@ -1,8 +1,9 @@ import Context from "android.content.Context"; import BatteryManager from "android.os.BatteryManager"; -import { UTSAndroid } from "io.dcloud.uts"; -import { GetBatteryInfo, GetBatteryInfoOptions, GetBatteryInfoSuccess, GetBatteryInfoResult,GetBatteryInfoSync } from '../interface.uts' +import { GetBatteryInfo, GetBatteryInfoOptions, GetBatteryInfoSuccess, GetBatteryInfoResult,GetBatteryInfoSync } from '../interface.uts' + + /** * 异步获取电量 */ diff --git a/uni_modules/uni-getbatteryinfo/utssdk/index.d.ts b/uni_modules/uni-getbatteryinfo/utssdk/index.d.ts new file mode 100644 index 00000000..bfd890c1 --- /dev/null +++ b/uni_modules/uni-getbatteryinfo/utssdk/index.d.ts @@ -0,0 +1,42 @@ +declare namespace UniNamespace { + interface GetBatteryInfoSuccessCallbackResult { + /** + * 是否正在充电中 + */ + isCharging: boolean; + /** + * 设备电量,范围 1 - 100 + */ + level: number; + errMsg: string; + } + + interface GetBatteryInfoOption { + /** + * 接口调用结束的回调函数(调用成功、失败都会执行) + */ + complete?: Function + /** + * 接口调用失败的回调函数 + */ + fail?: Function + /** + * 接口调用成功的回调函数 + */ + success?: (result: GetBatteryInfoSuccessCallbackResult) => void + } +} + +declare interface Uni { + /** + * 获取设备电量 + * + * 文档: [https://uniapp.dcloud.net.cn/api/system/batteryInfo.html](https://uniapp.dcloud.net.cn/api/system/batteryInfo.html) + */ + getBatteryInfo(option?: UniNamespace.GetBatteryInfoOption): void; + + /** + * 同步获取电池电量信息 + */ + GetBatteryInfoSync(): UniNamespace.GetBatteryInfoSuccessCallbackResult; +} -- GitLab