feat(route): add 全国港澳研究会 (#9011)

This commit is contained in:
Ethan Shen 2022-02-07 21:24:41 +08:00 committed by GitHub
parent 13883cafa9
commit fdf137b53b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 119 additions and 0 deletions

View File

@ -2551,6 +2551,22 @@ column 为 third 时可选的 category:
</Route>
## 全国港澳研究会
### 分类
<Route author="nczitzk" example="/cahkms" path="/cahkms/:category?" :paramsDesc="['分类,见下表,默认为重要新闻']">
| 关于我们 | 港澳新闻 | 重要新闻 | 顾问点评、会员观点 | 专题汇总 |
| -------- | -------- | -------- | ------------------ | -------- |
| 01 | 02 | 03 | 04 | 05 |
| 港澳时评 | 图片新闻 | 视频中心 | 港澳研究 | 最新书讯 | 研究资讯 |
| -------- | -------- | -------- | -------- | -------- | -------- |
| 06 | 07 | 08 | 09 | 10 | 11 |
</Route>
## 全民健康网
<Route author="nczitzk" example="/qm120/news" path="/qm120/news/:category?" :paramsDesc="['分类,见下表,默认为健康焦点']">

69
lib/v2/cahkms/index.js Normal file
View File

@ -0,0 +1,69 @@
const got = require('@/utils/got');
const timezone = require('@/utils/timezone');
const { parseDate } = require('@/utils/parse-date');
const { art } = require('@/utils/render');
const path = require('path');
const titles = {
'01': '关于我们',
'02': '港澳新闻',
'03': '重要新闻',
'04': '顾问点评、会员观点',
'05': '专题汇总',
'06': '港澳时评',
'07': '图片新闻',
'08': '视频中心',
'09': '港澳研究',
10: '最新书讯',
11: '研究资讯',
};
module.exports = async (ctx) => {
const category = ctx.params.category ?? '03';
const rootUrl = 'http://www.cahkms.org';
const currentUrl = `${rootUrl}/HKMAC/indexMac/getRightList?dm=${category}&page=1&countPage=${ctx.query.limit ?? 10}`;
const response = await got({
method: 'get',
url: currentUrl,
});
let items = response.data
.filter((item) => item.ID)
.map((item) => ({
title: item.TITLE,
description: `<p>${item.GJZ}</p>`,
pubDate: timezone(parseDate(item.JDRQ), +8),
link: `${rootUrl}/HKMAC/indexMac/getWzxx?id=${item.ID}`,
}));
items = await Promise.all(
items.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
});
item.author = detailResponse.data.WZLY;
item.description = art(path.join(__dirname, 'templates/description.art'), {
rootUrl,
content: detailResponse.data.CONTENT,
image: detailResponse.data.URL,
files: detailResponse.data.fjlist,
video: detailResponse.data.VIDEO.indexOf('.mp4') > 0 ? detailResponse.data.VIDEO : null,
});
item.link = `${rootUrl}/HKMAC/webView/mc/AboutUs_1.html?${category}&${titles[category]}`;
return item;
})
)
);
ctx.state.data = {
title: `${titles[category]} - 全国港澳研究会`,
link: currentUrl,
item: items,
};
};

View File

@ -0,0 +1,3 @@
module.exports = {
'/:category?': ['nczitzk'],
};

13
lib/v2/cahkms/radar.js Normal file
View File

@ -0,0 +1,13 @@
module.exports = {
'cahkms.org': {
_name: '全国港澳研究会',
'.': [
{
title: '分类',
docs: 'https://docs.rsshub.app/new-media.html#quan-guo-gang-ao-yan-jiu-hui-fen-lei',
source: '/',
target: '/cahkms/:category?',
},
],
},
};

3
lib/v2/cahkms/router.js Normal file
View File

@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/:category?', require('./index'));
};

View File

@ -0,0 +1,15 @@
{{ if image }}
<img src="{{ rootUrl }}{{ image }}">
{{ /if }}
{{ if content }}
{{@ content }}
{{ /if }}
{{ if video }}
<video controls><source src="{{ rootUrl }}{{ video }}" type="video/mp4"></video>
{{ /if }}
{{ if files }}
<br><b>下载附件:</b><br>
{{ each files file }}
<a href="{{ rootUrl }}{{ file.URL }}">{{ file.FJMC }}</a><br>
{{ /each }}
{{ /if }}