From 55f1c8a4316d1912eb4349b2145d656230bff69c Mon Sep 17 00:00:00 2001 From: yangsy Date: Mon, 10 Nov 2025 20:28:45 +0800 Subject: [PATCH] fix(device-tree): extract renderStationNodeSuffix --- src/components/device-page/device-tree.vue | 25 +++++++++++----------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/components/device-page/device-tree.vue b/src/components/device-page/device-tree.vue index 8a3f260..e66e63b 100644 --- a/src/components/device-page/device-tree.vue +++ b/src/components/device-page/device-tree.vue @@ -101,7 +101,7 @@ const lineDeviceTreeData = computed>(() => { label: stationName, key: stationCode, prefix: () => renderStationNodePrefix(station), - suffix: () => `(${onlineDevices?.length ?? 0}/${offlineDevices?.length ?? 0}/${devices?.length ?? 0})`, + suffix: () => renderStationNodeSuffix(onlineDevices?.length ?? 0, offlineDevices?.length ?? 0, devices?.length ?? 0), children: nvrClusters.map((nvrCluster) => { return { label: `${nvrCluster.name}`, @@ -130,17 +130,7 @@ const lineDeviceTreeData = computed>(() => { label: stationName, key: stationCode, prefix: () => renderStationNodePrefix(station), - suffix: () => { - return h('span', null, [ - '(', - h('span', { style: { color: themeVars.value.successColor } }, `${onlineDevices?.length ?? 0}`), - '/', - h('span', { style: { color: themeVars.value.errorColor } }, `${offlineDevices?.length ?? 0}`), - '/', - `${devices?.length ?? 0}`, - ')', - ]); - }, + suffix: () => renderStationNodeSuffix(onlineDevices?.length ?? 0, offlineDevices?.length ?? 0, devices?.length ?? 0), children: lineDevices.value[stationCode]?.[paneName]?.map((dev) => { const device = dev as NdmDeviceResultVO; @@ -165,6 +155,17 @@ const renderStationNodePrefix = (station: Station) => { const tagText = online ? '在线' : '离线'; return h(NTag, { type: tagType, size: 'tiny' }, () => tagText); }; +const renderStationNodeSuffix = (onlineCount: number, offlineCount: number, count: number) => { + return h('span', null, [ + '(', + h('span', { style: { color: themeVars.value.successColor } }, `${onlineCount}`), + '/', + h('span', { style: { color: themeVars.value.errorColor } }, `${offlineCount}`), + '/', + `${count}`, + ')', + ]); +}; const renderDeviceNodePrefix = (device: NdmDeviceResultVO, stationCode: string) => { const renderDeviceStatusTag = (device: NdmDeviceResultVO) => { const { deviceStatus } = device;