diff --git a/docs/study.md b/docs/study.md index 758953eec..6dfe6888d 100644 --- a/docs/study.md +++ b/docs/study.md @@ -304,6 +304,22 @@ pageClass: routes +## 印象识堂 + +### 印象剪藏 + + + +### 卡片清单 + + + +| 每周收藏排行榜・TOP5 | 每周热门「读书笔记」榜 TOP5 | 【印象话题】如何提高记忆力? | 【印象话题】选择的悖论 | 【印象专题】如何一秒洞察问题本质? | 「识堂开讲」5 位嘉宾精华笔记大放送 | 【印象话题】培养专注力的 5 个步骤 | 🎁购物清单主题活动获奖结果 | +| -------------------- | --------------------------- | ---------------------------- | ---------------------- | ---------------------------------- | ---------------------------------- | --------------------------------- | -------------------------- | +| 32 | 33 | 100 | 101 | 103 | 104 | 105 | 106 | + + + ## 英中协会 ### 奖学金 diff --git a/lib/router.js b/lib/router.js index 8e8459d80..7fdfaca79 100644 --- a/lib/router.js +++ b/lib/router.js @@ -3508,4 +3508,8 @@ router.get('/uisdc/news', require('./routes/uisdc/news')); router.get('/uisdc/zt/:title?', require('./routes/uisdc/zt')); router.get('/uisdc/topic/:title?/:sort?', require('./routes/uisdc/topic')); +// 印象识堂 +router.get('/yinxiang/note', require('./routes/yinxiang/note')); +router.get('/yinxiang/card/:id?', require('./routes/yinxiang/card')); + module.exports = router; diff --git a/lib/routes/yinxiang/card.js b/lib/routes/yinxiang/card.js new file mode 100644 index 000000000..6dc671eb6 --- /dev/null +++ b/lib/routes/yinxiang/card.js @@ -0,0 +1,46 @@ +const got = require('@/utils/got'); + +module.exports = async (ctx) => { + const id = ctx.params.id || '32'; + + const apiUrl = `https://app.yinxiang.com/third/discovery/client/restful/public/discovery/card-holder?cardHolderId=${id}`; + const response = await got({ + method: 'get', + url: apiUrl, + }); + + const list = response.data.card.map((item) => ({ + title: item.title, + link: item.url, + author: item.userNickname, + })); + + const items = await Promise.all( + list.map( + async (item) => + await ctx.cache.tryGet(item.link, async () => { + const detailResponse = await got({ + method: 'get', + url: `https://app.yinxiang.com/third/discovery/client/restful/public/blog-note?noteGuid=${item.link.split('/note/')[1]}`, + }); + + item.pubDate = new Date(parseInt(detailResponse.data.blogNote.publishTime)).toUTCString(); + + const description = detailResponse.data.blogNote.htmlContent; + if (description.indexOf('(.*)<\/en-note>/)[1]; + } + + return item; + }) + ) + ); + + ctx.state.data = { + title: `${response.data.name} - 印象识堂`, + link: 'https://www.yinxiang.com/everhub/', + item: items, + }; +}; diff --git a/lib/routes/yinxiang/note.js b/lib/routes/yinxiang/note.js new file mode 100644 index 000000000..2237ab96f --- /dev/null +++ b/lib/routes/yinxiang/note.js @@ -0,0 +1,42 @@ +const got = require('@/utils/got'); + +module.exports = async (ctx) => { + const apiUrl = 'https://app.yinxiang.com/third/discovery/client/restful/public/v2/discovery/homepage?notePageSize=20'; + const response = await got({ + method: 'get', + url: apiUrl, + }); + + const list = response.data.blogNote.slice(0, 5).map((item) => ({ + title: item.title, + link: `https://www.yinxiang.com/everhub/note/${item.noteGuid}`, + pubDate: new Date(parseInt(item.publishTime)).toUTCString(), + })); + + const items = await Promise.all( + list.map( + async (item) => + await ctx.cache.tryGet(item.link, async () => { + const detailResponse = await got({ + method: 'get', + url: `https://app.yinxiang.com/third/discovery/client/restful/public/blog-note?noteGuid=${item.link.split('/note/')[1]}`, + }); + + const description = detailResponse.data.blogNote.htmlContent; + if (description.indexOf('(.*)<\/en-note>/)[1]; + } + + return item; + }) + ) + ); + + ctx.state.data = { + title: '印象剪藏 - 印象识堂', + link: 'https://www.yinxiang.com/everhub/', + item: items, + }; +};