refactor(ndm-security-box-diag-info): make all fields optional
This commit is contained in:
@@ -1,23 +1,24 @@
|
||||
export interface NdmSecurityBoxDiagInfo {
|
||||
[key: string]: any;
|
||||
info: [
|
||||
info?: [
|
||||
{
|
||||
addrCode: number;
|
||||
circuits: NdmSecurityBoxCircuit[];
|
||||
fanSpeeds: number[];
|
||||
humidity: number;
|
||||
switches: number[];
|
||||
temperature: number;
|
||||
addrCode?: number;
|
||||
circuits?: NdmSecurityBoxCircuit[];
|
||||
fanSpeeds?: number[];
|
||||
humidity?: number;
|
||||
switches?: number[];
|
||||
temperature?: number;
|
||||
},
|
||||
];
|
||||
stCommonInfo: {
|
||||
内存使用率: string;
|
||||
CPU使用率: string;
|
||||
stCommonInfo?: {
|
||||
[key: string]: any;
|
||||
内存使用率?: string;
|
||||
CPU使用率?: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface NdmSecurityBoxCircuit {
|
||||
current: number;
|
||||
status: number;
|
||||
voltage: number;
|
||||
current?: number;
|
||||
status?: number;
|
||||
voltage?: number;
|
||||
}
|
||||
|
||||
@@ -23,14 +23,14 @@ const debugModeStore = useDebugModeStore();
|
||||
const { stationCode, ndmSecurityBox } = toRefs(props);
|
||||
|
||||
const lastDiagInfo = computed(() => {
|
||||
const result = destr<NdmSecurityBoxDiagInfo>(ndmSecurityBox.value.lastDiagInfo);
|
||||
const result = destr<any>(ndmSecurityBox.value.lastDiagInfo);
|
||||
if (!result) return null;
|
||||
if (typeof result !== 'object') return null;
|
||||
return result;
|
||||
return result as NdmSecurityBoxDiagInfo;
|
||||
});
|
||||
|
||||
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;
|
||||
@@ -39,15 +39,15 @@ 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 fanSpeeds = computed(() => lastDiagInfo.value?.info.at(0)?.fanSpeeds);
|
||||
const temperature = computed(() => lastDiagInfo.value?.info.at(0)?.temperature);
|
||||
const humidity = computed(() => lastDiagInfo.value?.info.at(0)?.humidity);
|
||||
const switches = computed(() => lastDiagInfo.value?.info.at(0)?.switches);
|
||||
const fanSpeeds = computed(() => lastDiagInfo.value?.info?.at(0)?.fanSpeeds);
|
||||
const temperature = computed(() => lastDiagInfo.value?.info?.at(0)?.temperature);
|
||||
const humidity = computed(() => lastDiagInfo.value?.info?.at(0)?.humidity);
|
||||
const switches = computed(() => lastDiagInfo.value?.info?.at(0)?.switches);
|
||||
|
||||
const circuits = computed(() => lastDiagInfo.value?.info.at(0)?.circuits);
|
||||
const circuits = computed(() => lastDiagInfo.value?.info?.at(0)?.circuits);
|
||||
|
||||
const selectedTab = ref('设备状态');
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user