diff --git a/src/components/device-page/device-tree.vue b/src/components/device-page/device-tree.vue index 0ac3fa3..91d063c 100644 --- a/src/components/device-page/device-tree.vue +++ b/src/components/device-page/device-tree.vue @@ -14,9 +14,27 @@ import type { NdmDeviceResultVO, NdmNvrResultVO } from '@/apis/models'; import type { LineDevices } from '@/composables/query'; import { DeviceType, DeviceTypeName, getDeviceTypeVal, type DeviceTypeKey, type DeviceTypeVal } from '@/enums/device-type'; import { destr } from 'destr'; -import { NButton, NFlex, NInput, NRadio, NRadioGroup, NTab, NTabs, NTag, NTree, type TagProps, type TreeInst, type TreeOption, type TreeOverrideNodeClickBehavior, type TreeProps } from 'naive-ui'; +import { + NButton, + NFlex, + NInput, + NRadio, + NRadioGroup, + NTab, + NTabs, + NTag, + NTree, + useThemeVars, + type TagProps, + type TreeInst, + type TreeOption, + type TreeOverrideNodeClickBehavior, + type TreeProps, +} from 'naive-ui'; import { computed, h, ref, toRefs, useTemplateRef, watch, type CSSProperties } from 'vue'; +const themeVars = useThemeVars(); + const props = defineProps<{ stationList: Station[]; lineDevices: LineDevices; @@ -140,9 +158,11 @@ const renderStationNodePrefix = (station: Station) => { const renderDeviceNodePrefix = (device: NdmDeviceResultVO, stationCode: string) => { const renderDeviceStatusTag = (device: NdmDeviceResultVO) => { const { deviceStatus } = device; - const tagType: TagProps['type'] = deviceStatus === '10' ? 'success' : deviceStatus === '20' ? 'error' : 'warning'; - const tagText = device.deviceStatus === '10' ? '在线' : device.deviceStatus === '20' ? '离线' : '未知'; - return h(NTag, { type: tagType, size: 'tiny' }, () => tagText); + // const tagType: TagProps['type'] = deviceStatus === '10' ? 'success' : deviceStatus === '20' ? 'error' : 'warning'; + // const tagText = device.deviceStatus === '10' ? '在线' : device.deviceStatus === '20' ? '离线' : '未知'; + // return h(NTag, { type: tagType, bordered: false, size: 'tiny' }, { default: () => '◉' }); // ⁕∘∙⋅﹒▪● + const color = deviceStatus === '10' ? themeVars.value.successColor : deviceStatus === '20' ? themeVars.value.errorColor : themeVars.value.warningColor; + return h('div', { style: { color } }, { default: () => '◉' }); // ⁕∘∙⋅﹒▪● }; const renderViewDeviceButton = (device: NdmDeviceResultVO, stationCode: string) => { return h(