feat: add aqicn.org 实时空气质量 (#2209)
* feat: add aqicn.org 实时空气质量 * fix: 修正修改显示内容
This commit is contained in:
parent
e895dcf05a
commit
8888da3fc5
|
|
@ -884,3 +884,9 @@ type 为 all 时,category 参数不支持 cost 和 free
|
|||
### 全文
|
||||
|
||||
<Route author="HenryQW" example="/zzz" path="/zzz/index"/>
|
||||
|
||||
##空气质量
|
||||
|
||||
###实时 AQI
|
||||
|
||||
<Route author="xapool" example="/aqicn/beijing" path="/aqicn/:city" :paramsDesc="['城市拼音,详见[aqicn.org](http://aqicn.org/city/)']"/>
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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}<br>风力:<b>${data.cwind[0]}</b>级<br>AQI:<b>${data.aqi}</b><br><img referrerpolicy="no-referrer" src="${data.wgt}">`,
|
||||
pubDate: new Date(data.time * 1000).toUTCString(),
|
||||
guid: data.time,
|
||||
link: `https://aqicn.org/city/${data.ids.path}`,
|
||||
},
|
||||
],
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue