feat: add 天天基金 (#4249)

This commit is contained in:
zidekuls
2020-03-18 10:39:18 +08:00
committed by GitHub
parent e2b0d3b4bf
commit 6a79ccfe7a
3 changed files with 39 additions and 0 deletions
+6
View File
@@ -57,3 +57,9 @@ pageClass: routes
| announcement | news | research |
</Route>
## 天天基金
### 用户动态
<Route author="zidekuls" example="/eastmoney/user/6551094298949188" path="/eastmoney/user/:uid" :paramsDesc="['用户 id, 可在用户主页 URL 中找到']"/>
+3
View File
@@ -429,6 +429,9 @@ router.get('/xueqiu/stock_info/:id/:type?', require('./routes/xueqiu/stock_info'
router.get('/xueqiu/snb/:id', require('./routes/xueqiu/snb'));
router.get('/xueqiu/hots', require('./routes/xueqiu/hots'));
// 天天基金
router.get('/eastmoney/user/:uid', require('./routes/eastmoney/user'));
// Greasy Fork
router.get('/greasyfork/:language/:domain?', require('./routes/greasyfork/scripts'));
+30
View File
@@ -0,0 +1,30 @@
const got = require('@/utils/got');
module.exports = async (ctx) => {
const uid = ctx.params.uid;
const response = await got({
method: 'get',
headers: {
Accept: '*/*',
Host: 'i.eastmoney.com',
'Accept-Encoding': 'gzip, deflate, br',
'Cache-Control': 'no-cache',
},
url: `https://i.eastmoney.com/api/ta/UserPostList?p=1&ps=20&uid=${uid}`,
});
const data = response.data.data.re;
const username = data[0].post_user.user_nickname;
ctx.state.data = {
title: `天天基金-${username}的主页`,
link: `https://i.eastmoney.com//${uid}`,
description: `${username} 的 动态`,
item: data.map((item) => ({
title: item.post_title,
description: item.post_content,
pubDate: item.post_display_time,
link: `http://guba.eastmoney.com/news,${item.code_name},${item.post_id}.html`,
})),
};
};