mirror of
https://github.com/Moe-Sakura/Wrangler-API.git
synced 2026-03-15 04:13:18 +08:00
feat: 配置Vercel部署,README更新
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -12,4 +12,5 @@ node_modules/
|
||||
|
||||
# Environment variables
|
||||
.env
|
||||
.env.*
|
||||
.env.*
|
||||
.vercel
|
||||
|
||||
351
README.md
351
README.md
@@ -1,266 +1,227 @@
|
||||
<div align="center">
|
||||
|
||||
# Wrangler-API
|
||||
# 🔍 SearchGal · Gal资源聚合搜索工具
|
||||
|
||||
[](https://workers.cloudflare.com/)
|
||||
[](https://www.typescriptlang.org/)
|
||||
[](./LICENSE)
|
||||
🚀 **极速响应** | 🌊 **SSE 流式传输** | 🎮 **32+ 平台聚合** | ☁️ **边缘部署**
|
||||
|
||||
|
||||
**Cloudflare Workers 版 SearchGal 聚合搜索 API**
|
||||
|
||||
🚀 **极速响应** | 🌊 **SSE 流式传输** | 🎮 **多平台聚合**
|
||||
|
||||
[快速部署](#quick-start) • [API 文档](#api-doc) • [开发者接入指南](#dev-guide)
|
||||
[前端项目](https://github.com/Moe-Sakura/frontend) • [在线预览](#-在线预览) • [快速部署](#-快速部署) • [API 文档](#-api-文档) • [开发者接入](#-开发者接入指南)
|
||||
|
||||
</div>
|
||||
|
||||
---
|
||||
|
||||
## 📖 简介
|
||||
## 🖥️ 在线预览
|
||||
|
||||
本项目是一个基于 Cloudflare Workers 的聚合搜索 API,专为 Galgame 资源搜索设计。它提供 `/gal` 和 `/patch` 两个主要入口,接收游戏名称后,通过 Server-Sent Events (SSE) 流式返回各大 Galgame 论坛和资源站的搜索结果。
|
||||
🌐 **预览地址**: [SearchGal.homes](https://searchgal.homes)
|
||||
|
||||
<a id="quick-start"></a>
|
||||
| 电脑端 | 移动端 |
|
||||
| :------------------------: | :----------------------: |
|
||||
|  |  |
|
||||
|
||||
---
|
||||
|
||||
## 🌟 项目亮点
|
||||
|
||||
| 特性 | 说明 |
|
||||
|:----:|------|
|
||||
| ✅ **多端适配** | PC/移动端完美适配,PC端支持展示游戏封面、介绍、标签 |
|
||||
| 💡 **多源聚合** | 实时聚合 **30+** Gal资源平台 + **2+** 补丁站 |
|
||||
| 🏷️ **智能标注** | 自动标注:🟢免登录 / 🟡需魔法 / ⚪特殊条件 |
|
||||
| ☁️ **边缘部署** | 支持 Cloudflare Workers / Vercel Edge 等平台 |
|
||||
| 🌊 **流式响应** | SSE 实时返回搜索结果,无需等待全部完成 |
|
||||
|
||||
> 📜 **历史版本**: Python 版本请查看 [`legacy-python`](../../tree/legacy-python) 分支 **(已停止维护)**
|
||||
|
||||
---
|
||||
|
||||
## 🚀 已收录平台
|
||||
|
||||
### 🟢 免登录直链下载
|
||||
|
||||
[](https://gal.saop.cc/)
|
||||
[](https://shinnku.com)
|
||||
[](https://www.touchgal.us/)
|
||||
[](https://www.galgamex.net/)
|
||||
[](https://www.ttloli.com/)
|
||||
[](https://gallibrary.pw/)
|
||||
[](https://game.acgs.one/)
|
||||
[](https://spare.qingju.org/)
|
||||
[](https://www.kungal.com/zh-cn/)
|
||||
[](https://www.nullcloud.top/)
|
||||
[](https://zi0.cc/)
|
||||
[](https://www.limulu.moe/)
|
||||
[](https://catcat.cloud/)
|
||||
[](https://seve.yugal.cc/)
|
||||
[](https://inarigal.com/)
|
||||
[](https://koyso.to/)
|
||||
[](https://yinghu.netlify.app/)
|
||||
[](https://www.ggbases.com/)
|
||||
[](https://www.sayafx.vip/)
|
||||
[](https://05fx.022016.xyz/)
|
||||
[](https://galzy.eu.org)
|
||||
|
||||
#### 🟢 补丁站
|
||||
|
||||
[](https://www.moyu.moe/)
|
||||
[](https://2dfan.com)
|
||||
|
||||
### ⚪ 需登录/特殊条件
|
||||
|
||||
[](https://lzacg.org/)
|
||||
[](https://www.fufugal.com/)
|
||||
[](https://acgyyg.ru/)
|
||||
[](https://www.nyantaku.com/)
|
||||
|
||||
### 🟡 需魔法访问
|
||||
|
||||
[](https://www.vikacg.com/)
|
||||
[](https://www.gogalgame.com/)
|
||||
[](https://www.tiangal.com/)
|
||||
[](https://res.nyne.dev/)
|
||||
[](https://xxacg.net/)
|
||||
|
||||
---
|
||||
|
||||
## 🚀 快速部署
|
||||
|
||||
### ☁️ 一键云部署
|
||||
|
||||
[](https://deploy.workers.cloudflare.com/?url=https://github.com/Moe-Sakura/Wrangler-API)
|
||||
[](https://app.koyeb.com/deploy?type=git&name=wrangler-api&repository=github.com/Moe-Sakura/Wrangler-API&branch=main&builder=dockerfile&ports=8787;http;/)
|
||||
[](https://deploy.cloud.run?git_repo=https://github.com/Moe-Sakura/Wrangler-API&revision=main)
|
||||
[](https://vercel.com/new/clone?repository-url=https://github.com/Moe-Sakura/SearchGal)
|
||||
|
||||
### 🧭 服务器性能参考(硬件配置)
|
||||
[](https://app.netlify.com/start/deploy?repository=https://github.com/Moe-Sakura/SearchGal)
|
||||
|
||||
> 以下为通用建议,适用于自建部署或容器化运行场景。此项目主要消耗在外部请求与解析,内存压力通常较低。
|
||||
[](https://deploy.workers.cloudflare.com/?url=https://github.com/Moe-Sakura/SearchGal)
|
||||
|
||||
| 档位 | CPU | 内存 | 网络 | 适用场景 |
|
||||
| :--- | :--- | :--- | :--- | :--- |
|
||||
| 最低 | 1 vCPU | 512 MB–1 GB | 1-5 Mbps | 低并发 |
|
||||
| 推荐 | 2 vCPU | 1–2 GB | 5-20 Mbps | 中小规模并发 |
|
||||
| 高并发 | 4 vCPU+ | 2–4 GB | 20 Mbps+ | 高并发 |
|
||||
[](https://app.koyeb.com/deploy?type=git&name=searchgal&repository=github.com/Moe-Sakura/SearchGal&branch=main&builder=dockerfile&ports=8787;http;/)
|
||||
|
||||
---
|
||||
### 🧭 服务器配置参考
|
||||
|
||||
### 环境准备
|
||||
| 档位 | CPU | 内存 | 适用场景 |
|
||||
|:----:|:---:|:----:|:--------:|
|
||||
| 最低 | 1 vCPU | 512MB–1GB | 低并发 |
|
||||
| 推荐 | 2 vCPU | 1–2GB | 中小规模 |
|
||||
| 高并发 | 4+ vCPU | 2–4GB | 高并发 |
|
||||
|
||||
- **Node.js**: 推荐最新 LTS 版本 (Windows 用户必需)
|
||||
- **pnpm**: 包管理工具
|
||||
- **Cloudflare 账号**: 用于发布 (本地开发可选)
|
||||
|
||||
### 安装依赖
|
||||
### 💻 本地开发
|
||||
|
||||
```bash
|
||||
# 安装 pnpm (如果未安装)
|
||||
npm install -g pnpm
|
||||
|
||||
# 安装项目依赖
|
||||
pnpm install
|
||||
pnpm install # 安装依赖
|
||||
pnpm wrangler dev # 启动开发服务器
|
||||
```
|
||||
|
||||
### 本地开发
|
||||
### 🐳 Docker 部署
|
||||
|
||||
```bash
|
||||
# 启动本地开发服务器 (模拟 Cloudflare 环境)
|
||||
npx wrangler dev
|
||||
|
||||
# 纯本地模式 (不连接 Cloudflare)
|
||||
npx wrangler dev --local
|
||||
```
|
||||
|
||||
### Docker / Podman 部署
|
||||
|
||||
如果您更喜欢使用容器化部署:
|
||||
|
||||
```bash
|
||||
# 启动服务
|
||||
podman-compose up -d
|
||||
|
||||
# 查看日志
|
||||
podman-compose logs -f
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
<a id="api-doc"></a>
|
||||
|
||||
## 📡 API 文档
|
||||
|
||||
### 搜索接口
|
||||
### 接口说明
|
||||
|
||||
- **路径**: `POST /gal` (游戏) 或 `POST /patch` (补丁)
|
||||
- **Content-Type**: `multipart/form-data` 或 `application/json`
|
||||
- **参数**: `game` (string) - 搜索关键词
|
||||
| 方法 | 路径 | 说明 |
|
||||
|:----:|------|------|
|
||||
| POST | `/gal` | 搜索游戏资源 |
|
||||
| POST | `/patch` | 搜索补丁资源 |
|
||||
|
||||
### 响应格式
|
||||
**请求参数**: `game` (string) - 搜索关键词
|
||||
**Content-Type**: `multipart/form-data` 或 `application/json`
|
||||
|
||||
响应采用 **Server-Sent Events (SSE)** 流式传输,每行是一个 JSON 对象。
|
||||
|
||||
**示例流:**
|
||||
### 响应格式 (SSE 流式)
|
||||
|
||||
```json
|
||||
{"total": 10} // 1. 预计总搜索源数量
|
||||
{"progress": {"completed": 1, "total": 10}} // 2. 进度更新
|
||||
{"progress": {"completed": 2, "total": 10}, "result": { ... }} // 3. 搜索结果 (见下文)
|
||||
{"done": true} // 4. 结束信号
|
||||
{"total": 10} // 总搜索源数量
|
||||
{"progress": {"completed": 1, "total": 10}} // 进度更新
|
||||
{"progress": {...}, "result": {...}} // 搜索结果
|
||||
{"done": true} // 结束信号
|
||||
```
|
||||
|
||||
**Result 对象结构:**
|
||||
### 🏷️ 标签说明
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "某平台",
|
||||
"color": "lime",
|
||||
"tags": ["NoReq"],
|
||||
"items": [
|
||||
{
|
||||
"name": "游戏标题",
|
||||
"url": "https://example.com/detail/123"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### 🏷️ 标签说明 (Tags)
|
||||
|
||||
| 标签 | 含义 | 说明 |
|
||||
| :--- | :--- | :--- |
|
||||
| `NoReq` | **无门槛** | 无需登录、无需回复即可获取资源 |
|
||||
| `Login` | **需登录** | 需要注册并登录账号 |
|
||||
| `LoginPay` | **需付费** | 需要登录且消耗积分/货币 |
|
||||
| `LoginRep` | **需回复** | 需要登录并回复/评论 |
|
||||
| `Rep` | **需回复** | 需回复但无需登录 (较少见) |
|
||||
| `SuDrive` | **自建盘** | 站点自建网盘,速度通常较快 |
|
||||
| `NoSplDrive` | **不限速** | 使用 OneDrive, Mega, Google Drive 等不限速网盘 |
|
||||
| `SplDrive` | **限速盘** | 使用 百度网盘, 夸克, 天翼 等可能限速的网盘 |
|
||||
| `MixDrive` | **混合盘** | 包含多种网盘链接 |
|
||||
| `BTmag` | **BT/磁力** | 提供种子或磁力链接 |
|
||||
| `magic` | **魔法** | 站点可能被墙,需要代理访问 |
|
||||
| 标签 | 含义 | 标签 | 含义 |
|
||||
|:----:|:----:|:----:|:----:|
|
||||
| `NoReq` | 无门槛 | `Login` | 需登录 |
|
||||
| `LoginPay` | 需付费 | `LoginRep` | 需回复 |
|
||||
| `SuDrive` | 自建盘 | `NoSplDrive` | 不限速盘 |
|
||||
| `SplDrive` | 限速盘 | `MixDrive` | 混合盘 |
|
||||
| `BTmag` | BT/磁力 | `magic` | 需魔法 |
|
||||
|
||||
---
|
||||
|
||||
## 🛠️ 使用指南
|
||||
|
||||
<a id="dev-guide"></a>
|
||||
| 步骤 | 技巧 |
|
||||
|:----:|------|
|
||||
| 🔍 **精准搜索** | 使用中文名效果最佳,如 `Senren*Banka` → `千恋万花` → `千恋` |
|
||||
| 🎯 **结果筛选** | 优先选择 🟢绿色标签 (免登录),🟡金色需代理,⚪白色需对应条件 |
|
||||
| ⬇️ **下载建议** | 推荐 IDM/FDM 加速,遇 Cloudflare 验证耐心等待 |
|
||||
|
||||
## 🤝 面向 Galgame 网站开发者:如何接入
|
||||
---
|
||||
|
||||
如果您是 Galgame 资源站的站长或开发者,欢迎将您的站点接入到本聚合搜索中。接入过程非常简单,只需三步。
|
||||
## 🤝 开发者接入指南
|
||||
|
||||
### 1. 创建适配器文件
|
||||
想要将您的站点接入聚合搜索?只需三步:
|
||||
|
||||
在 `src/platforms/gal/` 目录下创建一个新的 TypeScript 文件,例如 `MyGalSite.ts`。
|
||||
|
||||
### 2. 实现 Platform 接口
|
||||
|
||||
复制以下模板代码,并根据您站点的搜索逻辑进行修改:
|
||||
**1. 创建适配器** - 在 `src/platforms/gal/` 下创建 `YourSite.ts`
|
||||
|
||||
**2. 实现接口**
|
||||
```typescript
|
||||
import { fetchClient } from "../../utils/httpClient";
|
||||
import type { Platform, PlatformSearchResult, SearchResultItem } from "../../types";
|
||||
import type { Platform, PlatformSearchResult } from "../../types";
|
||||
|
||||
// 1. 定义站点配置
|
||||
const SITE_NAME = "我的Gal站";
|
||||
const API_URL = "https://api.mygalsite.com/search"; // 您的搜索接口或页面URL
|
||||
const DETAIL_BASE_URL = "https://mygalsite.com/game/";
|
||||
|
||||
// 2. 定义接口返回类型 (根据实际情况修改)
|
||||
interface MySiteResponse {
|
||||
code: number;
|
||||
data: {
|
||||
id: string;
|
||||
title: string;
|
||||
}[];
|
||||
}
|
||||
|
||||
// 3. 实现搜索函数
|
||||
async function searchMySite(game: string): Promise<PlatformSearchResult> {
|
||||
const result: PlatformSearchResult = { count: 0, items: [] };
|
||||
|
||||
try {
|
||||
// 构造请求
|
||||
const url = new URL(API_URL);
|
||||
url.searchParams.set("q", game); // 根据实际参数名修改
|
||||
|
||||
// 发起请求 (fetchClient 已封装 User-Agent 等通用头)
|
||||
const response = await fetchClient(url);
|
||||
|
||||
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
||||
|
||||
// 解析数据 (如果是 HTML 页面,可以使用正则表达式提取)
|
||||
const data = await response.json() as MySiteResponse;
|
||||
|
||||
// 转换为统一格式
|
||||
const items: SearchResultItem[] = data.data.map(item => ({
|
||||
name: item.title.trim(),
|
||||
url: `${DETAIL_BASE_URL}${item.id}`,
|
||||
}));
|
||||
|
||||
result.items = items;
|
||||
result.count = items.length;
|
||||
|
||||
} catch (error) {
|
||||
// 错误处理
|
||||
result.error = error instanceof Error ? error.message : "Unknown error";
|
||||
result.count = -1; // -1 表示搜索出错
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// 4. 导出配置对象
|
||||
const MyGalSite: Platform = {
|
||||
name: SITE_NAME,
|
||||
color: "blue", // 也就是前端显示的颜色,支持 hex 或颜色名
|
||||
tags: ["NoReq", "SuDrive"], // 标签见上文说明
|
||||
magic: false, // 是否需要代理访问
|
||||
search: searchMySite,
|
||||
const YourSite: Platform = {
|
||||
name: "站点名称",
|
||||
color: "lime",
|
||||
tags: ["NoReq"],
|
||||
search: async (game) => {
|
||||
// 实现搜索逻辑
|
||||
return { count: 0, items: [] };
|
||||
},
|
||||
};
|
||||
|
||||
export default MyGalSite;
|
||||
export default YourSite;
|
||||
```
|
||||
|
||||
### 3. 注册适配器
|
||||
|
||||
无需手动修改代码,只需运行以下命令即可自动注册所有适配器:
|
||||
|
||||
**3. 注册 & 提交**
|
||||
```bash
|
||||
npm run generate
|
||||
# 或者
|
||||
pnpm run generate
|
||||
pnpm run generate # 自动注册
|
||||
git push && PR # 提交贡献
|
||||
```
|
||||
|
||||
该脚本会自动扫描 `src/platforms/gal/` 目录下的文件并更新索引。
|
||||
---
|
||||
|
||||
### 4. 提交 Pull Request
|
||||
## ⚠️ 注意事项
|
||||
|
||||
完成上述步骤后,请将您的更改提交到 GitHub:
|
||||
|
||||
1. Fork 本仓库
|
||||
2. 提交您的更改 (`git commit -m "feat: add MyGalSite adapter"`)
|
||||
3. 推送到您的 Fork (`git push origin main`)
|
||||
4. 在 GitHub 上发起 Pull Request
|
||||
|
||||
我们会尽快审核并合并您的代码,感谢您的贡献!🎉
|
||||
**📢 广告白名单**: 本站无广告,但收录的资源站建站不易,请加入广告白名单支持站长!<br>
|
||||
**✉️ 写给站长**: 本程序仅提供游戏发布页链接(非下载链接),不提供解压码。如不想被搜索,请过滤 UA 含 `Searchgal` 的请求。<br>
|
||||
**🔐 安全声明**: 本工具仅提供搜索聚合,不托管资源,请自行校验文件安全性。<br>
|
||||
|
||||
---
|
||||
|
||||
## 📂 项目结构
|
||||
|
||||
```text
|
||||
```
|
||||
src/
|
||||
├── index.ts # Worker 入口,路由定义
|
||||
├── core.ts # 核心逻辑:并行搜索与 SSE 组装
|
||||
├── types.ts # 类型定义
|
||||
├── utils/
|
||||
│ └── httpClient.ts # 统一 HTTP 请求封装
|
||||
└── platforms/
|
||||
├── gal/ # GAL 游戏平台适配器集合
|
||||
│ ├── index.ts # GAL 平台注册表
|
||||
│ └── ... # 各平台实现
|
||||
└── patch/ # 补丁平台适配器集合
|
||||
├── index.ts # Worker 入口
|
||||
├── core.ts # 核心搜索逻辑
|
||||
├── types.ts # 类型定义
|
||||
└── platforms/ # 平台适配器
|
||||
api/
|
||||
└── [...slug].ts # Vercel Edge 入口
|
||||
```
|
||||
|
||||
## 📜 许可证
|
||||
---
|
||||
|
||||
[MIT](./LICENSE) © Wrangler-API
|
||||
## 🌱 支持正版
|
||||
|
||||
本工具旨在提供资源索引便利,**请通过 Steam/DLSite 等正规渠道支持开发者!**
|
||||
|
||||
---
|
||||
|
||||
<div align="center">
|
||||
|
||||
**欢迎各位 GalGame 爱好者优化本项目 ❤️**
|
||||
|
||||
[MIT License](./LICENSE) © SearchGal
|
||||
|
||||
</div>
|
||||
|
||||
BIN
docs/img/pc_search_view.png
Normal file
BIN
docs/img/pc_search_view.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.5 MiB |
BIN
docs/img/phone_search_view.jpg
Normal file
BIN
docs/img/phone_search_view.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 478 KiB |
@@ -12,6 +12,8 @@
|
||||
"description": "",
|
||||
"devDependencies": {
|
||||
"@cloudflare/workers-types": "^4.20250821.0",
|
||||
"@types/node": "^25.0.9",
|
||||
"@vercel/node": "^5.5.24",
|
||||
"typescript": "^5.9.2",
|
||||
"wrangler": "^4.31.0"
|
||||
}
|
||||
|
||||
1138
pnpm-lock.yaml
generated
1138
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -54,7 +54,8 @@ export default {
|
||||
const url = new URL(request.url);
|
||||
|
||||
if (url.pathname === '/') {
|
||||
return Response.redirect('https://searchgal.homes', 302);
|
||||
const origin = url.origin;
|
||||
return Response.redirect(`https://searchgal.homes?api=${encodeURIComponent(origin)}`, 302);
|
||||
}
|
||||
|
||||
if (request.method === "OPTIONS") {
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
"target": "esnext",
|
||||
"module": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"lib": ["esnext"],
|
||||
"lib": [
|
||||
"esnext"
|
||||
],
|
||||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
@@ -11,7 +13,13 @@
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"noEmit": true,
|
||||
"types": ["@cloudflare/workers-types"]
|
||||
"types": [
|
||||
"@cloudflare/workers-types",
|
||||
"node"
|
||||
]
|
||||
},
|
||||
"include": ["src"]
|
||||
"include": [
|
||||
"src",
|
||||
"api"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user