diff --git a/src/core.ts b/src/core.ts index ca9d87d..64519c7 100644 --- a/src/core.ts +++ b/src/core.ts @@ -1,4 +1,3 @@ -import { logToCF } from "./utils/httpClient"; import type { Platform, PlatformSearchResult, StreamProgress, StreamResult } from "./types"; import platformsGal from "./platforms/gal"; import platformsPatch from "./platforms/patch"; @@ -24,10 +23,10 @@ export async function handleSearchRequestStream( zypassword: string = "" // 添加 zypassword 参数 ): Promise { // 记录搜索关键词 - logToCF({ + console.log(JSON.stringify({ message: `搜索关键词: ${game}`, level: "info", - }); + })); const encoder = new TextEncoder(); const total = platforms.length; let completed = 0; @@ -46,10 +45,10 @@ export async function handleSearchRequestStream( if (result.count > 0 || result.error) { if (result.error) { // 记录平台错误 - logToCF({ + console.log(JSON.stringify({ message: `平台 ${result.name} 搜索错误: ${result.error}`, level: "error", - }); + })); } const streamResult: StreamResult = { name: result.name, @@ -67,10 +66,10 @@ export async function handleSearchRequestStream( // 记录平台内部的未知错误 console.error(`Error searching platform ${platform.name}:`, e); // 记录平台内部的未知错误 - logToCF({ + console.log(JSON.stringify({ message: `平台 ${platform.name} 内部错误: ${e instanceof Error ? e.message : String(e)}`, level: "error", - }); + })); const progress: StreamProgress = { completed, total }; await writer.write(encoder.encode(formatStreamEvent({ progress }))); } diff --git a/src/platforms/gal/xxacg.ts b/src/platforms/gal/xxacg.ts index c5f2314..1f762cb 100644 --- a/src/platforms/gal/xxacg.ts +++ b/src/platforms/gal/xxacg.ts @@ -38,11 +38,6 @@ async function searchXxacg(game: string): Promise { } } - if (items.length === 0 && html.length > 0) { - // 如果没有匹配项,但我们确实收到了 HTML,这可能意味着页面结构已更改。 - // 将部分 HTML 包含在错误中以供调试。 - throw new Error(`No matches found on page. HTML starts with: ${html.substring(0, 500)}`); - } searchResult.items = items; searchResult.count = items.length; diff --git a/src/utils/httpClient.ts b/src/utils/httpClient.ts index 4fcf320..81da63f 100644 --- a/src/utils/httpClient.ts +++ b/src/utils/httpClient.ts @@ -38,23 +38,4 @@ export async function fetchClient( } finally { clearTimeout(timeoutId); } -} -/** - * 向 Cloudflare 发送日志。 - * @param data 要记录的数据对象。 - */ -export async function logToCF(data: object) { - // 在此处添加 console.log,以便在 Cloudflare 控制台也能看到日志 - console.log(JSON.stringify(data)); - try { - await fetch("https://log.gal.homes", { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify(data), - }); - } catch (error) { - console.error("Failed to log to Cloudflare:", error); - } } \ No newline at end of file