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