diff --git a/docs/en/program-update.md b/docs/en/program-update.md index 6b54d1e30..d4cb26ec2 100644 --- a/docs/en/program-update.md +++ b/docs/en/program-update.md @@ -217,7 +217,7 @@ Use `library` as the `owner` for official images, such as - + Language | Simplified Chinese | Traditional Chinese | English | @@ -599,6 +599,12 @@ Language +## winstall + +### Apps Update + + + ## WizTree ### What's New diff --git a/docs/program-update.md b/docs/program-update.md index f9c556562..423953793 100644 --- a/docs/program-update.md +++ b/docs/program-update.md @@ -681,6 +681,12 @@ Logseq 开发团队已经放弃了 [旧网站](https://logseq.com/blog)。 +## winstall + +### 应用更新 + + + ## WizFile ### 更新日志 diff --git a/lib/v2/winstall/maintainer.js b/lib/v2/winstall/maintainer.js new file mode 100644 index 000000000..8d6fb834f --- /dev/null +++ b/lib/v2/winstall/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/:appId': ['TonyRL'], +}; diff --git a/lib/v2/winstall/radar.js b/lib/v2/winstall/radar.js new file mode 100644 index 000000000..75b4c4d5a --- /dev/null +++ b/lib/v2/winstall/radar.js @@ -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', + }, + ], + }, +}; diff --git a/lib/v2/winstall/router.js b/lib/v2/winstall/router.js new file mode 100644 index 000000000..a6be4a3f1 --- /dev/null +++ b/lib/v2/winstall/router.js @@ -0,0 +1,3 @@ +module.exports = (router) => { + router.get('/:appId', require('./update')); +}; diff --git a/lib/v2/winstall/templates/desc.art b/lib/v2/winstall/templates/desc.art new file mode 100644 index 000000000..998a2ff2c --- /dev/null +++ b/lib/v2/winstall/templates/desc.art @@ -0,0 +1,5 @@ +{{ if installers }} + {{ each installers installer }} + {{ installer }}
+ {{ /each }} +{{ /if }} diff --git a/lib/v2/winstall/update.js b/lib/v2/winstall/update.js new file mode 100644 index 000000000..fc78acab4 --- /dev/null +++ b/lib/v2/winstall/update.js @@ -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, + }; +};