fix(lockscreen): 修复距离电池充满时间显示错误

This commit is contained in:
chika
2021-07-31 14:11:24 +08:00
parent 9d9cac8064
commit 0c709871f3
3 changed files with 17 additions and 2 deletions

View File

@@ -33,6 +33,14 @@ export const useBattery = () => {
return `${~~hour}小时${~~minute}分钟`;
});
// 计算电池充满剩余时间
const calcChargingTime = computed(() => {
console.log(state.battery);
const hour = state.battery.chargingTime / 3600;
const minute = (state.battery.chargingTime / 60) % 60;
return `${~~hour}小时${~~minute}分钟`;
});
// 电池状态
const batteryStatus = computed(() => {
if (state.battery.charging && state.battery.level >= 100) {
@@ -80,5 +88,6 @@ export const useBattery = () => {
...toRefs(state),
batteryStatus,
calcDischargingTime,
calcChargingTime,
};
};