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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 54 additions and 9 deletions

View File

@ -26,7 +26,17 @@ pageClass: routes
### 中国地震台
<Route author="SettingDust" example="/earthquake/ceic/1" path="/earthquake/ceic/:type" :paramsDesc="['类型1 最近24小时地震信息, 2: 最近48小时地震信息, 5: 最近一年3.0级以上地震信息, 7: 最近一年3.0级以下地震, 8: 最近一年4.0级以上地震信息, 9: 最近一年5.0级以上地震信息, 0: 最近一年6.0级以上地震信息']">
<Route author="SettingDust" example="/earthquake/ceic/1" path="/earthquake/ceic/:type?" :paramsDesc="['类型,见下表']">
| 参数 | 类型 |
| -- | ---------------- |
| 1 | 最近 24 小时地震信息 |
| 2 | 最近 48 小时地震信息 |
| 5 | 最近一年 3.0 级以上地震信息 |
| 7 | 最近一年 3.0 级以下地震 |
| 8 | 最近一年 4.0 级以上地震信息 |
| 9 | 最近一年 5.0 级以上地震信息 |
| 0 | 最近一年 6.0 级以上地震信息 |
可通过全局过滤参数订阅您感兴趣的地区.

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'));

View File

@ -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,
};

View File

@ -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,
};
});

View File

@ -0,0 +1,4 @@
module.exports = {
'/ceic/:type?': ['SettingDust'],
'/:region?': ['LogicJake'],
};

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',
},
],
},
};

View File

@ -0,0 +1,4 @@
module.exports = (router) => {
router.get('/ceic/:type?', require('./ceic'));
router.get('/:region?', require('./index'));
};