feat: add 美团开放平台公告 (#6719)

* feat: add 美团开放平台公告

* feat: add 美团开放平台公告
This commit is contained in:
youzipi
2021-01-18 17:39:25 -05:00
committed by GitHub
parent 476274cafe
commit f1eedb01ab
3 changed files with 54 additions and 0 deletions
+6
View File
@@ -665,6 +665,12 @@ GitHub 官方也提供了一些 RSS:
<Route author="tonghs" example="/manong-weekly" path="/manong-weekly" />
## 美团开放平台
### 美团开放平台公告
<Route author="youzipi" example="/meituan/open/announce" path="/meituan/open/announce"/>
## 平安银河实验室
### posts
+3
View File
@@ -2092,6 +2092,9 @@ router.get('/tianya/comments/:userid', require('./routes/tianya/comments'));
router.get('/eleme/open/announce', require('./routes/eleme/open/announce'));
router.get('/eleme/open-be/announce', require('./routes/eleme/open-be/announce'));
// 美团开放平台
router.get('/meituan/open/announce', require('./routes/meituan/open/announce'));
// 微信开放社区
router.get('/wechat-open/community/:type', require('./routes/tencent/wechat/wechat-open/community/announce'));
// 微信支付 - 商户平台公告
+45
View File
@@ -0,0 +1,45 @@
const got = require('@/utils/got');
module.exports = async (ctx) => {
const response = await got({
method: 'get',
url: 'https://developer.meituan.com/api/v1/announcement/menu-page?docKey=anno-all&pageSize=100&pageNum=1',
});
const docList = response.data.data.docList;
const url = 'https://developer.meituan.com/api/v1/doc/content';
// https://developer.meituan.com/api/v1/doc/content?docKey=announcement-468
const articleList = await Promise.all(
docList.map(async (item) => {
const articleUrl = `${url}?docKey=${item.docKey}`;
const cacheKey = `${articleUrl}_${item.modifyTime}`;
const cache = await ctx.cache.get(cacheKey);
if (cache) {
return Promise.resolve(JSON.parse(cache));
} else {
const articleResp = await got.get(articleUrl);
const article = {
title: item.title,
link: `https://developer.meituan.com/isv/announcement/detail?dockey=anno-all&id=${item.docKey}`,
description: articleResp.data.data.docDataItemDtos[0].content,
pubDate: item.modifyTime,
};
ctx.cache.set(cacheKey, JSON.stringify(article));
return Promise.resolve(article);
}
})
);
ctx.state.data = {
title: '美团开放平台-公告',
link: 'https://developer.meituan.com/isv/announcement/list',
item: articleList.map((item) => ({
title: item.title,
description: item.description,
pubDate: item.modifyTime,
link: item.link,
})),
};
};