|
|
@@ -117,6 +117,7 @@
|
|
|
const baseUrl = VUE_APP_URL.baseUrl;
|
|
|
const actions = getActions();
|
|
|
let timer: NodeJS.Timeout | null = null;
|
|
|
+ let clockTimer: NodeJS.Timeout | null = null; // [perf-base-v1] 1s 时钟句柄,与数据轮询 timer 分离
|
|
|
let fanLocalList = reactive<any[]>([]); //局部风机数据
|
|
|
let mainList = ref<any[]>([]); //主通风机数据
|
|
|
let centerList = reactive<any[]>([]); //中间区域数据
|
|
|
@@ -242,7 +243,9 @@
|
|
|
|
|
|
//获取当前时间年月日时分秒
|
|
|
function getNowTime() {
|
|
|
- setInterval(() => {
|
|
|
+ // [perf-base-v1] 句柄赋值给 clockTimer,修复裸 setInterval 无法清理的泄漏
|
|
|
+ clockTimer = Number(
|
|
|
+ setInterval(() => {
|
|
|
nowTimeYear.value = dayjs().format('YYYY/MM/DD');
|
|
|
let week = dayjs(new Date().getTime()).day();
|
|
|
switch (week) {
|
|
|
@@ -279,7 +282,8 @@
|
|
|
seconds = `0${seconds}`;
|
|
|
}
|
|
|
nowTime.value = `${hours}:${minutes}:${seconds}`;
|
|
|
- }, 1000);
|
|
|
+ }, 1000)
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
function goModalDetail() {
|
|
|
@@ -322,6 +326,8 @@
|
|
|
onBeforeUnmount(() => {
|
|
|
clearInterval(timer);
|
|
|
timer = null;
|
|
|
+ clearInterval(clockTimer); // [perf-base-v1] 清理 1s 时钟
|
|
|
+ clockTimer = null;
|
|
|
});
|
|
|
onUnmounted(() => {
|
|
|
pageType.value = '';
|