简化固件更新状态展示

This commit is contained in:
stu2not
2026-05-09 10:55:11 +08:00
parent 5fede9cda1
commit 6f9cc3e3e0
2 changed files with 0 additions and 60 deletions

View File

@@ -292,36 +292,6 @@
}
}
.system-update-progress {
display: flex;
align-items: center;
gap: 16px;
padding-top: 18px;
}
.system-update-progress-track {
flex: 1;
height: 12px;
border-radius: 999px;
background: #E5E7EB;
overflow: hidden;
}
.system-update-progress-bar {
height: 100%;
border-radius: 999px;
background: #16A34A;
}
.system-update-progress-text {
flex-shrink: 0;
width: 72px;
font-size: 24px;
font-weight: 600;
text-align: right;
color: #15803D;
}
.menu-item.disabled {
opacity: 0.45;
}

View File

@@ -23,17 +23,6 @@ interface MenuItem {
disabled?: boolean
}
function getFirmwareStatusLabel(status?: string | null): string {
const normalized = String(status || '').trim()
if (!normalized || normalized === 'idle') return '未更新'
if (normalized === 'sent') return '指令已发送'
if (normalized === 'accepted') return '设备已接收'
if (normalized === 'updating') return '更新中'
if (normalized === 'success' || normalized === 'completed') return '已更新'
if (normalized === 'failed') return '更新失败'
return normalized
}
export default function Sleep() {
const systemBanner = useSystemBanner()
const [loading, setLoading] = useState(true)
@@ -298,13 +287,6 @@ export default function Sleep() {
const parentDisplayName = parentInfo.nickname?.trim() || '家长'
const currentFirmwareLabel = firmwareStatus?.current_version || '--'
const latestFirmwareLabel = firmwareStatus?.latest_version || '--'
const firmwareStatusLabel = binding?.device_id
? isLoadingFirmware
? '查询中'
: getFirmwareStatusLabel(firmwareStatus?.update_status)
: '未绑定设备'
const firmwareProgress = Math.max(0, Math.min(100, Math.round(Number(firmwareStatus?.progress || 0))))
const showFirmwareProgress = ['sent', 'accepted', 'updating'].includes(String(firmwareStatus?.update_status || ''))
const canUpdateFirmware = Boolean(binding?.device_id && firmwareStatus?.can_update && !isLoadingFirmware && !isUpdatingFirmware)
const firmwareActionText = isLoadingFirmware ? '查询中' : isUpdatingFirmware ? '发送中' : '更新'
const firmwareSubtitle = !binding?.device_id
@@ -416,18 +398,6 @@ export default function Sleep() {
<Text className='system-update-label'></Text>
<Text className='system-update-value highlight'>{latestFirmwareLabel}</Text>
</View>
<View className='system-update-row'>
<Text className='system-update-label'></Text>
<Text className='system-update-value'>{firmwareStatusLabel}</Text>
</View>
{showFirmwareProgress && (
<View className='system-update-progress'>
<View className='system-update-progress-track'>
<View className='system-update-progress-bar' style={{ width: `${firmwareProgress}%` }}></View>
</View>
<Text className='system-update-progress-text'>{firmwareProgress}%</Text>
</View>
)}
</View>
</View>