From 65e6d94f0005204bb66110e15336abe5cb1ba9b8 Mon Sep 17 00:00:00 2001 From: yahaozhang Date: Tue, 16 Sep 2025 02:05:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=AE=BE=E5=A4=87=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E9=A1=B5=E9=9D=A2=EF=BC=8C=E8=B0=83=E6=95=B4=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E4=BF=A1=E6=81=AF=E5=B1=95=E7=A4=BA=EF=BC=8C=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E8=AE=BE=E5=A4=87=E5=88=86=E7=B1=BB=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=EF=BC=8C=E6=8F=90=E5=8D=87=E7=94=A8=E6=88=B7=E4=BD=93=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/devices/DeviceStatus.vue | 50 ++++++++++++++++-------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/src/views/devices/DeviceStatus.vue b/src/views/devices/DeviceStatus.vue index 5685564..a6d947d 100644 --- a/src/views/devices/DeviceStatus.vue +++ b/src/views/devices/DeviceStatus.vue @@ -15,22 +15,20 @@
- - 可用: {{ stats.availableCount }} - {{ availableDevices.join(', ') }} + + + +
- - - - - - - + + + + @@ -52,15 +50,17 @@ const loading = ref(false) const autoRefresh = ref(true) const timer = ref(null) -const stats = reactive({ totalDevices: 0, availableCount: 0 }) -const availableDevices = ref([]) -const devicesMap = ref({}) +const stats = reactive({ totalDevices: 0, runningCount: 0, usingCount: 0, idleCooldownCount: 0, idleFreeCount: 0 }) +const categoryToDevices = ref({}) -const tableData = computed(() => { - const map = devicesMap.value || {} - return Object.values(map).sort((a, b) => { - if (a.series === b.series) return a.index - b.index - return String(a.series).localeCompare(String(b.series)) +const categoryOrder = ['RUNNING', 'USING', 'IDLE_COOLDOWN', 'IDLE_FREE'] +const categoryLabelMap = { RUNNING: '已占用', USING: '使用中', IDLE_COOLDOWN: '冷却空闲', IDLE_FREE: '空闲' } +const categoryRows = computed(() => { + const map = categoryToDevices.value || {} + return categoryOrder.map(key => { + const devices = Array.isArray(map[key]) ? map[key] : [] + const preview = devices.join(', ') + return { key, label: categoryLabelMap[key] || key, count: devices.length, devices, preview } }) }) @@ -69,10 +69,12 @@ async function fetchData() { try { loading.value = true const data = await getAllDeviceStatus() - devicesMap.value = data?.devices || {} - availableDevices.value = data?.availableDevices || [] - stats.totalDevices = data?.totalDevices || Object.keys(devicesMap.value).length - stats.availableCount = data?.availableCount || availableDevices.value.length + categoryToDevices.value = data?.categoryToDevices || {} + stats.totalDevices = data?.totalDevices ?? 0 + stats.runningCount = data?.runningCount ?? (categoryToDevices.value['RUNNING']?.length || 0) + stats.usingCount = data?.usingCount ?? (categoryToDevices.value['USING']?.length || 0) + stats.idleCooldownCount = data?.idleCooldownCount ?? (categoryToDevices.value['IDLE_COOLDOWN']?.length || 0) + stats.idleFreeCount = data?.idleFreeCount ?? (categoryToDevices.value['IDLE_FREE']?.length || 0) } finally { loading.value = false } @@ -113,7 +115,7 @@ onUnmounted(() => { .actions { display: flex; gap: 12px; align-items: center; } .stats { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; } .inline-tag { height: 24px; align-items: center; } -.table-card { } +.devices-list { white-space: normal; word-break: break-all; line-height: 1.6; } @media (max-width: 768px) { .title { font-size: 20px; }