Skip to content

Commit

Permalink
feat: add 孔夫子旧书网用户动态 (#5570)
Browse files Browse the repository at this point in the history
Co-authored-by: Henry Wang <[email protected]>
  • Loading branch information
Ethan Shen and HenryQW authored Sep 2, 2020
1 parent da3fc38 commit cbd832d
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docs/reading.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@ count 的取值范围为 1-12,为防止请求次数过多,推荐设置为 5

</Route>

## 孔夫子旧书网

### 用户动态

<Route author="nczitzk" example="/kongfz/people/5032170" path="/kongfz/people/:id" :paramsDesc="['用户 id, 可在对应用户页 URL 中找到']"/>

## 飘天文学

### 章节
Expand Down
3 changes: 3 additions & 0 deletions lib/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -3124,6 +3124,9 @@ router.get('/fjnews/fz/30', require('./routes/fjnews/fznews'));
// 九江新闻jjnews
router.get('/fjnews/jjnews', require('./routes/fjnews/jjnews'));

// 孔夫子旧书网
router.get('/kongfz/people/:id', require('./routes/kongfz/people'));

// 小刀娱乐网
router.get('/x6d/:id?', require('./routes/x6d/index'));

Expand Down
25 changes: 25 additions & 0 deletions lib/routes/kongfz/people.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const got = require('@/utils/got');

module.exports = async (ctx) => {
const userUrl = `https://t.kongfz.com/api/getFeedList?userId=${ctx.params.id}&size=20`;
const response = await got({
method: 'get',
url: userUrl,
});

const list = response.data.result.feedList.map((item) => ({
title: item.title || item.postTime,
link: `https://t.kongfz.com/detail/${item.feedId}`,
description: item.type === 'text' ? item.content : `<a href="https://t.kongfz.com/detail/${item.feedId}">商品上架</a>`,
pubDate: new Date(item.postDateTime).toUTCString(),
}));

const userInfo = response.data.result.userInfo;

ctx.state.data = {
title: `孔夫子旧书网 - ${userInfo.nickname}`,
link: userInfo.shareUrl,
item: list,
description: `${userInfo.sign}`,
};
};

0 comments on commit cbd832d

Please sign in to comment.