diff --git a/src/components/weather/weather.ts b/src/components/weather/weather.ts
index a24df33..181c004 100644
--- a/src/components/weather/weather.ts
+++ b/src/components/weather/weather.ts
@@ -105,8 +105,7 @@ export class StarWeather extends LitElement {
空气质量
${(this.dataBoo() &&
- this.data.weatherInfo[0]?.airQuality?.value +
- this.data.weatherInfo[0]?.airQuality?.type) ||
+ this.fun(this.data.weatherInfo[0]?.airQuality?.value)) ||
''}
@@ -175,7 +174,7 @@ export class StarWeather extends LitElement {
空气质量${(this.dataBoo() &&
- this.data.weatherInfo[0]?.airQuality?.type) ||
+ this.fun(this.data.weatherInfo[0]?.airQuality?.value)) ||
''}
@@ -246,6 +245,25 @@ export class StarWeather extends LitElement {
this.resize()
})
}
+ fun(value: any) {
+ let airQualityType = ''
+ if (value > 0 && value <= 50) {
+ airQualityType = '优'
+ } else if (value <= 100) {
+ airQualityType = '良'
+ } else if (value <= 150) {
+ airQualityType = '轻度污染'
+ } else if (value <= 200) {
+ airQualityType = '中度污染'
+ } else if (value <= 300) {
+ airQualityType = '重度污染'
+ } else if (value > 300) {
+ airQualityType = '严重污染'
+ } else {
+ airQualityType = 'null'
+ }
+ return airQualityType
+ }
protected resize() {
let width = this.starWeather?.clientWidth || 10
let height = this.starWeather?.clientHeight || 10
diff --git a/src/test/panels/weather/weatherData.ts b/src/test/panels/weather/weatherData.ts
index 3c6e38a..34b39b9 100644
--- a/src/test/panels/weather/weatherData.ts
+++ b/src/test/panels/weather/weatherData.ts
@@ -18,8 +18,7 @@ export const weatherData = {
humidity: '40%',
airQuality: {
label: '空气质量',
- value: '26',
- type: '优',
+ value: '400',
},
somatosensoryTemperature: '32°C',
visibility: '33km',