feat: add typora dev release changelog (#5559)
This commit is contained in:
parent
e1f5d25306
commit
34165f615b
|
|
@ -234,6 +234,10 @@ pageClass: routes
|
|||
|
||||
<Route author="cnzgray" example="/typora/changelog" path="/typora/changelog"/>
|
||||
|
||||
### Dev Release Changelog
|
||||
|
||||
<Route author="nczitzk" example="/typora/changelog-dev/macOS" path="/typora/changelog-dev/:os" :paramsDesc="['操作系统类型, 可选 `macOS` 或 `Windows` 与 `Linux`,默认为 `macOS`']"/>
|
||||
|
||||
## xclient.info
|
||||
|
||||
### 应用更新
|
||||
|
|
|
|||
|
|
@ -1070,6 +1070,7 @@ router.get('/tits-guru/model/:name', require('./routes/titsguru/model'));
|
|||
|
||||
// typora
|
||||
router.get('/typora/changelog', require('./routes/typora/changelog'));
|
||||
router.get('/typora/changelog-dev/:os?', require('./routes/typora/changelog-dev'));
|
||||
|
||||
// TSSstatus
|
||||
router.get('/tssstatus/:board/:build', require('./routes/tssstatus'));
|
||||
|
|
|
|||
|
|
@ -0,0 +1,35 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
ctx.params.os = ctx.params.os || 'macos';
|
||||
|
||||
const currentUrl = `https://typora.io${ctx.params.os.toLowerCase() === 'macos' ? '' : '/windows'}/dev_release.html`;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data.replace(/<h4>/g, '</div><div><h4>'));
|
||||
|
||||
const items = $('div')
|
||||
.slice(0, 10)
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
const h4 = item.find('h4');
|
||||
h4.remove();
|
||||
return {
|
||||
title: h4.text(),
|
||||
link: currentUrl,
|
||||
description: item.html(),
|
||||
};
|
||||
})
|
||||
.get();
|
||||
|
||||
ctx.state.data = {
|
||||
title: `Typora Changelog - ${ctx.params.os.toLowerCase() === 'macos' ? 'macOS' : 'Windows/Linux'}`,
|
||||
link: currentUrl,
|
||||
description: 'Typora Changelog',
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue