refactor&perf

- proxy config
- query export
- optimize station card request
This commit is contained in:
yangsy
2025-08-25 15:49:21 +08:00
parent dea621a7a2
commit d0658580a0
23 changed files with 263 additions and 109 deletions

View File

@@ -4,30 +4,31 @@ import DeviceParamsConfigModal from './device-params-config-modal.vue';
import OfflineDeviceDetailModal from './offline-device-detail-modal.vue';
import type { Station } from '@/apis/domains';
import { DeviceType } from '@/enums/device-type';
import type { StationAlarms } from '@/composables/query/use-line-alarms-query';
import type { StationDevices } from '@/composables/query/use-line-devices-query';
import { useStationDevicesQuery } from '@/composables/query/device/use-station-devices-query';
import { ControlOutlined } from '@vicons/antd';
import { Video as VideoIcon } from '@vicons/carbon';
import axios from 'axios';
import { NCard, NStatistic, NTag, NGrid, NGi, NButton, NIcon, useThemeVars, NSpace, NTooltip } from 'naive-ui';
import { toRefs, computed, ref } from 'vue';
import { useStationAlarmsQuery } from '@/composables/query/alarm/use-station-alarms-query';
interface Props {
station: Station;
stationDevices: StationDevices;
stationAlarms: StationAlarms;
}
const props = defineProps<Props>();
const { station, stationDevices, stationAlarms } = toRefs(props);
const { station } = toRefs(props);
const { code, name, online } = toRefs(station.value);
const { data: stationDevices } = useStationDevicesQuery(code.value);
const { data: stationAlarms } = useStationAlarmsQuery(station.value.code);
// 计算总离线设备数量
const offlineDeviceCount = computed(() => {
let count = 0;
Object.values(DeviceType).forEach((deviceType) => {
const offlineDeviceList = stationDevices.value[deviceType].filter((device) => device.deviceStatus === '20');
const offlineDeviceList = stationDevices.value?.[deviceType].filter((device) => device.deviceStatus === '20') ?? [];
count += offlineDeviceList.length;
});
return count;
@@ -35,14 +36,14 @@ const offlineDeviceCount = computed(() => {
const deviceCount = computed(() => {
let count = 0;
Object.values(DeviceType).forEach((deviceType) => {
count += stationDevices.value[deviceType].length;
count += stationDevices.value?.[deviceType].length ?? 0;
});
return count;
});
const devicAlarmCount = computed(() => {
let count = 0;
Object.values(DeviceType).forEach((deviceType) => {
count += stationAlarms.value[deviceType].length;
count += stationAlarms.value?.[deviceType].length ?? 0;
});
return count;
});