diff --git a/uni_modules/uni-getbatteryinfo/index.d.ts b/uni_modules/uni-getbatteryinfo/index.d.ts deleted file mode 100644 index 60b511f68f86e4fff522ee27ff04f3d5713a9645..0000000000000000000000000000000000000000 --- 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 cd789cb132dc3c8d379a9f31f561dafbf879d995..ea26d5232b6a4c0b178df6d4d7d065b0f57964f9 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 d64e60860de6405b9a417afd00d17d64e479a314..edf8bc75a9cdbc420503cf3fdb7eca5696a31a54 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