From 8e62240e4333bc6558f8ab52ef0e641b29fd877e Mon Sep 17 00:00:00 2001 From: BugWriter2 Date: Thu, 11 Jun 2020 11:35:52 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E5=A4=96=E6=8E=A5?= =?UTF-8?q?=E5=A4=A7=E8=84=91=E4=BD=9C=E4=B8=BA=E8=8E=B7=E5=8F=96=E5=85=AC?= =?UTF-8?q?=E4=BC=97=E5=8F=B7=E9=80=94=E5=BE=84=20(#4964)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/new-media.md | 6 +++++- lib/router.js | 1 + lib/routes/tencent/wechat/wjdn.js | 28 ++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 lib/routes/tencent/wechat/wjdn.js diff --git a/docs/new-media.md b/docs/new-media.md index 87cf5f0b3..1b3e539cd 100755 --- a/docs/new-media.md +++ b/docs/new-media.md @@ -698,7 +698,7 @@ Supported sub-sites: -具体栏目编号,去网站上看标签 +具体栏目编号,去网站上看标签 | 网址 | 对应路由 | | ------------------------------------------------------------------------------------------------- | -------- | @@ -1042,6 +1042,10 @@ Supported sub-sites: +### 公众号 (外接大脑来源) + + + ### 公众号栏目 (非推送 & 历史消息) diff --git a/lib/router.js b/lib/router.js index 1038b0023..14058c473 100644 --- a/lib/router.js +++ b/lib/router.js @@ -487,6 +487,7 @@ router.get('/wechat/miniprogram/plugins', require('./routes/tencent/wechat/minip router.get('/wechat/tgchannel/:id', require('./routes/tencent/wechat/tgchannel')); router.get('/wechat/uread/:userid', require('./routes/tencent/wechat/uread')); router.get('/wechat/ershicimi/:id', require('./routes/tencent/wechat/ershcimi')); +router.get('/wechat/wjdn/:id', require('./routes/tencent/wechat/wjdn')); router.get('/wechat/mp/homepage/:biz/:hid/:cid?', require('./routes/tencent/wechat/mp')); // All the Flight Deals diff --git a/lib/routes/tencent/wechat/wjdn.js b/lib/routes/tencent/wechat/wjdn.js new file mode 100644 index 000000000..a22d171c7 --- /dev/null +++ b/lib/routes/tencent/wechat/wjdn.js @@ -0,0 +1,28 @@ +const got = require('@/utils/got'); + +module.exports = async (ctx) => { + const { id } = ctx.params; + if (!id) { + throw Error('Bad category. See docs'); + } + + const currentUrl = `https://www.waijiedanao.com/api/posts?profile=${id}&page=1&limit=20`; + const response = await got({ + method: 'get', + url: currentUrl, + }); + + const title = response.data.data[0].profile.title; + const list = response.data.data.map((item) => ({ + title: item.title, + link: item.link, + description: item.digest, + pubDate: new Date(item.publishAt).toUTCString(), + })); + + ctx.state.data = { + title: `微信公众号 - ${title}`, + link: `https://www.waijiedanao.com/accountArtical?publicAccountId=${id}`, + item: list, + }; +};