fix(route): fix xianbao typo and parse (#15148)

This commit is contained in:
Shima Rin 2024-04-08 14:29:55 +08:00 committed by GitHub
parent 8757a93fa9
commit 4e7f0c187e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 13 additions and 5 deletions

View File

@ -26,10 +26,10 @@ export const route: Route = {
| | xiaodigu |
| | huluxia |
| | xiadao |
| QQ | qqjishu |
| YYOK | yyok |
| QQ | qqjishu |
| YYOK大全 | yyok |
| | huodong |
| | maifei |
| | mianfei |
| | yixiaoshi |
| | sanxiaoshi |
| | liuxiaoshi |
@ -84,7 +84,15 @@ async function handler(ctx) {
const response = await got(apiUrl);
const responseData = JSON.parse(response.body);
const items = responseData.map((item) => ({
let parsedData;
if (Array.isArray(responseData)) {
parsedData = responseData;
} else {
const hotKey = Object.keys(responseData).find((key) => key.startsWith('remen'));
parsedData = responseData[hotKey];
}
const items = parsedData.map((item) => ({
title: item.title,
link: `http://new.xianbao.fun${item.url}`,
description: item.content,
@ -130,5 +138,5 @@ const CATEGORIES = [
{ id: 'qqjishu', fullName: '技术QQ网', pushPath: 'push_6' },
{ id: 'yyok', fullName: 'YYOK大全', pushPath: 'push_7' },
{ id: 'huodong', fullName: '活动资讯网', pushPath: 'push_8' },
{ id: 'maifei', fullName: '免费赚钱中心', pushPath: 'push_9' },
{ id: 'mianfei', fullName: '免费赚钱中心', pushPath: 'push_9' },
];