feat(route): 华硕 固件 (#9403)

* feat(route): 华硕 固件

* fix(route): change radar url and modify the date format
This commit is contained in:
Fatpandac 2022-03-28 23:16:17 +08:00 committed by GitHub
parent 501dff59d0
commit 21dbeba12f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 69 additions and 0 deletions

View File

@ -502,6 +502,12 @@ pageClass: routes
见 [#怪物猎人世界](/game.html#guai-wu-lie-ren-shi-jie)
## 华硕
### 固件
<Route author="Fatpandac" example="/asus/bios/RT-AX88U" path="/asus/bios/:model" :paramsDesc="['产品型号,可在产品页面找到']"/>
## 蒲公英应用分发
### app 更新

38
lib/v2/asus/bios.js Normal file
View File

@ -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,
};
};

View File

@ -0,0 +1,3 @@
module.exports = {
'/bios/:model': ['Fatpandac'],
};

13
lib/v2/asus/radar.js Normal file
View File

@ -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',
},
],
},
};

3
lib/v2/asus/router.js Normal file
View File

@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/bios/:model', require('./bios'));
};

View File

@ -0,0 +1,6 @@
<p>更新信息:</p>
{{@ item.Description}}
<p>版本: {{item.Version}}</p>
<p>大小: {{item.FileSize}}</p>
<p>更新日期: {{item.ReleaseDate}}</p>
<p>下载链接: <a href="{{item.DownloadUrl.China}}">中国下载</a> | <a href="{{item.DownloadUrl.Global}}">全球下载</a></p>