perf: reduce ref update times
This commit is contained in:
@@ -62,7 +62,8 @@ export function useLineAlarmsQuery() {
|
|||||||
if (!lineAlarms.value[station.code]) {
|
if (!lineAlarms.value[station.code]) {
|
||||||
lineAlarms.value[station.code] = createEmptyStationAlarms();
|
lineAlarms.value[station.code] = createEmptyStationAlarms();
|
||||||
}
|
}
|
||||||
const stationAlarms = lineAlarms.value[station.code];
|
// const stationAlarms = lineAlarms.value[station.code];
|
||||||
|
const stationAlarms = createEmptyStationAlarms();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const now = dayjs();
|
const now = dayjs();
|
||||||
@@ -100,6 +101,8 @@ export function useLineAlarmsQuery() {
|
|||||||
const videoServerAlarms = alarmList.filter((device) => device.deviceType === DeviceType.VideoServer);
|
const videoServerAlarms = alarmList.filter((device) => device.deviceType === DeviceType.VideoServer);
|
||||||
stationAlarms[DeviceType.VideoServer] = videoServerAlarms;
|
stationAlarms[DeviceType.VideoServer] = videoServerAlarms;
|
||||||
stationAlarms.unclassified = alarmList;
|
stationAlarms.unclassified = alarmList;
|
||||||
|
|
||||||
|
lineAlarms.value[station.code] = stationAlarms;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error instanceof CanceledError) return lineAlarms.value;
|
if (error instanceof CanceledError) return lineAlarms.value;
|
||||||
console.error(`获取车站 ${station.name} 设备告警数据失败:`, error);
|
console.error(`获取车站 ${station.name} 设备告警数据失败:`, error);
|
||||||
|
|||||||
@@ -68,7 +68,8 @@ export function useLineDevicesQuery() {
|
|||||||
if (!lineDevices.value[station.code]) {
|
if (!lineDevices.value[station.code]) {
|
||||||
lineDevices.value[station.code] = createEmptyStationDevices();
|
lineDevices.value[station.code] = createEmptyStationDevices();
|
||||||
}
|
}
|
||||||
const stationDevices = lineDevices.value[station.code];
|
// const stationDevices = lineDevices.value[station.code];
|
||||||
|
const stationDevices = createEmptyStationDevices();
|
||||||
|
|
||||||
await Promise.allSettled([
|
await Promise.allSettled([
|
||||||
postNdmCameraPage(station.code, pageQuery, signal)
|
postNdmCameraPage(station.code, pageQuery, signal)
|
||||||
@@ -144,6 +145,8 @@ export function useLineDevicesQuery() {
|
|||||||
stationDevices[DeviceType.VideoServer] = [];
|
stationDevices[DeviceType.VideoServer] = [];
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
lineDevices.value[station.code] = stationDevices;
|
||||||
}
|
}
|
||||||
|
|
||||||
// console.timeEnd('useLineDevicesQuery');
|
// console.timeEnd('useLineDevicesQuery');
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ useLineAlarmsQuery();
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<NGrid :cols="8" :x-gap="6" :y-gap="6" style="padding: 8px">
|
<NGrid :cols="8" :x-gap="6" :y-gap="6" style="padding: 8px">
|
||||||
<NGi v-for="station in stationList" :key="station.name">
|
<NGi v-for="station in stationList" :key="station.code">
|
||||||
<StationCard :station="station" :station-devices="lineDevices[station.code]" :station-alarms="lineAlarms[station.code]" />
|
<StationCard :station="station" :station-devices="lineDevices[station.code]" :station-alarms="lineAlarms[station.code]" />
|
||||||
</NGi>
|
</NGi>
|
||||||
</NGrid>
|
</NGrid>
|
||||||
|
|||||||
Reference in New Issue
Block a user