Add(route): add 广州天气预警 (#8911)

This commit is contained in:
Fatpandac 2022-01-22 19:53:22 +08:00 committed by GitHub
parent b36b326742
commit 46c3833ff2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 110 additions and 0 deletions

View File

@ -32,6 +32,16 @@ pageClass: routes
</Route>
## 广州天气
### 突发性天气提示
<Route author="Fatpandac" example="/gov/guangdong/tqyb/tfxtq" path="/gov/guangdong/tqyb/tfxtq"/>
### 广东省内城市预警信号
<Route author="Fatpandac" example="/gov/guangdong/tqyb/sncsyjxh" path="/gov/guangdong/tqyb/sncsyjxh"/>
## 国家突发事件预警信息发布网
### 当前生效预警

View File

@ -0,0 +1,37 @@
const got = require('@/utils/got');
const { art } = require('@/utils/render');
const path = require('path');
const { parseDate } = require('@/utils/parse-date');
const timezone = require('@/utils/timezone');
const rootUrl = 'http://www.tqyb.com.cn';
module.exports = async (ctx) => {
const sncsyjxhJsUrl = `${rootUrl}/data/gzWeather/otherCityAlarm.js`;
const response = await got.get(sncsyjxhJsUrl);
const resData = JSON.parse(String(response.data.match(/Alarm = (.*?);/)[1]));
const data = [];
for (const i in resData) {
for (const j in resData[i]) {
data.push(resData[i][j]);
}
}
const items = data.map((item) => ({
title: item.cname + ' ' + item.sigtypename,
link: `http://www.tqyb.com.cn/gz/weatherAlarm/otherCity/`,
description: art(path.join(__dirname, './templates/sncsyjxh.art'), {
item,
}),
pubDate: timezone(parseDate(item.datetime, 'YYYY年MM月DD日 HH:mm'), +8),
guid: timezone(parseDate(item.datetime, 'YYYY年MM月DD日 HH:mm'), +8) + item.cname + item.sigtypename,
}));
ctx.state.data = {
title: '广东省内城市预警信号',
link: `http://www.tqyb.com.cn/gz/weatherAlarm/otherCity/`,
item: items,
};
};

View File

@ -0,0 +1,5 @@
<text>地区: {{ item.cname }} </text>
<br>
<text>等级: {{ item.sigtypename }} </text>
<br>
<text>发布时间:{{ item.datetime }}</text>

View File

@ -0,0 +1 @@
<p> {{ content }} </p>

View File

@ -0,0 +1,30 @@
const got = require('@/utils/got');
const { art } = require('@/utils/render');
const path = require('path');
const { parseDate } = require('@/utils/parse-date');
const rootUrl = 'http://www.tqyb.com.cn';
module.exports = async (ctx) => {
const tfxtqJsUrl = `${rootUrl}/data/gzWeather/weatherTips.js`;
const response = await got.get(tfxtqJsUrl);
const data = JSON.parse(`[{${response.data.match(/Tips = {(.*?)}/)[1]}}]`);
const items = data.map((item) => ({
title: item.title,
link: 'http://www.tqyb.com.cn/gz/weatherAlarm/suddenWeather/',
author: item.issuer,
description: art(path.join(__dirname, './templates/tfxtq.art'), {
content: item.content,
}),
pubDate: parseDate(item.ddate),
guid: parseDate(item.ddate) + item.title,
}));
ctx.state.data = {
title: '突发性天气提示',
link: 'http://www.tqyb.com.cn/gz/weatherAlarm/suddenWeather/',
item: items,
};
};

4
lib/v2/gov/maintainer.js Normal file
View File

@ -0,0 +1,4 @@
module.exports = {
'/guangdong/tqyb/tfxtq': ['Fatpandac'],
'/guangdong/tqyb/sncsyjxh': ['Fatpandac'],
};

19
lib/v2/gov/radar.js Normal file
View File

@ -0,0 +1,19 @@
module.exports = {
'tqyb.com.cn': {
_name: '广州天气',
www: [
{
title: '突发性天气提示',
docs: 'https://docs.rsshub.app/government.html#guang-zhou-tian-qi-tu-fa-xing-tian-qi-ti-shi',
source: ['/gz/weatherAlarm/suddenWeather/'],
target: '/gov/guangdong/tqyb/tfxtq',
},
{
title: '广东省内城市预警信号',
docs: 'https://docs.rsshub.app/government.html#guang-zhou-tian-qi-guang-dong-sheng-nei-cheng-shi-yu-jing-xin-hao',
source: ['/gz/weatherAlarm/otherCity/'],
target: '/gov/guangdong/tqyb/sncsyjxh',
},
],
},
};

4
lib/v2/gov/router.js Normal file
View File

@ -0,0 +1,4 @@
module.exports = function (router) {
router.get('/guangdong/tqyb/tfxtq', require('./guangdong/tqyb/tfxtq'));
router.get('/guangdong/tqyb/sncsyjxh', require('./guangdong/tqyb/sncsyjxh'));
};