docs: 添加多账号 OAuth 支持文档

- 添加 add-account.js 和 sync-accounts.sh 使用说明
- 说明配置优先级和账号管理特性
- accounts.json 添加到 .gitignore
This commit is contained in:
empty
2025-12-27 12:59:28 +08:00
parent dd58dec1f5
commit fecd215719
2 changed files with 43 additions and 1 deletions

1
.gitignore vendored
View File

@@ -4,3 +4,4 @@ node_modules/
.DS_Store
*.txt
AGENTS.md
accounts.json

View File

@@ -78,8 +78,49 @@ export DROID_REFRESH_KEY="your_refresh_token_here"
# 方式4无配置客户端授权
# 服务器将使用客户端请求头中的authorization字段
# 方式5多账号OAuth推荐免费用户
# 使用 accounts.json 配置多个账号自动轮询
```
### 多账号 OAuth 支持(推荐)
适用于免费账号用户,支持多个账号自动轮询:
**1. 添加账号**
```bash
# 交互式添加账号(自动打开浏览器完成授权)
node add-account.js
# 连续添加多个账号
node add-account.js --loop
```
**2. 同步到远程服务器**
```bash
# 配置 .env 中的同步参数
SYNC_SERVER=user@your-server.com
SYNC_REMOTE_PATH=/opt/droid2api
DEPLOY_TYPE=docker-compose
# 运行同步脚本
./sync-accounts.sh
```
**3. 配置优先级**
```
accounts.json (多账号OAuth) > FACTORY_API_KEY > DROID_REFRESH_KEY > ~/.factory/auth.json
```
**4. 账号管理特性**
- ✅ 基于健康度加权轮询选择账号
- ✅ 自动刷新 access_token每6小时
- ✅ 401/402 错误时自动禁用异常账号
- ✅ 请求统计和健康度监控
### 2. 配置模型(可选)
编辑 `config.json` 添加或修改模型: