Просмотр исходного кода

chore: format code (dev-84c05c1)

github-actions[bot] 3 месяцев назад
Родитель
Сommit
3d715363dd
2 измененных файлов с 54 добавлено и 54 удалено
  1. 27 27
      README.en.md
  2. 27 27
      README.md

+ 27 - 27
README.en.md

@@ -87,12 +87,12 @@ Once started:
 
 ## 🖼️ Screenshots
 
-| Feature | Screenshot | Description |
-| --- | --- | --- |
-| Dashboard | ![Dashboard](public/readme/首页.png) | Aggregates request volume, spending, active sessions, and time-series distribution for instant situational awareness. |
-| Provider management | ![Provider Management](public/readme/供应商管理.png) | Configure weight, cost multiplier, concurrency caps, proxies, and model redirection per vendor for precise routing. |
-| Logs & audit | ![Logs](public/readme/日志.png) | Unified request log with filters for time/user/provider/model plus token, cost, and cache-hit details. |
-| Leaderboard | ![Leaderboard](public/readme/排行榜.png) | Ranks users by requests, tokens, and spending to support chargeback and usage governance. |
+| Feature             | Screenshot                                           | Description                                                                                                           |
+| ------------------- | ---------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
+| Dashboard           | ![Dashboard](public/readme/首页.png)                 | Aggregates request volume, spending, active sessions, and time-series distribution for instant situational awareness. |
+| Provider management | ![Provider Management](public/readme/供应商管理.png) | Configure weight, cost multiplier, concurrency caps, proxies, and model redirection per vendor for precise routing.   |
+| Logs & audit        | ![Logs](public/readme/日志.png)                      | Unified request log with filters for time/user/provider/model plus token, cost, and cache-hit details.                |
+| Leaderboard         | ![Leaderboard](public/readme/排行榜.png)             | Ranks users by requests, tokens, and spending to support chargeback and usage governance.                             |
 
 ## 🏗️ Architecture
 
@@ -171,40 +171,40 @@ Docker Compose is the **preferred deployment method** — it automatically provi
 
 ## ⚙️ Configuration
 
-| Variable | Default | Description |
-| --- | --- | --- |
-| `ADMIN_TOKEN` | `change-me` | Admin console token — must be updated before deployment. |
-| `DSN` | - | PostgreSQL connection string, e.g., `postgres://user:pass@host:5432/db`. |
-| `AUTO_MIGRATE` | `true` | Executes Drizzle migrations on startup; consider disabling in production for manual control. |
-| `REDIS_URL` | `redis://localhost:6379` | Redis endpoint, supports `rediss://` for TLS providers. |
-| `ENABLE_RATE_LIMIT` | `true` | Toggles multi-dimensional rate limiting; Fail-Open handles Redis outages gracefully. |
-| `SESSION_TTL` | `300` | Session cache window (seconds) that drives vendor reuse. |
-| `ENABLE_SECURE_COOKIES` | `true` | Browsers require HTTPS for Secure cookies; set to `false` when serving plain HTTP outside localhost. |
-| `ENABLE_CIRCUIT_BREAKER_ON_NETWORK_ERRORS` | `false` | When `true`, network errors also trip the circuit breaker for quicker isolation. |
-| `APP_PORT` | `23000` | Production port (override via container or process manager). |
-| `APP_URL` | empty | Populate to expose correct `servers` entries in OpenAPI docs. |
+| Variable                                   | Default                  | Description                                                                                          |
+| ------------------------------------------ | ------------------------ | ---------------------------------------------------------------------------------------------------- |
+| `ADMIN_TOKEN`                              | `change-me`              | Admin console token — must be updated before deployment.                                             |
+| `DSN`                                      | -                        | PostgreSQL connection string, e.g., `postgres://user:pass@host:5432/db`.                             |
+| `AUTO_MIGRATE`                             | `true`                   | Executes Drizzle migrations on startup; consider disabling in production for manual control.         |
+| `REDIS_URL`                                | `redis://localhost:6379` | Redis endpoint, supports `rediss://` for TLS providers.                                              |
+| `ENABLE_RATE_LIMIT`                        | `true`                   | Toggles multi-dimensional rate limiting; Fail-Open handles Redis outages gracefully.                 |
+| `SESSION_TTL`                              | `300`                    | Session cache window (seconds) that drives vendor reuse.                                             |
+| `ENABLE_SECURE_COOKIES`                    | `true`                   | Browsers require HTTPS for Secure cookies; set to `false` when serving plain HTTP outside localhost. |
+| `ENABLE_CIRCUIT_BREAKER_ON_NETWORK_ERRORS` | `false`                  | When `true`, network errors also trip the circuit breaker for quicker isolation.                     |
+| `APP_PORT`                                 | `23000`                  | Production port (override via container or process manager).                                         |
+| `APP_URL`                                  | empty                    | Populate to expose correct `servers` entries in OpenAPI docs.                                        |
 
 > Boolean values should be `true/false` or `1/0` without quotes; otherwise Zod may coerce strings incorrectly. See `.env.example` for the full list.
 
 ## ❓ FAQ
 
