diff --git a/docs/program-update.md b/docs/program-update.md index ed7354551d..5eb9cf3bd5 100644 --- a/docs/program-update.md +++ b/docs/program-update.md @@ -439,3 +439,12 @@ pageClass: routes | | -commentCount | -createdAt | createdAt | + +## simpread + +### 消息通知 + + + +### 更新日志 + diff --git a/lib/router.js b/lib/router.js index 4c65a8a388..00588b2847 100644 --- a/lib/router.js +++ b/lib/router.js @@ -3785,6 +3785,11 @@ router.get('/nace/blog/:sort?', require('./routes/nace/blog')); // Caixin Latest router.get('/caixin/latest', require('./routes/caixin/latest')); +// SimpRead-消息通知 +router.get('/simpread/notice', require('./routes/simpread/notice')); +// SimpRead-更新日志 +router.get('/simpread/changelog', require('./routes/simpread/changelog')); + // Radio Free Asia router.get('/rfa/:language?/:channel?/:subChannel?', require('./routes/rfa/index')); diff --git a/lib/routes/simpread/changelog.js b/lib/routes/simpread/changelog.js new file mode 100644 index 0000000000..59ecaea8f7 --- /dev/null +++ b/lib/routes/simpread/changelog.js @@ -0,0 +1,79 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const url = 'http://ksria.com/simpread/changelog.html'; + const response = await got.get(url); + const data = response.data; + const $ = cheerio.load(data); + ctx.state.data = { + title: 'SimpRead 更新日志', + link: 'https://simpread.pro/changelog.html', + description: $('body > div.container.changelog > div.desc').html(), + item: $('.version') + .map((index, item) => { + const year = $(item).find('.year').html(); + const month_day = $(item).find('.day').html(); + let version = ''; + let detail = ''; + // 版本名称处理 + version = $(item).find('.num > a').clone().children().remove().end().text(); + // detail处理 + detail = $(item).find('.details'); + if (version === '') { + version = $(item).find('.num').clone().children().remove().end().text(); + } + let version_type = $(item).find('.num > a > i').attr('class'); + // 部分结构不一致处理 + if (version_type === undefined) { + version_type = $(item).find('.num > i').attr('class'); + } + if (version_type.indexOf('chrome') !== -1) { + version_type = 'Chrome'; + } + if (version_type.indexOf('apple') !== -1) { + version_type = 'Safari'; + } + if (version_type.indexOf('code') !== -1) { + version_type = 'UserScript'; + } + if (version_type.indexOf('firefox') !== -1) { + version_type = 'Firefox'; + } + + // detail + const text_color = { + important: '#9c27b0', + add: '#4caf50', + change: '#ffc107', + fix: '#f44336', + complete: '#03a9f4', + }; + $(detail) + .find('li') + .map((index, item) => { + let span_class = $(item).find('span').attr('class'); + const text = $(item).find('span').html(); + $(item).find('span').remove(); + if (span_class !== undefined) { + span_class = span_class.split(' '); + if (span_class[1] === 'empty') { + $(item).wrap(''); + } else { + $(item).prepend(`${text}: `); + } + } + return {}; + }); + + return { + description: $(detail).html(), + link: 'https://simpread.pro/changelog.html', + pubDate: `${year}-${month_day.replace('.', '-')} 00:00:00 GMT`, + title: `${version_type}${version}`, + author: 'SimpRead', + }; + }) + .get(), + }; +}; diff --git a/lib/routes/simpread/notice.js b/lib/routes/simpread/notice.js new file mode 100644 index 0000000000..79dd7950ef --- /dev/null +++ b/lib/routes/simpread/notice.js @@ -0,0 +1,20 @@ +const got = require('@/utils/got'); +const md = require('markdown-it')(); + +module.exports = async (ctx) => { + const url = 'https://static.simp.red/notice'; + const response = await got.get(url); + const data = response.data.notice; + ctx.state.data = { + title: 'SimpRead 消息通知', + link: 'https://simpread.pro/changelog.html', + description: 'SimpRead 消息通知', + item: data.map((item) => ({ + description: md.render(item.content), + link: 'https://simpread.pro/changelog.html', + pubDate: item.date, + title: `${item.category.name}-${item.title}`, + author: 'SimpRead', + })), + }; +};