fix: 简阅(simpread) 格式美化

This commit is contained in:
zytomorrow 2021-01-08 14:31:28 +08:00
parent 92ddaf6178
commit f17c4e92b8
1 changed files with 14 additions and 5 deletions

View File

@ -2,7 +2,7 @@ const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const url = 'https://simpread.pro/changelog.html';
const url = 'http://ksria.com/simpread/changelog.html';
const response = await got.get(url);
const data = response.data;
const $ = cheerio.load(data);
@ -41,17 +41,26 @@ module.exports = async (ctx) => {
version_type = 'Firefox';
}
// detail
const text_color = {
important: '#9c27b0',
add: '#4caf50',
change: '#ffc107',
fix: '#f44336',
complete: '#03a9f4',
};
$(detail)
.find('li')
.map((index, item) => {
const level = $(item).find('span').attr('class');
let span_class = $(item).find('span').attr('class');
const text = $(item).find('span').html();
$(item).find('span').remove();
if (level !== undefined) {
if (level.indexOf('empty') !== -1) {
if (span_class !== undefined) {
span_class = span_class.split(' ');
if (span_class[1] === 'empty') {
$(item).wrap('<ul></ul>');
} else {
$(item).prepend(`<b>${text}: </b>`);
$(item).prepend(`<b style='color:${text_color[span_class[1]]}'>${text}: </b>`);
}
}
return {};