-1. **Database connection failures**  
-   - Verify the `DSN` format and credentials; use service names (e.g., `postgres:5432`) within Docker.  
+1. **Database connection failures**
+   - Verify the `DSN` format and credentials; use service names (e.g., `postgres:5432`) within Docker.
    - Inspect `docker compose ps` or local PostgreSQL status, and use `make db-shell` for deeper checks.
 
-2. **What if Redis goes offline?**  
+2. **What if Redis goes offline?**
    - The platform uses a fail-open policy: rate limiting and session metrics degrade gracefully while requests continue flowing. Monitor logs for Redis errors and restore the service asap.
 
-3. **Circuit breaker keeps opening**  
-   - Inspect `[CircuitBreaker]` logs to see whether repeated 4xx/5xx or network errors triggered it.  
+3. **Circuit breaker keeps opening**
+   - Inspect `[CircuitBreaker]` logs to see whether repeated 4xx/5xx or network errors triggered it.
    - Check provider health in the admin console and wait 30 minutes or restart the app to reset state.
 
-4. **“No provider available” errors**  
-   - Ensure providers are enabled, have reasonable weights/priorities, and haven’t hit concurrency or spend caps.  
+4. **“No provider available” errors**
+   - Ensure providers are enabled, have reasonable weights/priorities, and haven’t hit concurrency or spend caps.
    - Review the decision-chain log to confirm whether breakers or proxy failures removed them.
 
-5. **Proxy configuration issues**  
-   - Make sure URLs include a protocol (`http://`, `socks5://`, etc.) and validate via the “Test Connection” button in the UI.  
+5. **Proxy configuration issues**
+   - Make sure URLs include a protocol (`http://`, `socks5://`, etc.) and validate via the “Test Connection” button in the UI.
    - If `proxy_fallback_to_direct` is enabled, confirm via logs that the system retried without the proxy when failures occur.
 
 ## 🤝 Contributing

+ 27 - 27
README.md

@@ -87,12 +87,12 @@ Claude Code Hub 通过 Next.js 15 + Hono + PostgreSQL + Redis 组合,实现 Cl
 
 ## 🖼️ 界面预览 Screenshots
 
-| 功能 | 截图 | 说明 |
-| --- | --- | --- |
-| 仪表盘 | ![Dashboard](public/readme/首页.png) | 汇总调用量、成本、活跃 Session 与时间分布,实时洞察整体使用情况。 |
-| 供应商管理 | ![Provider Management](public/readme/供应商管理.png) | 为每个供应商配置权重、成本系数、并发限制、代理及模型重定向,实现精细调度。 |
-| 日志与审计 | ![Logs](public/readme/日志.png) | 统一查询请求日志,支持时间/用户/供应商/模型筛选,查看 Token、成本与缓冲命中情况。 |
-| 排行榜 | ![Leaderboard](public/readme/排行榜.png) | 按用户统计请求数、Token 与成本,用于费用分摊与用量治理。 |
+| 功能       | 截图                                                 | 说明                                                                              |
+| ---------- | ---------------------------------------------------- | --------------------------------------------------------------------------------- |
+| 仪表盘     | ![Dashboard](public/readme/首页.png)                 | 汇总调用量、成本、活跃 Session 与时间分布,实时洞察整体使用情况。                 |
+| 供应商管理 | ![Provider Management](public/readme/供应商管理.png) | 为每个供应商配置权重、成本系数、并发限制、代理及模型重定向,实现精细调度。        |
+| 日志与审计 | ![Logs](public/readme/日志.png)                      | 统一查询请求日志,支持时间/用户/供应商/模型筛选,查看 Token、成本与缓冲命中情况。 |
+| 排行榜     | ![Leaderboard](public/readme/排行榜.png)             | 按用户统计请求数、Token 与成本,用于费用分摊与用量治理。                          |
 
 ## 🏗️ 架构说明 Architecture
 
@@ -171,40 +171,40 @@ Docker Compose 是**首选部署方式**,自动配置数据库、Redis 和应
 
 ## ⚙️ 配置说明 Configuration
 
