Files
AI_Translator/README.md
2025-12-29 15:52:50 +08:00

72 lines
1.2 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.
# AI Translator
AI 翻译网站 - Next.js + FastAPI
## 项目结构
```
apps/
web/ # Next.js 前端
api/ # FastAPI 后端
infra/ # Docker 配置
```
## 快速开始
### 本地开发
1. 后端
```bash
cd apps/api
pip install -e .
cp .env.example .env
# 编辑 .env 配置 LLM_API_KEY
uvicorn app.main:app --reload --port 8030
```
2. 前端
```bash
cd apps/web
npm install
cp .env.example .env.local
npm run dev
```
如果遇到 `/_next/static/* 404``vendor-chunks` 缺失Windows 上偶发的 Next 构建缓存污染),先清理再启动:
```bash
cd apps/web
npm run clean:next
npm run dev
```
### Docker 部署
```bash
cd infra
cp .env.example .env
# 编辑 .env 配置 LLM_API_KEY
docker-compose up -d
```
访问 http://localhost:3030
## 管理员后台
### 初始化数据库
```bash
cd apps/api
python scripts/init_db.py [用户名] [密码]
# 默认: admin / admin123
```
### 访问后台
- 登录页: http://localhost:3030/login
- 后台首页: http://localhost:3030/admin
### 后台功能
- **AI 配置管理**: 添加/编辑/删除 AI Provider模型ID、Base URL、API Key
- **使用统计**: 查看请求数、Token 用量、RPM/TPM、缓存命中率、错误数