feat: 国家应急广播 (#2914)
This commit is contained in:
parent
7b14cc1696
commit
616e79036d
|
|
@ -22,6 +22,16 @@ pageClass: routes
|
|||
|
||||
</Route>
|
||||
|
||||
## 国家应急广播网
|
||||
|
||||
### 预警信息
|
||||
|
||||
<Route author="muzea" example="/cneb/yjxx" path="/cneb/yjxx"/>
|
||||
|
||||
### 国内新闻
|
||||
|
||||
<Route author="muzea" example="/cneb/guoneinews" path="/cneb/guoneinews"/>
|
||||
|
||||
## 停电通知
|
||||
|
||||
获取未来一天的停电通知
|
||||
|
|
|
|||
|
|
@ -1646,4 +1646,8 @@ router.get('/sse/convert/:query?', require('./routes/sse/convert'));
|
|||
// 前端艺术家每日整理&&飞冰早报
|
||||
router.get('/jskou/:type?', require('./routes/jskou/index'));
|
||||
|
||||
// 国家应急广播
|
||||
router.get('/cneb/yjxx', require('./routes/cneb/yjxx'));
|
||||
router.get('/cneb/guoneinews', require('./routes/cneb/guoneinews'));
|
||||
|
||||
module.exports = router;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
const got = require('@/utils/got');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const list = (await got({
|
||||
method: 'get',
|
||||
url: 'http://www.cneb.gov.cn/guoneinews/guoneidata/',
|
||||
})).data.rollData;
|
||||
|
||||
const items = list.map((item) => {
|
||||
const single = {
|
||||
title: item.title,
|
||||
description: item.description.replace(/<!\[CDATA\[.+?]]>/g, ''),
|
||||
pubDate: new Date(item.dateTime + ' UTC+08:00').toString(),
|
||||
link: item.url,
|
||||
};
|
||||
return single;
|
||||
});
|
||||
|
||||
ctx.state.data = {
|
||||
title: '国内新闻_国家应急广播网',
|
||||
link: 'http://www.cneb.gov.cn/guoneinews/',
|
||||
description: '国家应急广播',
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
const got = require('@/utils/got');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const warningMessagesJsonp = (await got({
|
||||
method: 'get',
|
||||
url: 'http://uc.cneb.gov.cn:8080/getWarningMessages?callback=func&start=0&pagetype=PAGE1409368873582889&rows=100&_=' + +new Date(),
|
||||
})).data.trim();
|
||||
|
||||
let warningMessages = [];
|
||||
|
||||
try {
|
||||
const jsonString = warningMessagesJsonp.slice(5, -1);
|
||||
warningMessages = JSON.parse(jsonString).docs;
|
||||
} catch (error) {
|
||||
// console.error(error);
|
||||
}
|
||||
|
||||
const items = warningMessages.map((item) => {
|
||||
const single = {
|
||||
title: item.brief,
|
||||
description: item.content,
|
||||
pubDate: new Date(item.publishdate + ' UTC+08:00').toString(),
|
||||
link: item.url,
|
||||
};
|
||||
return single;
|
||||
});
|
||||
|
||||
ctx.state.data = {
|
||||
title: '预警信息_国家应急广播网',
|
||||
link: 'http://www.cneb.gov.cn/yjxx/',
|
||||
description: '国家应急广播',
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue