实时报警,细节修改

This commit is contained in:
fengerli
2025-09-29 11:27:36 +08:00
parent a3be91c6ac
commit 848f471ef1

View File

@ -29,7 +29,7 @@
</template> </template>
<script setup> <script setup>
import { getRealtimeAlarm } from '@/api/homeIndex/index'; import { getRealtimeAlarm } from '@/api/homeIndex/index';
let alarmTimer = null;
// 模拟报警数据 // 模拟报警数据
const alarmData = ref([ const alarmData = ref([
]); ]);
@ -38,17 +38,32 @@ const getRealtimeAlarmData = () => {
alarmData.value = res.data; alarmData.value = res.data;
}); });
} }
const startAlarmTimer = () => {
if (alarmTimer) {
clearInterval(alarmTimer);
}
getRealtimeAlarmData();
alarmTimer = setInterval(getRealtimeAlarmData, 40 * 1000);
};
const clearAlarmTimer = () => {
if (alarmTimer) {
clearInterval(alarmTimer);
alarmTimer = null;
}
};
const tableBody = ref(null); const tableBody = ref(null);
onMounted(() => { onMounted(() => {
getRealtimeAlarmData() startAlarmTimer();
// 启动滚动动画 // 启动滚动动画
if (tableBody.value) { if (tableBody.value) {
tableBody.value.style.animationName = 'scroll'; tableBody.value.style.animationName = 'scroll';
tableBody.value.style.animationIterationCount = 'infinite'; tableBody.value.style.animationIterationCount = 'infinite';
} }
}); });
onUnmounted(() => {
clearAlarmTimer(); // 组件销毁时清除定时器
})
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.alarm-table-container { .alarm-table-container {