refactor(diag-info): make all fields optional
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
export interface NdmCameraDiagInfo {
|
export interface NdmCameraDiagInfo {
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
logTime: string;
|
logTime?: string;
|
||||||
info: string;
|
info?: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
export interface NdmDecoderDiagInfo {
|
export interface NdmDecoderDiagInfo {
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
logTime: string;
|
logTime?: string;
|
||||||
stCommonInfo: {
|
stCommonInfo?: {
|
||||||
设备ID: string;
|
设备ID?: string;
|
||||||
软件版本: string;
|
软件版本?: string;
|
||||||
生产厂商: string;
|
生产厂商?: string;
|
||||||
设备别名: string;
|
设备别名?: string;
|
||||||
设备型号: string;
|
设备型号?: string;
|
||||||
硬件版本: string;
|
硬件版本?: string;
|
||||||
内存使用率: string;
|
内存使用率?: string;
|
||||||
CPU使用率: string;
|
CPU使用率?: string;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,31 +1,31 @@
|
|||||||
export interface NdmNvrDiagInfo {
|
export interface NdmNvrDiagInfo {
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
logTime: string;
|
logTime?: string;
|
||||||
info: {
|
info?: {
|
||||||
diskHealth: number[];
|
diskHealth?: number[];
|
||||||
groupInfoList: {
|
groupInfoList?: {
|
||||||
freeSize: number;
|
freeSize?: number;
|
||||||
state: number;
|
state?: number;
|
||||||
stateValue: string;
|
stateValue?: string;
|
||||||
totalSize: number;
|
totalSize?: number;
|
||||||
}[];
|
}[];
|
||||||
};
|
};
|
||||||
stCommonInfo: {
|
stCommonInfo?: {
|
||||||
设备ID: string;
|
设备ID?: string;
|
||||||
软件版本: string;
|
软件版本?: string;
|
||||||
生产厂商: string;
|
生产厂商?: string;
|
||||||
设备别名: string;
|
设备别名?: string;
|
||||||
设备型号: string;
|
设备型号?: string;
|
||||||
硬件版本: string;
|
硬件版本?: string;
|
||||||
内存使用率: string;
|
内存使用率?: string;
|
||||||
CPU使用率: string;
|
CPU使用率?: string;
|
||||||
};
|
};
|
||||||
cdFanInfo: {
|
cdFanInfo?: {
|
||||||
索引号: string;
|
索引号?: string;
|
||||||
'风扇转速(rpm)': string;
|
'风扇转速(rpm)'?: string;
|
||||||
}[];
|
}[];
|
||||||
cdPowerSupplyInfo: {
|
cdPowerSupplyInfo?: {
|
||||||
索引号: string;
|
索引号?: string;
|
||||||
电源状态: string;
|
电源状态?: string;
|
||||||
}[];
|
}[];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export interface NdmSecurityBoxDiagInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface NdmSecurityBoxCircuit {
|
export interface NdmSecurityBoxCircuit {
|
||||||
current?: number;
|
current: number;
|
||||||
status?: number;
|
status: number;
|
||||||
voltage?: number;
|
voltage: number;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
export interface NdmServerDiagInfo {
|
export interface NdmServerDiagInfo {
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
commInfo: {
|
commInfo?: {
|
||||||
CPU使用率: string;
|
CPU使用率?: string;
|
||||||
内存使用率: string;
|
内存使用率?: string;
|
||||||
磁盘使用率: string;
|
磁盘使用率?: string;
|
||||||
系统运行时间: string;
|
系统运行时间?: string;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,10 +2,10 @@ export interface NdmSwitchDiagInfo {
|
|||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
cpuRatio?: string; // 因环境不同可能不存在
|
cpuRatio?: string; // 因环境不同可能不存在
|
||||||
memoryRatio?: string; // 因环境不同可能不存在
|
memoryRatio?: string; // 因环境不同可能不存在
|
||||||
logTime: string;
|
logTime?: string;
|
||||||
info: {
|
info?: {
|
||||||
overFlowPorts: string[];
|
overFlowPorts?: string[];
|
||||||
portInfoList: NdmSwitchPortInfo[];
|
portInfoList?: NdmSwitchPortInfo[];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { computed, ref, toRefs } from 'vue';
|
|||||||
import DeviceHeaderCard from './current-diag-card/device-header-card.vue';
|
import DeviceHeaderCard from './current-diag-card/device-header-card.vue';
|
||||||
import CameraHistoryDiagCard from './history-diag-card/camera-history-diag-card.vue';
|
import CameraHistoryDiagCard from './history-diag-card/camera-history-diag-card.vue';
|
||||||
import DeviceCommonCard from './current-diag-card/device-common-card.vue';
|
import DeviceCommonCard from './current-diag-card/device-common-card.vue';
|
||||||
|
import type { NdmCameraDiagInfo } from '@/apis/domains';
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
stationCode: string;
|
stationCode: string;
|
||||||
@@ -22,7 +23,7 @@ const lastDiagInfo = computed(() => {
|
|||||||
const result = destr<any>(ndmCamera.value.lastDiagInfo);
|
const result = destr<any>(ndmCamera.value.lastDiagInfo);
|
||||||
if (!result) return null;
|
if (!result) return null;
|
||||||
if (typeof result !== 'object') return null;
|
if (typeof result !== 'object') return null;
|
||||||
return result;
|
return result as NdmCameraDiagInfo;
|
||||||
});
|
});
|
||||||
|
|
||||||
const commonInfo = computed(() => {
|
const commonInfo = computed(() => {
|
||||||
|
|||||||
@@ -21,10 +21,10 @@ const debugModeStore = useDebugModeStore();
|
|||||||
const { stationCode, ndmDecoder } = toRefs(props);
|
const { stationCode, ndmDecoder } = toRefs(props);
|
||||||
|
|
||||||
const lastDiagInfo = computed(() => {
|
const lastDiagInfo = computed(() => {
|
||||||
const result = destr<NdmDecoderDiagInfo>(ndmDecoder.value.lastDiagInfo);
|
const result = destr<any>(ndmDecoder.value.lastDiagInfo);
|
||||||
if (!result) return null;
|
if (!result) return null;
|
||||||
if (typeof result !== 'object') return null;
|
if (typeof result !== 'object') return null;
|
||||||
return result;
|
return result as NdmDecoderDiagInfo;
|
||||||
});
|
});
|
||||||
|
|
||||||
const commonInfo = computed<Record<string, string> | undefined>(() => {
|
const commonInfo = computed<Record<string, string> | undefined>(() => {
|
||||||
@@ -37,8 +37,8 @@ const commonInfo = computed<Record<string, string> | undefined>(() => {
|
|||||||
return info;
|
return info;
|
||||||
});
|
});
|
||||||
|
|
||||||
const cpuUsage = computed(() => lastDiagInfo.value?.stCommonInfo.CPU使用率);
|
const cpuUsage = computed(() => lastDiagInfo.value?.stCommonInfo?.CPU使用率);
|
||||||
const memUsage = computed(() => lastDiagInfo.value?.stCommonInfo.内存使用率);
|
const memUsage = computed(() => lastDiagInfo.value?.stCommonInfo?.内存使用率);
|
||||||
|
|
||||||
const selectedTab = ref('设备状态');
|
const selectedTab = ref('设备状态');
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -24,14 +24,14 @@ const debugModeStore = useDebugModeStore();
|
|||||||
const { stationCode, ndmNvr } = toRefs(props);
|
const { stationCode, ndmNvr } = toRefs(props);
|
||||||
|
|
||||||
const lastDiagInfo = computed(() => {
|
const lastDiagInfo = computed(() => {
|
||||||
const result = destr<NdmNvrDiagInfo>(ndmNvr.value.lastDiagInfo);
|
const result = destr<any>(ndmNvr.value.lastDiagInfo);
|
||||||
if (!result) return null;
|
if (!result) return null;
|
||||||
if (typeof result !== 'object') return null;
|
if (typeof result !== 'object') return null;
|
||||||
return result;
|
return result as NdmNvrDiagInfo;
|
||||||
});
|
});
|
||||||
|
|
||||||
const cpuUsage = computed(() => lastDiagInfo.value?.stCommonInfo.CPU使用率);
|
const cpuUsage = computed(() => lastDiagInfo.value?.stCommonInfo?.['CPU使用率']);
|
||||||
const memUsage = computed(() => lastDiagInfo.value?.stCommonInfo.内存使用率);
|
const memUsage = computed(() => lastDiagInfo.value?.stCommonInfo?.['内存使用率']);
|
||||||
|
|
||||||
const commonInfo = computed<Record<string, string> | undefined>(() => {
|
const commonInfo = computed<Record<string, string> | undefined>(() => {
|
||||||
const info = lastDiagInfo.value?.stCommonInfo;
|
const info = lastDiagInfo.value?.stCommonInfo;
|
||||||
@@ -43,8 +43,8 @@ const commonInfo = computed<Record<string, string> | undefined>(() => {
|
|||||||
return info;
|
return info;
|
||||||
});
|
});
|
||||||
|
|
||||||
const diskHealth = computed(() => lastDiagInfo.value?.info.diskHealth);
|
const diskHealth = computed(() => lastDiagInfo.value?.info?.diskHealth);
|
||||||
const groupInfoList = computed(() => lastDiagInfo.value?.info.groupInfoList);
|
const groupInfoList = computed(() => lastDiagInfo.value?.info?.groupInfoList);
|
||||||
|
|
||||||
const isCluster = computed(() => {
|
const isCluster = computed(() => {
|
||||||
return isNvrCluster(ndmNvr.value);
|
return isNvrCluster(ndmNvr.value);
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ const lastDiagInfo = computed(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const commonInfo = computed<Record<string, string> | undefined>(() => {
|
const commonInfo = computed<Record<string, string> | undefined>(() => {
|
||||||
const info = lastDiagInfo.value?.stCommonInfo ?? {};
|
const info = lastDiagInfo.value?.stCommonInfo;
|
||||||
if (info) {
|
if (info) {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
const { CPU使用率, 内存使用率, ...rest } = info;
|
const { CPU使用率, 内存使用率, ...rest } = info;
|
||||||
|
|||||||
@@ -20,16 +20,16 @@ const debugModeStore = useDebugModeStore();
|
|||||||
const { stationCode, ndmServer } = toRefs(props);
|
const { stationCode, ndmServer } = toRefs(props);
|
||||||
|
|
||||||
const lastDiagInfo = computed(() => {
|
const lastDiagInfo = computed(() => {
|
||||||
const result = destr<NdmServerDiagInfo>(ndmServer.value.lastDiagInfo);
|
const result = destr<any>(ndmServer.value.lastDiagInfo);
|
||||||
if (!result) return null;
|
if (!result) return null;
|
||||||
if (typeof result !== 'object') return null;
|
if (typeof result !== 'object') return null;
|
||||||
return result;
|
return result as NdmServerDiagInfo;
|
||||||
});
|
});
|
||||||
|
|
||||||
const cpuUsage = computed(() => lastDiagInfo.value?.commInfo.CPU使用率);
|
const cpuUsage = computed(() => lastDiagInfo.value?.commInfo?.['CPU使用率']);
|
||||||
const memUsage = computed(() => lastDiagInfo.value?.commInfo.内存使用率);
|
const memUsage = computed(() => lastDiagInfo.value?.commInfo?.['内存使用率']);
|
||||||
const diskUsage = computed(() => lastDiagInfo.value?.commInfo.磁盘使用率);
|
const diskUsage = computed(() => lastDiagInfo.value?.commInfo?.['磁盘使用率']);
|
||||||
const runningTime = computed(() => lastDiagInfo.value?.commInfo.系统运行时间);
|
const runningTime = computed(() => lastDiagInfo.value?.commInfo?.['系统运行时间']);
|
||||||
|
|
||||||
const selectedTab = ref('设备状态');
|
const selectedTab = ref('设备状态');
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -21,16 +21,16 @@ const debugModeStore = useDebugModeStore();
|
|||||||
const { stationCode, ndmSwitch } = toRefs(props);
|
const { stationCode, ndmSwitch } = toRefs(props);
|
||||||
|
|
||||||
const lastDiagInfo = computed(() => {
|
const lastDiagInfo = computed(() => {
|
||||||
const result = destr<NdmSwitchDiagInfo>(ndmSwitch.value.lastDiagInfo);
|
const result = destr<any>(ndmSwitch.value.lastDiagInfo);
|
||||||
if (!result) return null;
|
if (!result) return null;
|
||||||
if (typeof result !== 'object') return null;
|
if (typeof result !== 'object') return null;
|
||||||
return result;
|
return result as NdmSwitchDiagInfo;
|
||||||
});
|
});
|
||||||
|
|
||||||
const cpuUsage = computed(() => lastDiagInfo.value?.cpuRatio);
|
const cpuUsage = computed(() => lastDiagInfo.value?.cpuRatio);
|
||||||
const memUsage = computed(() => lastDiagInfo.value?.memoryRatio);
|
const memUsage = computed(() => lastDiagInfo.value?.memoryRatio);
|
||||||
|
|
||||||
const portInfoList = computed(() => lastDiagInfo.value?.info.portInfoList ?? []);
|
const portInfoList = computed(() => lastDiagInfo.value?.info?.portInfoList ?? []);
|
||||||
|
|
||||||
const selectedTab = ref('设备状态');
|
const selectedTab = ref('设备状态');
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user