feat(route): winstall (#12613)

This commit is contained in:
Tony
2023-06-04 23:59:21 +08:00
committed by GitHub
parent 649c3d3e5c
commit 0fb29a03d0
7 changed files with 80 additions and 1 deletions
+7 -1
View File
@@ -217,7 +217,7 @@ Use `library` as the `owner` for official images, such as <https://rsshub.app/do
### Changelog
<RouteEn author="tigercubden" example="/eagle/changelog/en" path="/eagle/changelog/:language?" :paramsDesc="['Language, see list, default to be `cn`']" radar="1">
Language
| Simplified Chinese | Traditional Chinese | English |
@@ -599,6 +599,12 @@ Language
<RouteEn author="nczitzk" example="/wdc/download/279" path="/wdc/download/:id?" :paramsDesc="['Software id, can be found in URL, 279 as Western Digital Dashboard by default']"/>
## winstall
### Apps Update
<RouteEn author="TonyRL" example="/winstall/Mozilla.Firefox" path="/winstall/:appId" :paramsDesc="['Application ID']" radar="1"/>
## WizTree
### What's New
+6
View File
@@ -681,6 +681,12 @@ Logseq 开发团队已经放弃了 [旧网站](https://logseq.com/blog)。
<Route author="nczitzk" example="/wdc/download/279" path="/wdc/download/:id?" :paramsDesc="['软件 id,可在对应软件页 URL 中找到,默认为 279,即 Western Digital Dashboard']"/>
## winstall
### 应用更新
<Route author="TonyRL" example="/winstall/Mozilla.Firefox" path="/winstall/:appId" :paramsDesc="['应用名']" radar="1"/>
## WizFile
### 更新日志
+3
View File
@@ -0,0 +1,3 @@
module.exports = {
'/:appId': ['TonyRL'],
};
+13
View File
@@ -0,0 +1,13 @@
module.exports = {
'winstall.app': {
_name: 'winstall',
'.': [
{
title: '应用更新',
docs: 'https://docs.rsshub.app/program-update.html#winstall',
source: ['/apps/:appId'],
target: '/winstall/:appId',
},
],
},
};
+3
View File
@@ -0,0 +1,3 @@
module.exports = (router) => {
router.get('/:appId', require('./update'));
};
+5
View File
@@ -0,0 +1,5 @@
{{ if installers }}
{{ each installers installer }}
<a href="{{ installer }}">{{ installer }}</a><br>
{{ /each }}
{{ /if }}
+43
View File
@@ -0,0 +1,43 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const config = require('@/config').value;
const { art } = require('@/utils/render');
const { join } = require('path');
module.exports = async (ctx) => {
const baseUrl = 'https://winstall.app';
const { appId } = ctx.params;
const buildId = await ctx.cache.tryGet(
'winget:buildId',
async () => {
const { data } = await got(baseUrl);
const $ = cheerio.load(data);
return JSON.parse($('#__NEXT_DATA__').text()).buildId;
},
config.cache.routeExpire,
false
);
const { data: response } = await got(`${baseUrl}/_next/data/${buildId}/apps/${appId}.json`);
const { app } = response.pageProps;
const items = app.versions.map((item) => ({
title: `${app.name} ${item.version}`,
description: art(join(__dirname, 'templates/desc.art'), {
installers: item.installers,
}),
author: app.publisher,
category: app.tags,
guid: `winstall:${appId}:${item.version}`,
}));
ctx.state.data = {
title: `${app.name} - winstall`,
description: app.desc,
link: `${baseUrl}/apps/${appId}`,
image: `https://api.winstall.app/icons/next/${appId}.webp`,
language: 'en',
item: items,
};
};