From 028b1b624eb23fd96ba0251ecfb5fff1e1eeaa52 Mon Sep 17 00:00:00 2001 From: Laam Pui Date: Tue, 24 Nov 2020 10:21:20 +0800 Subject: [PATCH 1/2] feat: add zhimap #6227 --- docs/study.md | 9 +++++++++ lib/router.js | 3 +++ lib/routes/zhimap/index.js | 20 ++++++++++++++++++++ 3 files changed, 32 insertions(+) create mode 100644 lib/routes/zhimap/index.js diff --git a/docs/study.md b/docs/study.md index 758953eec6c4cb..ed81637118e145 100644 --- a/docs/study.md +++ b/docs/study.md @@ -120,6 +120,15 @@ pageClass: routes +## zhimap 思维导图社区 + + + +| 热门 | 学科 | 学习 | 语言 | 工作 | 提升 | 生活 | 互联网 | 教育 | 其他 | 行业 | 服务发布 | 医疗 | +| -------------------------------- | -------------------------------- | -------------------------------- | -------------------------------- | -------------------------------- | -------------------------------- | -------------------------------- | -------------------------------- | -------------------------------- | -------------------------------- | -------------------------------- | -------------------------------- | -------------------------------- | +| 33b67d1bad1d4e37812f71d42764af34 | 9434268e893a46aa9a1a231059849984 | 820156a42e9a490796c7fd56916aa95b | 959c81f606ca495c882c7e461429eb2a | 5af4bca5496e4733a2d582690627e25f | 5300988dff564756b5d462cea8a865b7 | 02fdcc2ab6374bc6b9b9717e70c87723 | 437d434fe9eb410a94dcefb889994e2b | 9747cbf78f96492c973aa6ab23925eee | d4c3a92a9cf64da7b187763211dc6ff6 | 58231ab9cef34af7819c3f6e2160c007 | 73d89972bee0457997c983d7fca19f9f | 853ce8b3a4c24b87a03f66af95c5e06c | + + ## 唧唧堂 ### 论文 diff --git a/lib/router.js b/lib/router.js index 113514e27857f6..f58b863fc415f4 100644 --- a/lib/router.js +++ b/lib/router.js @@ -3505,4 +3505,7 @@ router.get('/instagram/:category/:key', require('./routes/instagram/index')); // 优设网 router.get('/uisdc/topic/:title?/:sort?', require('./routes/uisdc/topic')); +// Zhimap 知识导图社区 +router.get('/zhimap/:categoryUuid?/:recommend?', require('./routes/zhimap/index')); + module.exports = router; diff --git a/lib/routes/zhimap/index.js b/lib/routes/zhimap/index.js new file mode 100644 index 00000000000000..7b7ea920ec5023 --- /dev/null +++ b/lib/routes/zhimap/index.js @@ -0,0 +1,20 @@ +const got = require('@/utils/got'); + +module.exports = async (ctx) => { + const categoryUuid = ctx.params.categoryUuid || '33b67d1bad1d4e37812f71d42764af34'; + const recommend = ctx.params.recommend || 0; + const response = await got.get(`https://zhimap.com/restful/pub/publication/list?categoryUuid=${categoryUuid}&recommend=${recommend}&page=0&size=10`); + + const item = response.data.data.content.map((item) => ({ + author: item.author.nickname, + title: item.publicationInfo.abstracts, + pubDate: new Date(item.mindMap.createTime), + link: `https://zhimap.com/mmap/${item.mindMap.uuid}`, + })); + + ctx.state.data = { + title: 'Zhimap 知识导图社区', + link: `https://zhimap.com/gallery`, + item, + }; +}; From 16409db3bb516b34c492e86df707d6bb8f35e064 Mon Sep 17 00:00:00 2001 From: Laam Pui Date: Tue, 24 Nov 2020 10:39:25 +0800 Subject: [PATCH 2/2] fix: zhimap title --- lib/routes/zhimap/index.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/routes/zhimap/index.js b/lib/routes/zhimap/index.js index 7b7ea920ec5023..7849a61e2c2757 100644 --- a/lib/routes/zhimap/index.js +++ b/lib/routes/zhimap/index.js @@ -3,6 +3,23 @@ const got = require('@/utils/got'); module.exports = async (ctx) => { const categoryUuid = ctx.params.categoryUuid || '33b67d1bad1d4e37812f71d42764af34'; const recommend = ctx.params.recommend || 0; + + const title = { + '02fdcc2ab6374bc6b9b9717e70c87723': '生活', + '5af4bca5496e4733a2d582690627e25f': '工作', + '33b67d1bad1d4e37812f71d42764af34': '热门', + '73d89972bee0457997c983d7fca19f9f': '服务发布', + '437d434fe9eb410a94dcefb889994e2b': '互联网', + '853ce8b3a4c24b87a03f66af95c5e06c': '医疗', + '959c81f606ca495c882c7e461429eb2a': '语言', + '9747cbf78f96492c973aa6ab23925eee': '教育', + '58231ab9cef34af7819c3f6e2160c007': '行业', + '820156a42e9a490796c7fd56916aa95b': '学习', + '5300988dff564756b5d462cea8a865b7': '提升', + '9434268e893a46aa9a1a231059849984': '学科', + d4c3a92a9cf64da7b187763211dc6ff6: '其他', + }; + const response = await got.get(`https://zhimap.com/restful/pub/publication/list?categoryUuid=${categoryUuid}&recommend=${recommend}&page=0&size=10`); const item = response.data.data.content.map((item) => ({ @@ -13,7 +30,7 @@ module.exports = async (ctx) => { })); ctx.state.data = { - title: 'Zhimap 知识导图社区', + title: `Zhimap 知识导图社区 - ${title[categoryUuid]}`, link: `https://zhimap.com/gallery`, item, };