mirror of
https://github.com/Moe-Sakura/Wrangler-API.git
synced 2026-03-16 04:23:17 +08:00
- 引入平台标签系统,提供详细的平台特性说明。 - 重构搜索结果初始化,避免平台名称重复定义。 - 修正核心搜索错误日志,确保正确记录平台名称。 - 移除两个Galgame平台:TianYouErCiYuan(收费)和YingZhiGuang(网站转型)。 - 更新部分平台的颜色、魔法属性和标签信息。
66 lines
1.5 KiB
TypeScript
66 lines
1.5 KiB
TypeScript
import { fetchClient } from "../../utils/httpClient";
|
|
import type { Platform, PlatformSearchResult, SearchResultItem } from "../../types";
|
|
|
|
const API_URL = "https://www.fufugal.com/so";
|
|
const BASE_URL = "https://www.fufugal.com/detail";
|
|
|
|
interface FuFuACGItem {
|
|
game_id: number;
|
|
game_name: string;
|
|
}
|
|
|
|
interface FuFuACGResponse {
|
|
obj: FuFuACGItem[];
|
|
}
|
|
|
|
async function searchFuFuACG(game: string): Promise<PlatformSearchResult> {
|
|
const searchResult: PlatformSearchResult = {
|
|
count: 0,
|
|
items: [],
|
|
};
|
|
|
|
try {
|
|
const url = new URL(API_URL);
|
|
url.searchParams.set("query", game);
|
|
|
|
const response = await fetchClient(url, {
|
|
headers: {
|
|
"Accept": "application/json, text/plain, */*",
|
|
}
|
|
});
|
|
|
|
if (!response.ok) {
|
|
throw new Error(`资源平台 SearchAPI 响应异常状态码 ${response.status}`);
|
|
}
|
|
|
|
const data = await response.json() as FuFuACGResponse;
|
|
|
|
const items: SearchResultItem[] = data.obj.map(item => ({
|
|
name: item.game_name,
|
|
url: `${BASE_URL}?id=${item.game_id}`,
|
|
}));
|
|
|
|
searchResult.items = items;
|
|
searchResult.count = items.length;
|
|
|
|
} catch (error) {
|
|
if (error instanceof Error) {
|
|
searchResult.error = error.message;
|
|
} else {
|
|
searchResult.error = "An unknown error occurred";
|
|
}
|
|
searchResult.count = -1;
|
|
}
|
|
|
|
return searchResult;
|
|
}
|
|
|
|
const FuFuACG: Platform = {
|
|
name: "FuFuACG",
|
|
color: "white",
|
|
tags: ["LoginPay"],
|
|
magic: false,
|
|
search: searchFuFuACG,
|
|
};
|
|
|
|
export default FuFuACG; |