diff --git a/docs/other.md b/docs/other.md index ab43a1a86..2bcbbf9f1 100644 --- a/docs/other.md +++ b/docs/other.md @@ -884,3 +884,9 @@ type 为 all 时,category 参数不支持 cost 和 free ### 全文 + +##空气质量 + +###实时 AQI + + diff --git a/lib/router.js b/lib/router.js index 2fa15ef5d..3cd677f56 100644 --- a/lib/router.js +++ b/lib/router.js @@ -1341,4 +1341,7 @@ router.get('/steamgifts/discussions/:category?', require('./routes/steamgifts/di // Steamgifts router.get('/zzz', require('./routes/zzz/index')); +// aqicn +router.get('/aqicn/:city', require('./routes/aqicn/index')); + module.exports = router; diff --git a/lib/routes/aqicn/index.js b/lib/routes/aqicn/index.js new file mode 100644 index 000000000..888144b10 --- /dev/null +++ b/lib/routes/aqicn/index.js @@ -0,0 +1,27 @@ +const axios = require('@/utils/axios'); + +module.exports = async (ctx) => { + const city = ctx.params.city; + const area = isNaN(city) ? city : `@${city}`; + + const response = await axios({ + method: 'get', + url: `http://aqicn.org/aqicn/json/android/${area}/json`, + }); + const data = response.data; + + ctx.state.data = { + title: `${data.namena}AQI`, + link: `https://aqicn.org/city/${data.ids.path}`, + description: `${data.namena}AQI-aqicn.org`, + item: [ + { + title: `${data.namena}实时空气质量(AQI)${data.utimecn}`, + description: `${data.infocn}
风力:${data.cwind[0]}
AQI:${data.aqi}
`, + pubDate: new Date(data.time * 1000).toUTCString(), + guid: data.time, + link: `https://aqicn.org/city/${data.ids.path}`, + }, + ], + }; +};