From 21dbeba12fbaeae91dfded523eefb02742383284 Mon Sep 17 00:00:00 2001 From: Fatpandac <1779196284@qq.com> Date: Mon, 28 Mar 2022 23:16:17 +0800 Subject: [PATCH] =?UTF-8?q?feat(route):=20=E5=8D=8E=E7=A1=95=20=E5=9B=BA?= =?UTF-8?q?=E4=BB=B6=20(#9403)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(route): 华硕 固件 * fix(route): change radar url and modify the date format --- docs/program-update.md | 6 ++++++ lib/v2/asus/bios.js | 38 ++++++++++++++++++++++++++++++++++ lib/v2/asus/maintainer.js | 3 +++ lib/v2/asus/radar.js | 13 ++++++++++++ lib/v2/asus/router.js | 3 +++ lib/v2/asus/templates/bios.art | 6 ++++++ 6 files changed, 69 insertions(+) create mode 100644 lib/v2/asus/bios.js create mode 100644 lib/v2/asus/maintainer.js create mode 100644 lib/v2/asus/radar.js create mode 100644 lib/v2/asus/router.js create mode 100644 lib/v2/asus/templates/bios.art diff --git a/docs/program-update.md b/docs/program-update.md index 3be814206..3423f36b2 100644 --- a/docs/program-update.md +++ b/docs/program-update.md @@ -502,6 +502,12 @@ pageClass: routes 见 [#怪物猎人世界](/game.html#guai-wu-lie-ren-shi-jie) +## 华硕 + +### 固件 + + + ## 蒲公英应用分发 ### app 更新 diff --git a/lib/v2/asus/bios.js b/lib/v2/asus/bios.js new file mode 100644 index 000000000..bb343e551 --- /dev/null +++ b/lib/v2/asus/bios.js @@ -0,0 +1,38 @@ +const got = require('@/utils/got'); +const { parseDate } = require('@/utils/parse-date'); +const { art } = require('@/utils/render'); +const path = require('path'); + +const getProductID = async (model) => { + const searchAPI = `https://odinapi.asus.com.cn/recent-data/apiv2/SearchSuggestion?SystemCode=asus&WebsiteCode=cn&SearchKey=${model}&SearchType=ProductsAll&RowLimit=4&sitelang=cn`; + const response = await got(searchAPI); + + return { + productID: response.data.Result[0].Content[0].DataId, + url: response.data.Result[0].Content[0].Url, + }; +}; + +module.exports = async (ctx) => { + const model = ctx.params.model; + const { productID, url } = await getProductID(model); + const biosAPI = `https://www.asus.com.cn/support/api/product.asmx/GetPDBIOS?website=cn&model=${model}&pdid=${productID}&sitelang=cn`; + + const response = await got(biosAPI); + const biosList = response.data.Result.Obj[0].Files; + + const items = biosList.map((item) => ({ + title: item.Title, + description: art(path.join(__dirname, 'templates/bios.art'), { + item, + }), + pubDate: parseDate(item.ReleaseDate, 'YYYY/MM/DD'), + link: url, + })); + + ctx.state.data = { + title: `${model} BIOS`, + link: url, + item: items, + }; +}; diff --git a/lib/v2/asus/maintainer.js b/lib/v2/asus/maintainer.js new file mode 100644 index 000000000..45440b15a --- /dev/null +++ b/lib/v2/asus/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/bios/:model': ['Fatpandac'], +}; diff --git a/lib/v2/asus/radar.js b/lib/v2/asus/radar.js new file mode 100644 index 000000000..636df00ac --- /dev/null +++ b/lib/v2/asus/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'asus.com.cn': { + _name: 'Asus 华硕', + '.': [ + { + title: '固件', + docs: 'https://docs.rsshub.app/program-update.html#hua-shuo', + source: ['/'], + target: '/bios/:model', + }, + ], + }, +}; diff --git a/lib/v2/asus/router.js b/lib/v2/asus/router.js new file mode 100644 index 000000000..e95103000 --- /dev/null +++ b/lib/v2/asus/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/bios/:model', require('./bios')); +}; diff --git a/lib/v2/asus/templates/bios.art b/lib/v2/asus/templates/bios.art new file mode 100644 index 000000000..08bcee2ea --- /dev/null +++ b/lib/v2/asus/templates/bios.art @@ -0,0 +1,6 @@ +

更新信息:

+{{@ item.Description}} +

版本: {{item.Version}}

+

大小: {{item.FileSize}}

+

更新日期: {{item.ReleaseDate}}

+

下载链接: 中国下载 | 全球下载