diff --git a/src/stores/transferData.ts b/src/stores/transferData.ts index 751e44c..3b2f15d 100644 --- a/src/stores/transferData.ts +++ b/src/stores/transferData.ts @@ -32,6 +32,20 @@ export const useTransferDataStore = defineStore('transfer', () => { }, 1000); } + function formatSizeFromKB(num: number): string { + const sizeKB = Number(num) + const units = ['KB', 'MB', 'GB', 'TB', 'PB'] + let size = sizeKB + let unitIndex = 0 + + while (size >= 1024 && unitIndex < units.length - 1) { + size = size / 1024 + unitIndex++ + } + + return `${size.toFixed(2)} ${units[unitIndex]}` + } + function getSubDevicesCb(msg: SubMsgData) { const { feedback } = msg const sn = feedback[1] @@ -40,12 +54,13 @@ export const useTransferDataStore = defineStore('transfer', () => { hasDevice.lastUpdated = Date.now() hasDevice.status = '在线' } else { + const num = feedback[4] || 0 const device: IOnlineDevice = { clientIp: feedback[0], sn: sn, site_id: feedback[2], versions: feedback[3] ?? '--', - footprint: feedback[4] ?? '--', + footprint: formatSizeFromKB(Number(num)), lastUpdated: Date.now(), status: '在线', // 初始状态为在线 isChecked: false, diff --git a/src/views/firmwareUpload/index.vue b/src/views/firmwareUpload/index.vue index 9da863b..0a8af96 100644 --- a/src/views/firmwareUpload/index.vue +++ b/src/views/firmwareUpload/index.vue @@ -111,6 +111,8 @@ async function onSave() { // } catch (error) { // message.error('上传失败') // } + + await getPath() abortController.value = undefined loading.value = false @@ -164,12 +166,16 @@ const firmwarePath = ref() const title = computed(() => { return `固件上传(${firmwarePath.value ? `当前固件:${firmwarePath.value}` : '当前固件: 未上传'})` }) -onMounted(async () => { + +const getPath = async () => { const res = await getFirmwarePath() if (res.code === 200 || res.code === 0) { - firmwarePath.value = res.data.path.split('/').at(-1) + firmwarePath.value = res.data?.path?.split('/').at(-1) } +} +onMounted(() => { + getPath() }) diff --git a/src/views/stationData/components/PointGroupTree.vue b/src/views/stationData/components/PointGroupTree.vue index 0af8e0a..2d0b65b 100644 --- a/src/views/stationData/components/PointGroupTree.vue +++ b/src/views/stationData/components/PointGroupTree.vue @@ -13,7 +13,7 @@ -
+