mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-06 05:03:44 +08:00
Update changelog.js
This commit is contained in:
@@ -2,13 +2,27 @@ const got = require('@/utils/got');
|
|||||||
const cheerio = require('cheerio');
|
const cheerio = require('cheerio');
|
||||||
|
|
||||||
module.exports = async (ctx) => {
|
module.exports = async (ctx) => {
|
||||||
|
var language = ctx.params.language;
|
||||||
|
let changelog = '';
|
||||||
|
|
||||||
|
//如果为空或选项以外的值,则设置默认值
|
||||||
|
if (language === undefined || !(language === 'tw' || language === 'en')) {
|
||||||
|
language = 'cn';
|
||||||
|
changelog = '更新日志';
|
||||||
|
}
|
||||||
|
if (language === 'tw') {
|
||||||
|
changelog = '更新日誌';
|
||||||
|
}
|
||||||
|
if (language === 'en') {
|
||||||
|
changelog = 'Release Notes';
|
||||||
|
}
|
||||||
|
|
||||||
// 发起 HTTP GET 请求
|
// 发起 HTTP GET 请求
|
||||||
const response = await got({
|
const response = await got({
|
||||||
method: 'get',
|
method: 'get',
|
||||||
url: 'https://cn.eagle.cool/changelog',
|
url: `https://${language}.eagle.cool/changelog`,
|
||||||
headers: {
|
headers: {
|
||||||
Referer: `https://cn.eagle.cool/`,
|
Referer: `https://${language}.eagle.cool/`,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -20,33 +34,38 @@ module.exports = async (ctx) => {
|
|||||||
|
|
||||||
ctx.state.data = {
|
ctx.state.data = {
|
||||||
// 源标题
|
// 源标题
|
||||||
title: 'Eagle 更新日志',
|
title: `Eagle ${changelog}`,
|
||||||
// 源链接
|
// 源链接
|
||||||
link: 'https://cn.eagle.cool/changelog',
|
link: `https://${language}.eagle.cool/changelog`,
|
||||||
// 源说明
|
// 源说明
|
||||||
description: `Eagle 更新日志`,
|
description: `Eagle ${changelog}`,
|
||||||
|
|
||||||
// 遍历此前获取的数据
|
//遍历此前获取的数据
|
||||||
item:
|
item:
|
||||||
list &&
|
list &&
|
||||||
list.map((index, item) => {
|
list.map((index, item) => {
|
||||||
item = $(item);
|
item = $(item);
|
||||||
// 对获取的日期进行格式化处理
|
// 对获取的日期进行格式化处理
|
||||||
function getDate() {
|
function getDate() {
|
||||||
const str = item.find('.date').text();
|
var str = item.find('.date').text();
|
||||||
const patt = /[0-9]\d*/g;
|
|
||||||
let result;
|
|
||||||
let date = "";
|
let date = "";
|
||||||
while ((result = patt.exec(str)) !== null) {
|
if (language === "cn" || language === "tw") {
|
||||||
date += result + '-';
|
var patt = /[0-9]\d*/g;
|
||||||
|
var result;
|
||||||
|
while ((result = patt.exec(str)) !== null) {
|
||||||
|
date += result + '-';
|
||||||
|
}
|
||||||
|
date = date.replace(/-$/g, "");
|
||||||
|
} else if (language === "en") {
|
||||||
|
date = str.replace(/RELEASED/g, "");
|
||||||
}
|
}
|
||||||
return date.replace(/-$/g, "");
|
return date;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
title: item.find('.ver').text(),
|
title: item.find('.ver').text(),
|
||||||
description: item.find('.logs').html(),
|
description: item.find('.logs').html(),
|
||||||
link: 'https://cn.eagle.cool/changelog',
|
link: `https://${language}.eagle.cool/changelog`,
|
||||||
pubDate: new Date(getDate()).toUTCString(),
|
pubDate: new Date(getDate()).toUTCString(),
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user