From 46c3833ff2dfde4b32450499d32d00a9eb192411 Mon Sep 17 00:00:00 2001
From: Fatpandac <1779196284@qq.com>
Date: Sat, 22 Jan 2022 19:53:22 +0800
Subject: [PATCH] =?UTF-8?q?Add(route):=20add=20=E5=B9=BF=E5=B7=9E=E5=A4=A9?=
=?UTF-8?q?=E6=B0=94=E9=A2=84=E8=AD=A6=20(#8911)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
docs/forecast.md | 10 +++++
lib/v2/gov/guangdong/tqyb/sncsyjxh.js | 37 +++++++++++++++++++
.../gov/guangdong/tqyb/templates/sncsyjxh.art | 5 +++
lib/v2/gov/guangdong/tqyb/templates/tfxtq.art | 1 +
lib/v2/gov/guangdong/tqyb/tfxtq.js | 30 +++++++++++++++
lib/v2/gov/maintainer.js | 4 ++
lib/v2/gov/radar.js | 19 ++++++++++
lib/v2/gov/router.js | 4 ++
8 files changed, 110 insertions(+)
create mode 100644 lib/v2/gov/guangdong/tqyb/sncsyjxh.js
create mode 100644 lib/v2/gov/guangdong/tqyb/templates/sncsyjxh.art
create mode 100644 lib/v2/gov/guangdong/tqyb/templates/tfxtq.art
create mode 100644 lib/v2/gov/guangdong/tqyb/tfxtq.js
create mode 100644 lib/v2/gov/maintainer.js
create mode 100644 lib/v2/gov/radar.js
create mode 100644 lib/v2/gov/router.js
diff --git a/docs/forecast.md b/docs/forecast.md
index 647cb38c2..3e9aa8f8d 100644
--- a/docs/forecast.md
+++ b/docs/forecast.md
@@ -32,6 +32,16 @@ pageClass: routes
+## 广州天气
+
+### 突发性天气提示
+
+
+
+
{{ content }}
diff --git a/lib/v2/gov/guangdong/tqyb/tfxtq.js b/lib/v2/gov/guangdong/tqyb/tfxtq.js new file mode 100644 index 000000000..cfb299b35 --- /dev/null +++ b/lib/v2/gov/guangdong/tqyb/tfxtq.js @@ -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, + }; +}; diff --git a/lib/v2/gov/maintainer.js b/lib/v2/gov/maintainer.js new file mode 100644 index 000000000..a1d45dc4d --- /dev/null +++ b/lib/v2/gov/maintainer.js @@ -0,0 +1,4 @@ +module.exports = { + '/guangdong/tqyb/tfxtq': ['Fatpandac'], + '/guangdong/tqyb/sncsyjxh': ['Fatpandac'], +}; diff --git a/lib/v2/gov/radar.js b/lib/v2/gov/radar.js new file mode 100644 index 000000000..27b4a5171 --- /dev/null +++ b/lib/v2/gov/radar.js @@ -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', + }, + ], + }, +}; diff --git a/lib/v2/gov/router.js b/lib/v2/gov/router.js new file mode 100644 index 000000000..bf10a4ead --- /dev/null +++ b/lib/v2/gov/router.js @@ -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')); +};