fix(route): fixed routes/earthquake and ceic timezone shift (#9780)

* fixed routes/earthquake and ceic timezone shift

* use utils/timezone and remove changes on yarn.lock

* edit format problem

* refactor: migrate to v2
This commit is contained in:
b0ttle
2022-05-19 01:29:58 +08:00
committed by GitHub
parent 6187a08227
commit f477e3e8bf
7 changed files with 54 additions and 9 deletions
+3 -4
View File
@@ -453,11 +453,10 @@ router.get('/hopper/:lowestOnly/:from/:to?', lazyloadRouteHandler('./routes/hopp
router.get('/mafengwo/note/:type', lazyloadRouteHandler('./routes/mafengwo/note'));
router.get('/mafengwo/ziyouxing/:code', lazyloadRouteHandler('./routes/mafengwo/ziyouxing'));
// 中国地震局震情速递(与地震台网同步更新)
router.get('/earthquake/:region?', lazyloadRouteHandler('./routes/earthquake'));
// 中国地震局震情速递(与地震台网同步更新)migrated to v2
// router.get('/earthquake/:region?', lazyloadRouteHandler('./routes/earthquake'));
// 中国地震台网
router.get('/earthquake/ceic/:type', lazyloadRouteHandler('./routes/earthquake/ceic'));
// router.get('/earthquake/ceic/:type', lazyloadRouteHandler('./routes/earthquake/ceic'));
// 小说
router.get('/novel/biquge/:id', lazyloadRouteHandler('./routes/novel/biquge'));
@@ -1,4 +1,6 @@
const got = require('@/utils/got');
const { parseDate } = require('@/utils/parse-date');
const timezone = require('@/utils/timezone');
module.exports = async (ctx) => {
let type = Number(ctx.params.type);
@@ -57,7 +59,7 @@ module.exports = async (ctx) => {
return {
title: `${entity.LOCATION_C}发生${entity.M}级地震`,
link: `${baseUrl}/${NEW_DID}.html`,
pubDate: new Date(entity.O_TIME).toUTCString(),
pubDate: timezone(parseDate(entity.O_TIME, 'YYYY-MM-DD HH:mm:ss'), +8),
description: contentBuilder.join('<br>'),
guid: NEW_DID,
};
@@ -1,7 +1,9 @@
const got = require('@/utils/got');
const { parseDate } = require('@/utils/parse-date');
const timezone = require('@/utils/timezone');
module.exports = async (ctx) => {
const region = ctx.params.region || 1;
const region = ctx.params.region ?? 1;
const api = 'https://www.cea.gov.cn/eportal/ui?struts.portlet.mode=view&struts.portlet.action=/portlet/expressEarthquake!queryExpressEarthquakeList.action&pageId=363409&moduleId=a852ba487b534470a84a30f00e7d6670';
const link = 'https://www.cea.gov.cn/cea/xwzx/zqsd/index.html';
const response = await got({
@@ -18,14 +20,14 @@ module.exports = async (ctx) => {
const out = data.map((item) => {
const { id, epicenter, latitudes, longitudes, depth } = item;
const date = item.orig_time.slice(0, -2);
const date = item.orig_time;
const num = item.num_mag;
const description = `北京时间${date},${epicenter}(纬度${latitudes}度,经度${longitudes}度)发生${num}级地震,震源深度${depth}千米`;
return {
title: `${epicenter}发生${num}级地震`,
link: `https://www.cea.gov.cn/eportal/ui?struts.portlet.mode=view&struts.portlet.action=/portlet/expressEarthquake!toNewInfoView.action&pageId=366521&id=${id}`,
pubDate: new Date(date).toUTCString(),
pubDate: timezone(parseDate(date, 'YYYY-MM-DD HH:mm:ss'), +8),
description,
};
});
+4
View File
@@ -0,0 +1,4 @@
module.exports = {
'/ceic/:type?': ['SettingDust'],
'/:region?': ['LogicJake'],
};
+24
View File
@@ -0,0 +1,24 @@
module.exports = {
'ac.cn': {
_name: '地震速报',
'www.ceic': [
{
title: '中国地震台',
docs: 'https://docs-rsshub.pages.dev/forecast.html#di-zhen-su-bao',
source: ['/speedsearch', '/'],
target: '/earthquake/ceic',
},
],
},
'cea.gov.cn': {
_name: '地震速报',
www: [
{
title: '中国地震局',
docs: 'https://docs-rsshub.pages.dev/forecast.html#di-zhen-su-bao',
source: ['/cea/xwzx/zqsd/index.html', '/'],
target: '/earthquake',
},
],
},
};
+4
View File
@@ -0,0 +1,4 @@
module.exports = (router) => {
router.get('/ceic/:type?', require('./ceic'));
router.get('/:region?', require('./index'));
};