feat: add 国家预警信息发布中心当前生效预警 (#5118)

This commit is contained in:
Ethan Shen
2020-07-07 17:15:12 +08:00
committed by GitHub
parent f789c4b9fc
commit 5c3ff7bf63
3 changed files with 32 additions and 0 deletions
+6
View File
@@ -32,6 +32,12 @@ pageClass: routes
</Route>
## 国家突发事件预警信息发布网
### 当前生效预警
<Route author="nczitzk" example="/12379" path="/12379/index"/>
## 国家应急广播网
### 预警信息
+3
View File
@@ -2932,4 +2932,7 @@ router.get('/gelonghui/keyword/:keyword', require('./routes/gelonghui/keyword'))
// 光谷社区
router.get('/guanggoo/:caty', require('./routes/guanggoo/index'));
// 国家突发事件预警信息发布网
router.get('/12379', require('./routes/12379/index'));
module.exports = router;
+23
View File
@@ -0,0 +1,23 @@
const got = require('@/utils/got');
module.exports = async (ctx) => {
const currentUrl = `http://www.12379.cn/data/index_map_all.html`;
const response = await got({
method: 'get',
url: currentUrl,
});
const data = JSON.parse(response.data.substr('var alertData ='.length, response.data.length + 1));
const list = data.map((item) => ({
title: item.headline,
link: `http://www.12379.cn/html/new2018/alarmcontent.shtml?file=${item.identifier}.html}`,
description: item.description,
pubDate: new Date(item.sendTime).toUTCString(),
}));
ctx.state.data = {
title: `当前生效预警 - 国家突发事件预警信息发布网`,
link: currentUrl,
item: list,
};
};