add WeGene 微解读 和 最近更新 (#1635)

closes #1601
This commit is contained in:
Chenyang Shi 2019-02-28 16:55:25 +08:00 committed by DIYgod
parent 4380d0014e
commit f9ebd68f58
4 changed files with 69 additions and 0 deletions

View File

@ -3053,6 +3053,21 @@ board 和 build 可在[这里](http://api.ineal.me/tss/status)查看
</route>
### WeGene
<route name="最近更新" author="LogicJake" example="/wegene/newest" path="/wegene/newest"/>
<route name="栏目" author="LogicJake" example="/wegene/column/all/all" path="/wegene/column/:type/:category" :paramsDesc="['栏目类型all全部项目 或 weapp专业版','栏目分类']">
:::
type 为 all 时category 参数不支持 cost 和 free
:::
| 全部 | 祖源分析 | 付费 | 遗传性疾病 | 药物指南 | 免费 | 运动基因 | 营养代谢 | 心理特质 | 健康风险 | 皮肤特性 | 遗传特征 |
| ---- | -------- | ---- | ---------- | -------- | ---- | -------- | ---------- | ---------- | -------- | -------- | -------- |
| all | ancestry | cost | disease | drug | free | genefit | metabolism | psychology | risk | skin | traits |
</route>
### instapaper
<route name="个人分享" author="LogicJake" example="/instapaper/person/viridiano" path="/instapaper/person"/>

View File

@ -1086,6 +1086,10 @@ router.get('/security/pulses', require('./routes/security/pulses'));
// DoNews
router.get('/donews/:column?', require('./routes/donews/index'));
// WeGene
router.get('/wegene/column/:type/:category', require('./routes/wegene/column'));
router.get('/wegene/newest', require('./routes/wegene/newest'));
// instapaper
router.get('/instapaper/person/:name', require('./routes/instapaper/person'));

View File

@ -0,0 +1,30 @@
const axios = require('../../utils/axios');
module.exports = async (ctx) => {
const type = ctx.params.type;
let name;
if (type === 'all') {
name = '全部项目';
} else {
name = '专业版';
}
const category = ctx.params.category;
const link = 'https://www.wegene.com/crowdsourcing';
const api = `https://www.wegene.com/crowdsourcing/ajax/get_list/?&htmlspecialchars_decode=true&type=${type}&page=1&limit=10&category=${category}&sort=NEW`;
const response = await axios.get(api);
const data = response.data.rsm.list;
ctx.state.data = {
title: `${name}${category}最近更新-WeGene`,
link: link,
item: data.map((item) => ({
title: item.title,
link: `https://www.wegene.com/crowdsourcing/details/${item.id}`,
date: new Date(item.add_time * 1000).toUTCString(),
author: item.user.user_name,
description: item.description,
})),
};
};

View File

@ -0,0 +1,20 @@
const axios = require('../../utils/axios');
module.exports = async (ctx) => {
const link = 'https://www.wegene.com/';
const api = 'https://www.wegene.com/contents/ajax/update/get_list/?htmlspecialchars_decode=true&page=1';
const response = await axios.get(api);
const data = response.data.rsm;
ctx.state.data = {
title: '最近更新-WeGene',
link: link,
item: data.map((item) => ({
title: item.title,
description: item.description,
pubDate: new Date(item.add_time * 1000).toUTCString(),
link: item.url,
})),
};
};