From b51203e1ba1e45a642fa009ea4dac060c2312336 Mon Sep 17 00:00:00 2001 From: lizhongyi Date: Sun, 28 Apr 2024 19:42:42 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4get-battery-info=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/API/get-battery-info/get-battery-info.test.js | 6 ++++++ uni_modules/uni-getbatteryinfo/utssdk/app-ios/index.uts | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) 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 6db08e0d..ccd4e7b7 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 7d9a5237..a63acd56 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 +} -- GitLab