-| 变量 | 默认值 | 说明与建议 |
-| --- | --- | --- |
-| `ADMIN_TOKEN` | `change-me` | 后台登录令牌,部署前必须修改。 |
-| `DSN` | - | PostgreSQL 连接串,如 `postgres://user:pass@host:5432/db`. |
-| `AUTO_MIGRATE` | `true` | 启动时自动执行 Drizzle 迁移;生产环境可关闭以人工控制。 |
-| `REDIS_URL` | `redis://localhost:6379` | Redis 地址,支持 `rediss://` 用于 TLS。 |
-| `ENABLE_RATE_LIMIT` | `true` | 控制多维限流开关;Fail-Open 策略在 Redis 不可用时自动降级。 |
-| `SESSION_TTL` | `300` | Session 缓存时间(秒),影响供应商复用策略。 |
-| `ENABLE_SECURE_COOKIES` | `true` | 仅 HTTPS 场景能设置 Secure Cookie;HTTP 访问(非 localhost)需改为 `false`。 |
-| `ENABLE_CIRCUIT_BREAKER_ON_NETWORK_ERRORS` | `false` | 是否将网络错误计入熔断器;开启后能更激进地阻断异常线路。 |
-| `APP_PORT` | `23000` | 生产端口,可被容器或进程管理器覆盖。 |
-| `APP_URL` | 空 | 设置后 OpenAPI 文档 `servers` 将展示正确域名/端口。 |
+| 变量                                       | 默认值                   | 说明与建议                                                                   |
+| ------------------------------------------ | ------------------------ | ---------------------------------------------------------------------------- |
+| `ADMIN_TOKEN`                              | `change-me`              | 后台登录令牌,部署前必须修改。                                               |
+| `DSN`                                      | -                        | PostgreSQL 连接串,如 `postgres://user:pass@host:5432/db`.                   |
+| `AUTO_MIGRATE`                             | `true`                   | 启动时自动执行 Drizzle 迁移;生产环境可关闭以人工控制。                      |
+| `REDIS_URL`                                | `redis://localhost:6379` | Redis 地址,支持 `rediss://` 用于 TLS。                                      |
+| `ENABLE_RATE_LIMIT`                        | `true`                   | 控制多维限流开关;Fail-Open 策略在 Redis 不可用时自动降级。                  |
+| `SESSION_TTL`                              | `300`                    | Session 缓存时间(秒),影响供应商复用策略。                                 |
+| `ENABLE_SECURE_COOKIES`                    | `true`                   | 仅 HTTPS 场景能设置 Secure Cookie;HTTP 访问(非 localhost)需改为 `false`。 |
+| `ENABLE_CIRCUIT_BREAKER_ON_NETWORK_ERRORS` | `false`                  | 是否将网络错误计入熔断器;开启后能更激进地阻断异常线路。                     |
+| `APP_PORT`                                 | `23000`                  | 生产端口,可被容器或进程管理器覆盖。                                         |
+| `APP_URL`                                  | 空                       | 设置后 OpenAPI 文档 `servers` 将展示正确域名/端口。                          |
 
 > 布尔变量请直接写 `true/false` 或 `1/0`,勿加引号,避免被 Zod 转换为真值。更多字段参考 `.env.example`。
 
 ## ❓ FAQ
 
-1. **数据库连接失败怎么办?**  
-   - 确认 `DSN` 格式与凭据无误;Docker 场景下使用服务名(如 `postgres:5432`)。  
+1. **数据库连接失败怎么办?**
+   - 确认 `DSN` 格式与凭据无误;Docker 场景下使用服务名(如 `postgres:5432`)。
    - 查看 `docker compose ps` 或本地 PostgreSQL 状态,必要时通过 `make db-shell` 诊断。
 
-2. **Redis 离线会影响服务吗?**  
+2. **Redis 离线会影响服务吗?**
    - 平台采用 Fail-Open 策略:限流与会话统计会降级,但请求仍会继续;建议监控日志中的 Redis Error 并尽快恢复。
 
-3. **熔断器持续打开如何排查?**  
-   - 查看日志中的 `[CircuitBreaker]` 记录,确认是否由于 4xx/5xx 或网络错误导致。  
+3. **熔断器持续打开如何排查?**
+   - 查看日志中的 `[CircuitBreaker]` 记录,确认是否由于 4xx/5xx 或网络错误导致。
    - 在管理后台检查供应商健康状态,等待 30 分钟或重启应用重置状态。
 
-4. **提示“无可用供应商”该怎么办?**  
-   - 检查供应商是否启用、权重/优先级设置合理,以及是否达到并发/金额限制。  
+4. **提示“无可用供应商”该怎么办?**
+   - 检查供应商是否启用、权重/优先级设置合理,以及是否达到并发/金额限制。
    - 查看决策链日志,确认是否被熔断或代理失败导致。
 
-5. **代理配置失败?**  
-   - 确认 URL 含协议前缀(`http://`、`socks5://` 等),并使用后台“测试连接”按钮验证。  
+5. **代理配置失败?**
+   - 确认 URL 含协议前缀(`http://`、`socks5://` 等),并使用后台“测试连接”按钮验证。
    - 若启用降级策略(`proxy_fallback_to_direct`),请在日志中确认是否已自动切换至直连。
 
 ## 🤝 贡献指南 Contributing