Files
2026-06-23 21:57:39 +08:00

159 lines
1.9 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# CryptoCoin 币安 API 代理Cloudflare Worker
当本机无法直连 `api.binance.com` 时,可通过此 Worker 转发行情请求。
## 部署
1. 安装 [Node.js](https://nodejs.org/) 与 Cloudflare 账号
2. 在本目录执行:
```bash
npm install
npx wrangler login
npm run deploy
```
3. 记下部署后的地址,例如:
```
https://cryptocoin-binance-proxy.你的用户名.workers.dev
```
4. 在 CryptoCoin 中配置(二选一):
**方式 A托盘菜单**
- 托盘右键 → **行情源** → 带 **✓** 的项为当前模式
- **CF Worker 代理** 需在设置文件中已填写 `proxyBaseUrl`
-**直连** 不会删除已保存的代理地址
**方式 B编辑设置文件**
路径(与 **CryptoCoin.exe** 同级的 `data` 目录):
```
D:\WindowsApp\CryptoCoin\data\settings.json
```
代理模式:
```json
{
"enabled": ["BTCUSDT", "ETHUSDT"],
"proxyBaseUrl": "https://cryptocoin-binance-proxy.你的用户名.workers.dev",
"useProxy": true,
"refreshIntervalMs": 5000
}
```
直连模式:
```json
{
"enabled": ["BTCUSDT", "ETHUSDT"],
"proxyBaseUrl": "https://cryptocoin-binance-proxy.你的用户名.workers.dev",
"useProxy": false,
"refreshIntervalMs": 5000
}
```
`refreshIntervalMs` 可选值毫秒3000、5000、10000、30000、60000、180000、300000、600000也可在托盘 **刷新间隔** 中切换。
改完后重启应用,或在托盘切换一次「直连 / 代理」。
**Release 用户**:修改代码后需执行 `npm run tauri build` 并重新安装,否则仍为旧版行为。
## 接口说明
- `GET /health` — 健康检查
- `GET /api/v3/ticker/24hr?symbols=...` — 转发至币安同名接口
仅允许 `/api/` 路径,其它路径返回 404。
## 本地调试
```bash
npm run dev
```
默认 `http://127.0.0.1:8787`,可浏览器访问 `/health` 验证。