forked from dyf/dyf-vue-ui
实时报警,细节修改
This commit is contained in:
@ -29,7 +29,7 @@
|
||||
</template>
|
||||
<script setup>
|
||||
import { getRealtimeAlarm } from '@/api/homeIndex/index';
|
||||
|
||||
let alarmTimer = null;
|
||||
// 模拟报警数据
|
||||
const alarmData = ref([
|
||||
]);
|
||||
@ -38,17 +38,32 @@ const getRealtimeAlarmData = () => {
|
||||
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);
|
||||
|
||||
onMounted(() => {
|
||||
getRealtimeAlarmData()
|
||||
startAlarmTimer();
|
||||
// 启动滚动动画
|
||||
if (tableBody.value) {
|
||||
tableBody.value.style.animationName = 'scroll';
|
||||
tableBody.value.style.animationIterationCount = 'infinite';
|
||||
}
|
||||
});
|
||||
onUnmounted(() => {
|
||||
clearAlarmTimer(); // 组件销毁时清除定时器
|
||||
})
|
||||
</script>
|
||||
<style scoped lang="scss">
|
||||
.alarm-table-container {
|
||||
|
||||
Reference in New Issue
Block a user