diff --git a/src/App.vue b/src/App.vue
index a836b58..9007e9e 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -77,7 +77,7 @@ page {
top: 0;
left: 0;
right: 0;
- height: 40px;
+ height: 50px;
z-index: 1000;
background-color: #ffffff;
padding: 15rpx 20rpx;
@@ -111,7 +111,7 @@ page {
.tabbar-content {
flex: 1;
// padding: 0 20rpx; /* 增加底部padding为tabbar留出空间 */
- margin-top: 100rpx; /* 为固定头部留出空间,增加距离 */
+ margin-top: 130rpx; /* 为固定头部留出空间,增加距离 */
overflow-y: auto;
display: flex;
flex-direction: column;
@@ -121,6 +121,11 @@ page {
// #endif
}
+.header-title {
+ font-weight: normal;
+ color: #333;
+}
+
/* 非tabbar页面内容区域 */
.non-tabbar-content {
flex: 1;
diff --git a/src/pages/environment/index.vue b/src/pages/environment/index.vue
index 17e1a81..4132873 100644
--- a/src/pages/environment/index.vue
+++ b/src/pages/environment/index.vue
@@ -319,6 +319,12 @@ export default {
// 空调控制相关
acControlLoading: false, // 空调控制按钮加载状态
// 数据获取定时器
+ // 上一次数据记录,用于检测变动
+ previousData: {
+ temperature: null,
+ humidity: null,
+ pm25: null
+ },
dataFetchInterval: null
}
},
@@ -689,78 +695,114 @@ export default {
// 检查从接口获取的数据的报警条件
checkAlertsFromApiData(apiData) {
- const currentTime = this.formatDateTime(new Date())
const { temperature, humidity, pm25 } = apiData
+ const currentTime = this.formatDateTime(new Date())
- // 1. 温度报警:使用环境控制设置的区间
- if (temperature !== undefined && temperature !== 0 && this.temperatureRange.min !== 0 && this.temperatureRange.max !== 0) {
- if (temperature < this.temperatureRange.min || temperature > this.temperatureRange.max) {
- const alert = {
- content: `当前温度${temperature}°C超出控制范围${this.temperatureRange.min}°C-${this.temperatureRange.max}°C`,
- category: "温度超出范围",
- alertTime: currentTime,
- level: "中危",
- action: "检查温度",
- actionTime: currentTime,
- deviceId: "WSD_001"
- }
- this.logAlert(alert)
- }
- }
+ // 检查各个数据是否有变动,分别处理对应的报警逻辑
+ const temperatureChanged = this.previousData.temperature !== temperature;
+ const humidityChanged = this.previousData.humidity !== humidity;
+ const pm25Changed = this.previousData.pm25 !== pm25;
- // 2. 湿度报警:使用环境控制设置的区间
- if (humidity !== undefined && humidity !== 0 && this.humidityRange.min !== 0 && this.humidityRange.max !== 0) {
- if (humidity < this.humidityRange.min || humidity > this.humidityRange.max) {
- const alert = {
- content: `当前湿度${humidity}%超出控制范围${this.humidityRange.min}%-${this.humidityRange.max}%`,
- category: "湿度超出范围",
- alertTime: currentTime,
- level: "中危",
- action: "检查湿度",
- actionTime: currentTime,
- deviceId: "WSD_001"
- }
- this.logAlert(alert)
- }
- }
-
- // 3. 温度偏差报警:|温湿度计温度 - 空调设定温度| / 空调设定温度 > 30%
- if (temperature !== undefined && temperature !== 0 && this.targetTemperature !== 0) {
- const temperatureDiff = Math.abs(temperature - this.targetTemperature)
- const deviationPercent = (temperatureDiff / this.targetTemperature) * 100
+ // 只有温度有变化时才检查温度相关报警
+ if (temperatureChanged) {
+ console.log('📊 检测到温度数据变化,检查温度相关报警')
- if (deviationPercent > 30) {
- const alert = {
- content: `当前温度${temperature}°C与设定${this.targetTemperature}°C偏差${deviationPercent.toFixed(1)}%`,
- category: "温度偏差过大",
- alertTime: currentTime,
- level: "中危",
- action: "调整空调设定温度",
- actionTime: currentTime,
- deviceId: "AC_001"
+ // 1. 温度报警:使用环境控制设置的区间
+ if (temperature !== undefined && temperature !== 0 && this.temperatureRange.min !== 0 && this.temperatureRange.max !== 0) {
+ if (temperature < this.temperatureRange.min || temperature > this.temperatureRange.max) {
+ const alert = {
+ content: `当前温度${temperature}°C超出控制范围${this.temperatureRange.min}°C-${this.temperatureRange.max}°C`,
+ category: "温度超出范围",
+ alertTime: currentTime,
+ level: "中危",
+ action: "检查温度",
+ actionTime: currentTime,
+ deviceId: "WSD_001"
+ }
+ this.logAlert(alert)
}
- this.logAlert(alert)
}
+
+ // 3. 温度偏差报警:|温湿度计温度 - 空调设定温度| / 空调设定温度 > 30%
+ if (temperature !== undefined && temperature !== 0 && this.targetTemperature !== 0) {
+ const temperatureDiff = Math.abs(temperature - this.targetTemperature)
+ const deviationPercent = (temperatureDiff / this.targetTemperature) * 100
+
+ if (deviationPercent > 30) {
+ const alert = {
+ content: `当前温度${temperature}°C与设定${this.targetTemperature}°C偏差${deviationPercent.toFixed(1)}%`,
+ category: "温度偏差过大",
+ alertTime: currentTime,
+ level: "中危",
+ action: "调整空调设定温度",
+ actionTime: currentTime,
+ deviceId: "AC_001"
+ }
+ this.logAlert(alert)
+ }
+ }
+ } else {
+ console.log('📊 温度数据无变化,跳过温度报警检查')
}
- // 4. 湿度偏差报警:|温湿度计湿度 - 空调设定湿度| / 空调设定湿度 > 30%
- if (humidity !== undefined && humidity !== 0 && this.targetHumidity !== 0) {
- const humidityDiff = Math.abs(humidity - this.targetHumidity)
- const deviationPercent = (humidityDiff / this.targetHumidity) * 100
+ // 只有湿度有变化时才检查湿度相关报警
+ if (humidityChanged) {
+ console.log('📊 检测到湿度数据变化,检查湿度相关报警')
- if (deviationPercent > 30) {
- const alert = {
- content: `当前湿度${humidity}%与设定${this.targetHumidity}%偏差${deviationPercent.toFixed(1)}%`,
- category: "湿度偏差过大",
- alertTime: currentTime,
- level: "中危",
- action: "调整空调设定湿度",
- actionTime: currentTime,
- deviceId: "AC_001"
+ // 2. 湿度报警:使用环境控制设置的区间
+ if (humidity !== undefined && humidity !== 0 && this.humidityRange.min !== 0 && this.humidityRange.max !== 0) {
+ if (humidity < this.humidityRange.min || humidity > this.humidityRange.max) {
+ const alert = {
+ content: `当前湿度${humidity}%超出控制范围${this.humidityRange.min}%-${this.humidityRange.max}%`,
+ category: "湿度超出范围",
+ alertTime: currentTime,
+ level: "中危",
+ action: "检查湿度",
+ actionTime: currentTime,
+ deviceId: "WSD_001"
+ }
+ this.logAlert(alert)
}
- this.logAlert(alert)
}
+
+ // 4. 湿度偏差报警:|温湿度计湿度 - 空调设定湿度| / 空调设定湿度 > 30%
+ if (humidity !== undefined && humidity !== 0 && this.targetHumidity !== 0) {
+ const humidityDiff = Math.abs(humidity - this.targetHumidity)
+ const deviationPercent = (humidityDiff / this.targetHumidity) * 100
+
+ if (deviationPercent > 30) {
+ const alert = {
+ content: `当前湿度${humidity}%与设定${this.targetHumidity}%偏差${deviationPercent.toFixed(1)}%`,
+ category: "湿度偏差过大",
+ alertTime: currentTime,
+ level: "中危",
+ action: "调整空调设定湿度",
+ actionTime: currentTime,
+ deviceId: "AC_001"
+ }
+ this.logAlert(alert)
+ }
+ }
+ } else {
+ console.log('📊 湿度数据无变化,跳过湿度报警检查')
}
+
+ // PM25相关报警检查(如果有的话)
+ if (pm25Changed) {
+ console.log('📊 检测到PM25数据变化')
+ // 这里可以添加PM25相关的报警逻辑
+ }
+
+ // 更新上一次的数据
+ this.updatePreviousData(apiData)
+ },
+
+ // 更新上一次的数据
+ updatePreviousData(apiData) {
+ const { temperature, humidity, pm25 } = apiData
+ this.previousData.temperature = temperature
+ this.previousData.humidity = humidity
+ this.previousData.pm25 = pm25
},
// 记录报警到控制台并调用创建告警接口
@@ -1369,17 +1411,10 @@ export default {
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.06);
}
-.header-title {
- font-size: 32rpx;
- font-weight: 600;
- color: #2c3e50;
- text-align: center;
-}
-
/* 内容区域 */
.tabbar-content {
padding: 20rpx 20rpx 120rpx; /* 增加底部padding为tabbar留出空间 */
- margin-top: 100rpx; /* 为固定头部留出空间,增加距离 */
+ margin-top: 150rpx; /* 为固定头部留出空间,增加距离 */
min-height: calc(100vh - 200rpx); /* 调整最小高度计算 */
}
diff --git a/src/pages/log/index.vue b/src/pages/log/index.vue
index 36cdd2d..b1963da 100644
--- a/src/pages/log/index.vue
+++ b/src/pages/log/index.vue
@@ -235,13 +235,6 @@ export default {
overflow: hidden;
}
-.header-title {
- font-size: 32rpx;
- font-weight: bold;
- color: #333;
- text-align: center;
-}
-
/* 查询区域样式 */
.query-section {
background: white;
diff --git a/src/pages/parameter/index.vue b/src/pages/parameter/index.vue
index 461a7a2..adf010c 100644
--- a/src/pages/parameter/index.vue
+++ b/src/pages/parameter/index.vue
@@ -1081,10 +1081,10 @@ export default {
}
.header-title {
- font-size: 32rpx;
- font-weight: bold;
- color: #333;
- text-align: center;
+ // font-size: 32rpx;
+ // font-weight: bold;
+ // color: #333;
+ // text-align: center;
}
.tabbar-content {
diff --git a/src/pages/visual/index.vue b/src/pages/visual/index.vue
index a677763..e6d74b2 100644
--- a/src/pages/visual/index.vue
+++ b/src/pages/visual/index.vue
@@ -1,61 +1,71 @@
-
-
+