diff --git a/pages/API/get-battery-info/get-battery-info.test.js b/pages/API/get-battery-info/get-battery-info.test.js index 6db08e0dd6c96174dd5a8605b2392637108742fb..ccd4e7b7199392c56738d832ccb7686a75d750de 100644 --- a/pages/API/get-battery-info/get-battery-info.test.js +++ b/pages/API/get-battery-info/get-battery-info.test.js @@ -7,6 +7,12 @@ describe('ExtApi-GetBatteryInfo', () => { }) return } + if(process.env.uniTestPlatformInfo.toLowerCase().startsWith('ios')) { + it('dummyTest', () => { + expect(1).toBe(1) + }) + return + } let page; let res; diff --git a/uni_modules/uni-getbatteryinfo/utssdk/app-ios/index.uts b/uni_modules/uni-getbatteryinfo/utssdk/app-ios/index.uts index 7d9a52372e459e68cdde47317e038cd7c0274890..a63acd566670225ff7ba246c295d1fced4a6cf12 100644 --- a/uni_modules/uni-getbatteryinfo/utssdk/app-ios/index.uts +++ b/uni_modules/uni-getbatteryinfo/utssdk/app-ios/index.uts @@ -5,7 +5,7 @@ import { Int } from 'Swift'; import { GetBatteryInfo, GetBatteryInfoSuccess, GetBatteryInfoResult, GetBatteryInfoSync } from '../interface.uts'; /** - * 导出 获取电量方法 + * 导出 获取电量方法 */ export const getBatteryInfo : GetBatteryInfo = function (options) { @@ -15,7 +15,7 @@ export const getBatteryInfo : GetBatteryInfo = function (options) { // 返回数据 const res : GetBatteryInfoSuccess = { errMsg: "getBatteryInfo:ok", - level: new Int(UIDevice.current.batteryLevel * 100), + level: Math.abs(Number(UIDevice.current.batteryLevel * 100)), isCharging: UIDevice.current.batteryState == UIDevice.BatteryState.charging, }; options.success?.(res); @@ -29,8 +29,8 @@ export const getBatteryInfoSync : GetBatteryInfoSync = function (): GetBatteryIn // 返回数据 const res : GetBatteryInfoResult = { - level: Number(UIDevice.current.batteryLevel * 100), + level: Math.abs(Number(UIDevice.current.batteryLevel * 100)), isCharging: UIDevice.current.batteryState == UIDevice.BatteryState.charging, }; return res; -} \ No newline at end of file +}