feat(route/asus): 华硕 BIOS 路由增加国外访问 API 地址 (#16848)
This commit is contained in:
+39
-6
@@ -7,8 +7,24 @@ import { parseDate } from '@/utils/parse-date';
|
||||
import { art } from '@/utils/render';
|
||||
import path from 'node: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 endPoints = {
|
||||
zh: {
|
||||
url: 'https://odinapi.asus.com.cn/',
|
||||
lang: 'cn',
|
||||
website_code: 'cn',
|
||||
},
|
||||
en: {
|
||||
url: 'https://odinapi.asus.com/',
|
||||
lang: 'en',
|
||||
website_code: 'us',
|
||||
},
|
||||
};
|
||||
|
||||
const getProductID = async (model, language) => {
|
||||
const currentEndpoint = endPoints[language] ?? endPoints.zh;
|
||||
const { url, lang, website_code } = currentEndpoint;
|
||||
|
||||
const searchAPI = `${url}recent-data/apiv2/SearchSuggestion?SystemCode=asus&WebsiteCode=${website_code}&SearchKey=${model}&SearchType=ProductsAll&RowLimit=4&sitelang=${lang}`;
|
||||
const response = await got(searchAPI);
|
||||
|
||||
return {
|
||||
@@ -18,10 +34,26 @@ const getProductID = async (model) => {
|
||||
};
|
||||
|
||||
export const route: Route = {
|
||||
path: '/bios/:model',
|
||||
path: '/bios/:model/:lang?',
|
||||
categories: ['program-update'],
|
||||
example: '/asus/bios/RT-AX88U',
|
||||
parameters: { model: 'Model, can be found in product page' },
|
||||
example: '/asus/bios/RT-AX88U/zh',
|
||||
parameters: {
|
||||
model: 'Model, can be found in product page',
|
||||
lang: {
|
||||
description: 'Language, provide access routes for other parts of the world',
|
||||
options: [
|
||||
{
|
||||
label: 'Chinese',
|
||||
value: 'zh',
|
||||
},
|
||||
{
|
||||
label: 'English',
|
||||
value: 'en',
|
||||
},
|
||||
],
|
||||
default: 'zh',
|
||||
},
|
||||
},
|
||||
features: {
|
||||
requireConfig: false,
|
||||
requirePuppeteer: false,
|
||||
@@ -43,7 +75,8 @@ export const route: Route = {
|
||||
|
||||
async function handler(ctx) {
|
||||
const model = ctx.req.param('model');
|
||||
const { productID, url } = await getProductID(model);
|
||||
const language = ctx.req.param('lang') ?? 'zh';
|
||||
const { productID, url } = await getProductID(model, language);
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user