简化固件更新状态展示
This commit is contained in:
@@ -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 {
|
.menu-item.disabled {
|
||||||
opacity: 0.45;
|
opacity: 0.45;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,17 +23,6 @@ interface MenuItem {
|
|||||||
disabled?: boolean
|
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() {
|
export default function Sleep() {
|
||||||
const systemBanner = useSystemBanner()
|
const systemBanner = useSystemBanner()
|
||||||
const [loading, setLoading] = useState(true)
|
const [loading, setLoading] = useState(true)
|
||||||
@@ -298,13 +287,6 @@ export default function Sleep() {
|
|||||||
const parentDisplayName = parentInfo.nickname?.trim() || '家长'
|
const parentDisplayName = parentInfo.nickname?.trim() || '家长'
|
||||||
const currentFirmwareLabel = firmwareStatus?.current_version || '--'
|
const currentFirmwareLabel = firmwareStatus?.current_version || '--'
|
||||||
const latestFirmwareLabel = firmwareStatus?.latest_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 canUpdateFirmware = Boolean(binding?.device_id && firmwareStatus?.can_update && !isLoadingFirmware && !isUpdatingFirmware)
|
||||||
const firmwareActionText = isLoadingFirmware ? '查询中' : isUpdatingFirmware ? '发送中' : '更新'
|
const firmwareActionText = isLoadingFirmware ? '查询中' : isUpdatingFirmware ? '发送中' : '更新'
|
||||||
const firmwareSubtitle = !binding?.device_id
|
const firmwareSubtitle = !binding?.device_id
|
||||||
@@ -416,18 +398,6 @@ export default function Sleep() {
|
|||||||
<Text className='system-update-label'>最新版本</Text>
|
<Text className='system-update-label'>最新版本</Text>
|
||||||
<Text className='system-update-value highlight'>{latestFirmwareLabel}</Text>
|
<Text className='system-update-value highlight'>{latestFirmwareLabel}</Text>
|
||||||
</View>
|
</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>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user