From 1b3ad13e15703a55ce9d42d2abfe105ccf8d4a17 Mon Sep 17 00:00:00 2001 From: yanyilin Date: Fri, 15 Sep 2023 18:14:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=AD=A5uni-getbatteryinfo=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=20for=20HBuilderX3.9.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- uni_modules/uni-getbatteryinfo/index.d.ts | 37 --- uni_modules/uni-getbatteryinfo/package.json | 12 +- .../uni-getbatteryinfo/utssdk/interface.uts | 214 +++++++++--------- 3 files changed, 114 insertions(+), 149 deletions(-) delete mode 100644 uni_modules/uni-getbatteryinfo/index.d.ts diff --git a/uni_modules/uni-getbatteryinfo/index.d.ts b/uni_modules/uni-getbatteryinfo/index.d.ts deleted file mode 100644 index 60b511f6..00000000 --- a/uni_modules/uni-getbatteryinfo/index.d.ts +++ /dev/null @@ -1,37 +0,0 @@ -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; -} diff --git a/uni_modules/uni-getbatteryinfo/package.json b/uni_modules/uni-getbatteryinfo/package.json index cd789cb1..ea26d523 100644 --- a/uni_modules/uni-getbatteryinfo/package.json +++ b/uni_modules/uni-getbatteryinfo/package.json @@ -8,7 +8,7 @@ ], "repository": "", "engines": { - "HBuilderX": "^3.6.0" + "HBuilderX": "^3.9.0" }, "dcloudext": { "type": "uts", @@ -32,10 +32,12 @@ }, "uni_modules": { "uni-ext-api": { - "uni": [ - "getBatteryInfo", - "getBatteryInfoSync" - ] + "uni": { + "getBatteryInfo": "getBatteryInfo", + "getBatteryInfoSync": { + "web": false + } + } }, "dependencies": [], "encrypt": [], diff --git a/uni_modules/uni-getbatteryinfo/utssdk/interface.uts b/uni_modules/uni-getbatteryinfo/utssdk/interface.uts index d64e6086..edf8bc75 100644 --- a/uni_modules/uni-getbatteryinfo/utssdk/interface.uts +++ b/uni_modules/uni-getbatteryinfo/utssdk/interface.uts @@ -1,112 +1,112 @@ -export type GetBatteryInfoSuccess = { - errMsg : string, - /** - * 设备电量,范围1 - 100 - */ - level : number, - /** - * 是否正在充电中 - */ - isCharging : boolean -} - -export type GetBatteryInfoFail = { - /** - * 错误码 - */ - errCode : number, - /** - * 调用API的名称 - */ - errSubject : string, - /** - * 错误的详细信息 - */ - errMsg : string, - /** - * 错误来源 - */ - cause : any | null -} - - - -export type GetBatteryInfoOptions = { - /** - * 接口调用结束的回调函数(调用成功、失败都会执行) - */ - success ?: (res : GetBatteryInfoSuccess) => void - /** - * 接口调用失败的回调函数 - */ - fail ?: (res : GetBatteryInfoFail) => void - /** - * 接口调用成功的回调 - */ - complete ?: (res : any) => void -} - -export type GetBatteryInfoResult = { - /** - * 设备电量,范围1 - 100 - */ - level : number, - /** - * 是否正在充电中 - */ - isCharging : boolean +export type GetBatteryInfoSuccess = { + errMsg : string, + /** + * 设备电量,范围1 - 100 + */ + level : number, + /** + * 是否正在充电中 + */ + isCharging : boolean +} + +// export type GetBatteryInfoFail = { +// /** +// * 错误码 +// */ +// errCode : number, +// /** +// * 调用API的名称 +// */ +// errSubject : string, +// /** +// * 错误的详细信息 +// */ +// errMsg : string, +// /** +// * 错误来源 +// */ +// cause : any | null +// } + + + +export type GetBatteryInfoOptions = { + /** + * 接口调用结束的回调函数(调用成功、失败都会执行) + */ + success ?: (res : GetBatteryInfoSuccess) => void + /** + * 接口调用失败的回调函数 + */ + fail ?: (res : UniError) => void + /** + * 接口调用成功的回调 + */ + complete ?: (res : any) => void } -/** -* 获取电量信息 -* @param {GetBatteryInfoOptions} options -* -* -* @tutorial https://uniapp.dcloud.net.cn/api/system/batteryInfo.html -* @platforms APP-IOS = ^9.0,APP-ANDROID = ^22 -* @since 3.6.11 -* -* @assert () => success({errCode: 0, errSubject: "uni-getBatteryInfo", errMsg: "getBatteryInfo:ok", level: 60, isCharging: false }) -* @assert () => fail({errCode: 1001, errSubject: "uni-getBatteryInfo", errMsg: "getBatteryInfo:fail getAppContext is null" }) -*/ +export type GetBatteryInfoResult = { + /** + * 设备电量,范围1 - 100 + */ + level : number, + /** + * 是否正在充电中 + */ + isCharging : boolean +} + +/** +* 获取电量信息 +* @param {GetBatteryInfoOptions} options +* +* +* @tutorial https://uniapp.dcloud.net.cn/api/system/batteryInfo.html +* @platforms APP-IOS = ^9.0,APP-ANDROID = ^22 +* @since 3.6.11 +* +* @assert () => success({errCode: 0, errSubject: "uni-getBatteryInfo", errMsg: "getBatteryInfo:ok", level: 60, isCharging: false }) +* @assert () => fail({errCode: 1001, errSubject: "uni-getBatteryInfo", errMsg: "getBatteryInfo:fail getAppContext is null" }) +*/ export type GetBatteryInfo = (options : GetBatteryInfoOptions) => void - -export type GetBatteryInfoSync = () => GetBatteryInfoResult - -interface Uni { - - /** - * 获取电池电量信息 - * @description 获取电池电量信息 - * @param {GetBatteryInfoOptions} options - * @example - * ```typescript - * uni.getBatteryInfo({ - * success(res) { - * console.log(res); - * } - * }) - * ``` - * @remark - * - 该接口需要同步调用 - * @uniPlatform { - * "app": { - * "android": { - * "osVer": "4.4.4", - * "uniVer": "3.6.11", - * "unixVer": "3.9.0" - * }, - * "ios": { - * "osVer": "9.0", - * "uniVer": "3.6.11", - * "unixVer": "3.9.0" - * } - * } - * } - * @uniVueVersion 2,3 //支持的vue版本 - * - */ + +export type GetBatteryInfoSync = () => GetBatteryInfoResult + +interface Uni { + + /** + * 获取电池电量信息 + * @description 获取电池电量信息 + * @param {GetBatteryInfoOptions} options + * @example + * ```typescript + * uni.getBatteryInfo({ + * success(res) { + * console.log(res); + * } + * }) + * ``` + * @remark + * - 该接口需要同步调用 + * @uniPlatform { + * "app": { + * "android": { + * "osVer": "4.4.4", + * "uniVer": "3.6.11", + * "unixVer": "3.9.0" + * }, + * "ios": { + * "osVer": "9.0", + * "uniVer": "3.6.11", + * "unixVer": "3.9.0" + * } + * } + * } + * @uniVueVersion 2,3 //支持的vue版本 + * + */ getBatteryInfo : GetBatteryInfo, /** * 同步获取电池电量信息 @@ -134,6 +134,6 @@ interface Uni { * @uniVueVersion 2,3 //支持的vue版本 * */ - getBatteryInfoSync: GetBatteryInfoSync - + getBatteryInfoSync: GetBatteryInfoSync + } \ No newline at end of file -- GitLab