From ffdc8b0d4b80eff2f9b5d247a98ea76f0305cdfb Mon Sep 17 00:00:00 2001 From: yangsy Date: Tue, 25 Nov 2025 17:38:16 +0800 Subject: [PATCH] feat(alarm-page): realtime refresh --- src/pages/alarm-page.vue | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/pages/alarm-page.vue b/src/pages/alarm-page.vue index 9f90ec9..f3d6227 100644 --- a/src/pages/alarm-page.vue +++ b/src/pages/alarm-page.vue @@ -5,7 +5,9 @@ import { AlarmType, DeviceType, DeviceTypeCode, DeviceTypeName, FaultLevel, tryG import { useAlarmStore, useStationStore } from '@/stores'; import { downloadByData } from '@/utils'; import { useMutation } from '@tanstack/vue-query'; +import { watchDebounced } from '@vueuse/core'; import dayjs from 'dayjs'; +import { debounce } from 'es-toolkit'; import { NForm, NInput, @@ -25,6 +27,8 @@ import { type DataTableColumns, type DataTableRowData, type PaginationProps, + NFlex, + NSwitch, } from 'naive-ui'; import { storeToRefs } from 'pinia'; import { ref, reactive, onBeforeMount, h, computed, watch } from 'vue'; @@ -41,6 +45,20 @@ watch(unreadCountCleared, (newValue, oldValue) => { } }); +const realtimeRefresh = ref(false); + +watchDebounced( + [unreadAlarmCount, realtimeRefresh], + ([unreadCount, refresh]) => { + if (unreadCount > 0 && refresh) { + onClickReset(); + } + }, + { + debounce: 500, + }, +); + const stationStore = useStationStore(); const { stationList } = storeToRefs(stationStore); @@ -280,6 +298,7 @@ const onClickReset = () => { tablePagination.itemCount = 0; getTableData(); }; +const onClickResetDebounced = debounce(onClickReset, 500); const onClickQuery = () => { if (searchFieldsChanged.value) { tablePagination.page = 1; @@ -428,9 +447,11 @@ onBeforeMount(() => getTableData());
设备告警列表
- + +
实时刷新
+ 导出 -
+