fix: 修复版本号背景图展示不完全问题
This commit is contained in:
@@ -1,5 +1,10 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { computed } from "vue";
|
import { computed } from "vue";
|
||||||
|
import { getDeviceBatteryAPI } from "@/apis";
|
||||||
|
|
||||||
|
const OTA_MIN_BATTERY = 20;
|
||||||
|
const OTA_LOW_BATTERY_TEXT = "电量不足 50%,暂不支持 OTA 升级";
|
||||||
|
const OTA_OFFLINE_TEXT = "请先开启智能弓";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
visible: {
|
visible: {
|
||||||
@@ -42,6 +47,32 @@ const isSuccess = computed(() => props.state === "update_success");
|
|||||||
const isFailure = computed(() => props.state === "update_failure");
|
const isFailure = computed(() => props.state === "update_failure");
|
||||||
// Clamp progress to keep the progress bar width within its container.
|
// Clamp progress to keep the progress bar width within its container.
|
||||||
const progressValue = computed(() => Math.min(100, Math.max(0, Number(props.progress) || 0)));
|
const progressValue = computed(() => Math.min(100, Math.max(0, Number(props.progress) || 0)));
|
||||||
|
|
||||||
|
// 点击立即更新前先校验设备在线状态,再校验设备电量。
|
||||||
|
const handleUpdateClick = async () => {
|
||||||
|
try {
|
||||||
|
const deviceStatus = await getDeviceBatteryAPI();
|
||||||
|
if (deviceStatus?.online !== true) {
|
||||||
|
uni.showToast({
|
||||||
|
title: OTA_OFFLINE_TEXT,
|
||||||
|
icon: "none",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Number(deviceStatus?.battery) <= OTA_MIN_BATTERY) {
|
||||||
|
uni.showToast({
|
||||||
|
title: OTA_LOW_BATTERY_TEXT,
|
||||||
|
icon: "none",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
emit("update");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
emit("update");
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -91,7 +122,7 @@ const progressValue = computed(() => Math.min(100, Math.max(0, Number(props.prog
|
|||||||
<block v-if="isNewVersion">
|
<block v-if="isNewVersion">
|
||||||
<image src="../static/ota/new-ver.png" mode="aspectFit" class="new-ver-img" />
|
<image src="../static/ota/new-ver.png" mode="aspectFit" class="new-ver-img" />
|
||||||
<view v-if="version" class="version-tag-wrap">
|
<view v-if="version" class="version-tag-wrap">
|
||||||
<image src="../static/ota/ota-ver.png" mode="aspectFill" class="version-tag-bg-img" />
|
<image src="../static/ota/ota-ver.png" mode="aspectFit" class="version-tag-bg-img" />
|
||||||
<text class="version-tag">{{ version }}</text>
|
<text class="version-tag">{{ version }}</text>
|
||||||
</view>
|
</view>
|
||||||
<!-- 副标题:如“新版本将优化智能弓体验”,离下方详情 12rpx -->
|
<!-- 副标题:如“新版本将优化智能弓体验”,离下方详情 12rpx -->
|
||||||
@@ -99,7 +130,7 @@ const progressValue = computed(() => Math.min(100, Math.max(0, Number(props.prog
|
|||||||
<!-- 详细说明:如“升级前请确保:...” -->
|
<!-- 详细说明:如“升级前请确保:...” -->
|
||||||
<text v-if="changelog" class="changelog-text">{{ changelog }}</text>
|
<text v-if="changelog" class="changelog-text">{{ changelog }}</text>
|
||||||
<view class="btn-group">
|
<view class="btn-group">
|
||||||
<view class="primary-btn" @click="emit('update')">
|
<view class="primary-btn" @click="handleUpdateClick">
|
||||||
<text class="primary-btn-text">立即更新</text>
|
<text class="primary-btn-text">立即更新</text>
|
||||||
</view>
|
</view>
|
||||||
<text v-if="!forceUpdate" class="skip-text" @click="emit('skip')">暂不更新</text>
|
<text v-if="!forceUpdate" class="skip-text" @click="emit('skip')">暂不更新</text>
|
||||||
@@ -270,6 +301,8 @@ const progressValue = computed(() => Math.min(100, Math.max(0, Number(props.prog
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
width: 116rpx;
|
||||||
|
height: 44rpx;
|
||||||
/* 离标题图 -10rpx,左边距 50rpx,离下方副标题 22rpx */
|
/* 离标题图 -10rpx,左边距 50rpx,离下方副标题 22rpx */
|
||||||
margin-top: -10rpx;
|
margin-top: -10rpx;
|
||||||
margin-left: 50rpx;
|
margin-left: 50rpx;
|
||||||
|
|||||||
@@ -54,6 +54,8 @@ let wifiConnectPollCount = 0;
|
|||||||
const WIFI_CONNECT_POLL_INTERVAL = 2000;
|
const WIFI_CONNECT_POLL_INTERVAL = 2000;
|
||||||
const WIFI_CONNECT_MAX_POLL_COUNT = 15;
|
const WIFI_CONNECT_MAX_POLL_COUNT = 15;
|
||||||
const WIFI_CONNECT_FAILED_TEXT = "连接失败,请检查WiFi密码或WiFi状态";
|
const WIFI_CONNECT_FAILED_TEXT = "连接失败,请检查WiFi密码或WiFi状态";
|
||||||
|
const OTA_MIN_BATTERY = 20;
|
||||||
|
const OTA_LOW_BATTERY_TEXT = "电量不足 50%,暂不支持 OTA 升级";
|
||||||
// 控制授权拒绝弹窗显示/隐藏
|
// 控制授权拒绝弹窗显示/隐藏
|
||||||
const wifiAuthDeniedVisible = ref(false);
|
const wifiAuthDeniedVisible = ref(false);
|
||||||
|
|
||||||
@@ -437,7 +439,7 @@ const pollUpdateTaskStatus = (taskId) => {
|
|||||||
// 判断设备是否满足 OTA 更新条件,不满足时返回精确提示文案。
|
// 判断设备是否满足 OTA 更新条件,不满足时返回精确提示文案。
|
||||||
const getUpdateDisabledReason = (deviceStatus) => {
|
const getUpdateDisabledReason = (deviceStatus) => {
|
||||||
if (deviceStatus?.online !== true) return "请先开启智能弓";
|
if (deviceStatus?.online !== true) return "请先开启智能弓";
|
||||||
if (Number(deviceStatus?.battery) <= 20) return "设备电量不足,请充电至 20% 以上后再更新";
|
if (Number(deviceStatus?.battery) <= OTA_MIN_BATTERY) return OTA_LOW_BATTERY_TEXT;
|
||||||
if (String(deviceStatus?.netType || "").toLowerCase() !== "wifi") return "设备当前未连接 WiFi,请先连接 WiFi 后再更新";
|
if (String(deviceStatus?.netType || "").toLowerCase() !== "wifi") return "设备当前未连接 WiFi,请先连接 WiFi 后再更新";
|
||||||
return "";
|
return "";
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user