Skip to content

Commit

Permalink
feat(route): 华硕 固件 (DIYgod#9403)
Browse files Browse the repository at this point in the history
* feat(route): 华硕 固件

* fix(route): change radar url and modify the date format
  • Loading branch information
Fatpandac authored Mar 28, 2022
1 parent 501dff5 commit 21dbeba
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docs/program-update.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 更新
Expand Down
38 changes: 38 additions & 0 deletions lib/v2/asus/bios.js
Original file line number Diff line number Diff line change
@@ -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,
};
};
3 changes: 3 additions & 0 deletions lib/v2/asus/maintainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'/bios/:model': ['Fatpandac'],
};
13 changes: 13 additions & 0 deletions lib/v2/asus/radar.js
Original file line number Diff line number Diff line change
@@ -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 changes: 3 additions & 0 deletions lib/v2/asus/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/bios/:model', require('./bios'));
};
6 changes: 6 additions & 0 deletions lib/v2/asus/templates/bios.art
Original file line number Diff line number Diff line change
@@ -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>

0 comments on commit 21dbeba

Please sign in to comment.