From 7b533fff224d2319aa9bf6eab88d6aa8a7caa2fd Mon Sep 17 00:00:00 2001
From: Ethan Shen <42264778+nczitzk@users.noreply.github.com>
Date: Sun, 14 May 2023 00:24:48 +0800
Subject: [PATCH] =?UTF-8?q?feat(route):=20add=20=E9=98=BF=E9=87=8C?=
=?UTF-8?q?=E7=A0=94=E7=A9=B6=E9=99=A2=E8=B5=84=E8=AE=AF=20(#12507)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* feat(route): add 阿里研究院资讯
* docs: fix changes
---
docs/new-media.md | 11 ++++++
lib/v2/aliresearch/information.js | 57 +++++++++++++++++++++++++++++++
lib/v2/aliresearch/maintainer.js | 3 ++
lib/v2/aliresearch/radar.js | 13 +++++++
lib/v2/aliresearch/router.js | 3 ++
5 files changed, 87 insertions(+)
create mode 100644 lib/v2/aliresearch/information.js
create mode 100644 lib/v2/aliresearch/maintainer.js
create mode 100644 lib/v2/aliresearch/radar.js
create mode 100644 lib/v2/aliresearch/router.js
diff --git a/docs/new-media.md b/docs/new-media.md
index 4ec2f62bd..a2891688d 100644
--- a/docs/new-media.md
+++ b/docs/new-media.md
@@ -1545,6 +1545,17 @@ Supported sub-sites:
+## 阿里研究院
+
+### 资讯
+
+
+
+| 新闻 | 观点 | 案例 |
+| ---- | ---- | ---- |
+
+
+
## 艾莱资讯
### 世界轨道交通资讯网
diff --git a/lib/v2/aliresearch/information.js b/lib/v2/aliresearch/information.js
new file mode 100644
index 000000000..38470eff4
--- /dev/null
+++ b/lib/v2/aliresearch/information.js
@@ -0,0 +1,57 @@
+const got = require('@/utils/got');
+const timezone = require('@/utils/timezone');
+const { parseDate } = require('@/utils/parse-date');
+
+module.exports = async (ctx) => {
+ const type = ctx.params.type ?? '新闻';
+ const limit = ctx.query.limit ? parseInt(ctx.query.limit) : 50;
+
+ const rootUrl = 'http://www.aliresearch.com';
+ const currentUrl = `${rootUrl}/cn/information`;
+ const apiUrl = `${rootUrl}/ch/listArticle`;
+
+ const response = await got({
+ method: 'post',
+ url: apiUrl,
+ json: {
+ pageNo: 1,
+ pageSize: 10,
+ type,
+ },
+ });
+
+ let items = response.data.data.slice(0, limit).map((item) => ({
+ title: item.articleCode,
+ author: item.author,
+ pubDate: timezone(parseDate(item.gmtCreated), +8),
+ link: `${rootUrl}/ch/information/informationdetails?articleCode=${item.articleCode}`,
+ }));
+
+ items = await Promise.all(
+ items.map((item) =>
+ ctx.cache.tryGet(item.link, async () => {
+ const detailResponse = await got({
+ method: 'post',
+ url: `${rootUrl}/ch/getArticle`,
+ json: {
+ articleCode: item.title,
+ },
+ });
+
+ const data = detailResponse.data.data;
+
+ item.title = data.title;
+ item.description = data.content;
+ item.category = data.special.split(',');
+
+ return item;
+ })
+ )
+ );
+
+ ctx.state.data = {
+ title: `阿里研究院 - ${type}`,
+ link: currentUrl,
+ item: items,
+ };
+};
diff --git a/lib/v2/aliresearch/maintainer.js b/lib/v2/aliresearch/maintainer.js
new file mode 100644
index 000000000..5dc189006
--- /dev/null
+++ b/lib/v2/aliresearch/maintainer.js
@@ -0,0 +1,3 @@
+module.exports = {
+ '/information/:type?': ['nczitzk'],
+};
diff --git a/lib/v2/aliresearch/radar.js b/lib/v2/aliresearch/radar.js
new file mode 100644
index 000000000..ed9969de6
--- /dev/null
+++ b/lib/v2/aliresearch/radar.js
@@ -0,0 +1,13 @@
+module.exports = {
+ 'aliresearch.com': {
+ _name: '阿里研究院',
+ '.': [
+ {
+ title: '资讯',
+ docs: 'https://docs.rsshub.app/new-media.html#a-li-yan-jiu-yuan',
+ source: ['/cn/information', '/'],
+ target: '/aliresearch/information',
+ },
+ ],
+ },
+};
diff --git a/lib/v2/aliresearch/router.js b/lib/v2/aliresearch/router.js
new file mode 100644
index 000000000..ab438d810
--- /dev/null
+++ b/lib/v2/aliresearch/router.js
@@ -0,0 +1,3 @@
+module.exports = function (router) {
+ router.get('/information/:type?', require('./information'));
+};