From 76b3bba2584e84569a46e705dcca8fb8b8743554 Mon Sep 17 00:00:00 2001 From: nuomi1 Date: Fri, 25 Feb 2022 11:08:32 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20QQ=20=E4=BA=92=E8=81=94=20SDK=20(#8421)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: QQ SDK changelog * refactor: functional style * refactor: migrate to v2 Co-authored-by: TonyRL --- assets/radar-rules.js | 41 ---------------------- docs/program-update.md | 6 ++++ lib/radar-rules.js | 46 ------------------------ lib/v2/tencent/maintainer.js | 3 ++ lib/v2/tencent/qq/sdk/changelog.js | 56 ++++++++++++++++++++++++++++++ lib/v2/tencent/radar.js | 56 ++++++++++++++++++++++++++++++ lib/v2/tencent/router.js | 3 ++ 7 files changed, 124 insertions(+), 87 deletions(-) create mode 100644 lib/v2/tencent/maintainer.js create mode 100644 lib/v2/tencent/qq/sdk/changelog.js create mode 100644 lib/v2/tencent/radar.js create mode 100644 lib/v2/tencent/router.js diff --git a/assets/radar-rules.js b/assets/radar-rules.js index 35fca4ac7..fd17d9df7 100644 --- a/assets/radar-rules.js +++ b/assets/radar-rules.js @@ -638,47 +638,6 @@ _name: 'eTOLAND', '.': [{ title: '主题贴', docs: 'https://docs.rsshub.app/bbs.html#etoland', source: ['/bbs/board.php', '/plugin/mobile/board.php'], target: (params, url) => `/etoland/${new URL(url).searchParams.get('bo_table')}` }], }, - 'qq.com': { - _name: '腾讯', - 'mp.weixin': [ - { - title: '微信公众号栏目', - docs: 'https://docs.rsshub.app/new-media.html#gong-zhong-hao-lan-mu-fei-tui-song-li-shi-xiao-xi', - source: '/mp/homepage', - target: (params, url) => `/wechat/mp/homepage/${new URL(url).searchParams.get('__biz')}/${new URL(url).searchParams.get('hid')}/${new URL(url).searchParams.get('cid') ? new URL(url).searchParams.get('cid') : ''}`, - }, - { - title: '微信公众号话题', - docs: 'https://docs.rsshub.app/new-media.html#wei-xin-gong-zhong-hao-wen-zhang-hua-ti-tag', - source: '/mp/appmsgalbum', - target: (params, url) => `/wechat/mp/msgalbum/${new URL(url).searchParams.get('__biz')}/${new URL(url).searchParams.get('album_id')}`, - }, - ], - egame: [ - { - title: '企鹅电竞直播间', - docs: 'https://docs.rsshub.app/live.html#qi-e-dian-jing-zhi-bo-jian-kai-bo', - source: '/:id', - target: (params) => { - if (params.id.match(/^\d+$/)) { - return '/egameqq/room/:id'; - } - }, - }, - ], - v: [ - { - title: '视频 - 播放列表', - docs: 'https://docs.rsshub.app/multimedia.html#teng-xun-shi-pin', - source: '/x/cover/:id', - target: (params) => { - const id = params.id.match('(.*).html')[1]; - return id ? `/tencentvideo/playlist/${id}` : ''; - }, - }, - { title: '视频 - 播放列表', docs: 'https://docs.rsshub.app/multimedia.html#teng-xun-shi-pin', source: '/x/cover/:id/:detail', target: '/tencentvideo/playlist/:id' }, - ], - }, 'onejav.com': { _name: 'OneJAV BT', '.': [ diff --git a/docs/program-update.md b/docs/program-update.md index abcf89844..3be814206 100644 --- a/docs/program-update.md +++ b/docs/program-update.md @@ -366,6 +366,12 @@ pageClass: routes +## QQ 互联 SDK + +### 更新日志 + + + ## QTTabBar ### Change Log diff --git a/lib/radar-rules.js b/lib/radar-rules.js index 46a87dfe7..f8d53284b 100644 --- a/lib/radar-rules.js +++ b/lib/radar-rules.js @@ -1658,52 +1658,6 @@ module.exports = { }, ], }, - 'qq.com': { - _name: '腾讯', - 'mp.weixin': [ - { - title: '微信公众号栏目', - docs: 'https://docs.rsshub.app/new-media.html#gong-zhong-hao-lan-mu-fei-tui-song-li-shi-xiao-xi', - source: '/mp/homepage', - target: (params, url) => `/wechat/mp/homepage/${new URL(url).searchParams.get('__biz')}/${new URL(url).searchParams.get('hid')}/${new URL(url).searchParams.get('cid') ? new URL(url).searchParams.get('cid') : ''}`, - }, - { - title: '微信公众号话题', - docs: 'https://docs.rsshub.app/new-media.html#wei-xin-gong-zhong-hao-wen-zhang-hua-ti-tag', - source: '/mp/appmsgalbum', - target: (params, url) => `/wechat/mp/msgalbum/${new URL(url).searchParams.get('__biz')}/${new URL(url).searchParams.get('album_id')}`, - }, - ], - egame: [ - { - title: '企鹅电竞直播间', - docs: 'https://docs.rsshub.app/live.html#qi-e-dian-jing-zhi-bo-jian-kai-bo', - source: '/:id', - target: (params) => { - if (params.id.match(/^\d+$/)) { - return '/egameqq/room/:id'; - } - }, - }, - ], - v: [ - { - title: '视频 - 播放列表', - docs: 'https://docs.rsshub.app/multimedia.html#teng-xun-shi-pin', - source: '/x/cover/:id', - target: (params) => { - const id = params.id.match('(.*).html')[1]; - return id ? `/tencentvideo/playlist/${id}` : ''; - }, - }, - { - title: '视频 - 播放列表', - docs: 'https://docs.rsshub.app/multimedia.html#teng-xun-shi-pin', - source: '/x/cover/:id/:detail', - target: '/tencentvideo/playlist/:id', - }, - ], - }, 'onejav.com': { _name: 'OneJAV BT', '.': [ diff --git a/lib/v2/tencent/maintainer.js b/lib/v2/tencent/maintainer.js new file mode 100644 index 000000000..336c84ad8 --- /dev/null +++ b/lib/v2/tencent/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/qq/sdk/changelog/:platform': ['nuomi1'], +}; diff --git a/lib/v2/tencent/qq/sdk/changelog.js b/lib/v2/tencent/qq/sdk/changelog.js new file mode 100644 index 000000000..a1fd1efa5 --- /dev/null +++ b/lib/v2/tencent/qq/sdk/changelog.js @@ -0,0 +1,56 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const platform = ctx.params.platform; + + let title = ''; + let link = ''; + if (platform === 'iOS') { + title = 'iOS SDK 历史变更'; + link = 'https://wiki.connect.qq.com/ios_sdk历史变更'; + } else if (platform === 'Android') { + title = 'Android SDK 历史变更'; + link = 'https://wiki.connect.qq.com/android_sdk历史变更'; + } else { + throw Error('not support platform'); + } + + const response = await got.get(link); + + const $ = cheerio.load(response.data); + + // 获取主要文本,并且过滤空行 + const contents = $('.wp-editor') + .children('p') + .filter((_, element) => $(element).text() !== ''); + + const pList = []; + const titleIndex = []; + + // 遍历文本 p 标签,并且获取标题索引 + contents.each((index, element) => { + if ($(element).find('strong').length) { + titleIndex.push(index); + } + + pList.push($(element).text().replace('\n', '')); + }); + + // 用标题索引切割数组 + const changelogs = titleIndex.map((_, index) => { + const section = pList.slice(titleIndex[index], titleIndex[index + 1]); + const changelog = { + title: section[0], + description: section.slice(1).join('\n'), + }; + + return changelog; + }); + + ctx.state.data = { + title, + link, + item: changelogs, + }; +}; diff --git a/lib/v2/tencent/radar.js b/lib/v2/tencent/radar.js new file mode 100644 index 000000000..dde59d629 --- /dev/null +++ b/lib/v2/tencent/radar.js @@ -0,0 +1,56 @@ +module.exports = { + 'qq.com': { + _name: '腾讯', + 'mp.weixin': [ + { + title: '微信公众号栏目', + docs: 'https://docs.rsshub.app/new-media.html#gong-zhong-hao-lan-mu-fei-tui-song-li-shi-xiao-xi', + source: '/mp/homepage', + target: (params, url) => `/wechat/mp/homepage/${new URL(url).searchParams.get('__biz')}/${new URL(url).searchParams.get('hid')}/${new URL(url).searchParams.get('cid') ? new URL(url).searchParams.get('cid') : ''}`, + }, + { + title: '微信公众号话题', + docs: 'https://docs.rsshub.app/new-media.html#wei-xin-gong-zhong-hao-wen-zhang-hua-ti-tag', + source: '/mp/appmsgalbum', + target: (params, url) => `/wechat/mp/msgalbum/${new URL(url).searchParams.get('__biz')}/${new URL(url).searchParams.get('album_id')}`, + }, + ], + egame: [ + { + title: '企鹅电竞直播间', + docs: 'https://docs.rsshub.app/live.html#qi-e-dian-jing-zhi-bo-jian-kai-bo', + source: '/:id', + target: (params) => { + if (params.id.match(/^\d+$/)) { + return '/egameqq/room/:id'; + } + }, + }, + ], + v: [ + { + title: '视频 - 播放列表', + docs: 'https://docs.rsshub.app/multimedia.html#teng-xun-shi-pin', + source: '/x/cover/:id', + target: (params) => { + const id = params.id.match('(.*).html')[1]; + return id ? `/tencentvideo/playlist/${id}` : ''; + }, + }, + { + title: '视频 - 播放列表', + docs: 'https://docs.rsshub.app/multimedia.html#teng-xun-shi-pin', + source: '/x/cover/:id/:detail', + target: '/tencentvideo/playlist/:id', + }, + ], + 'wiki.connect': [ + { + title: 'QQ 互联 SDK 更新日志', + docs: 'https://docs.rsshub.app/program-update.html#qq-hu-lian-sdk', + source: '/', + target: (_params, url) => `/tencent/qq/sdk/changelog/${new URL(url).pathname === '/ios_sdk历史变更' ? 'iOS' : 'Android'}`, + }, + ], + }, +}; diff --git a/lib/v2/tencent/router.js b/lib/v2/tencent/router.js new file mode 100644 index 000000000..a708c751e --- /dev/null +++ b/lib/v2/tencent/router.js @@ -0,0 +1,3 @@ +module.exports = (router) => { + router.get('/qq/sdk/changelog/:platform', require('./qq/sdk/changelog')); +};