docs: add README.md and update AGENTS.md
This commit is contained in:
@@ -1,36 +1,134 @@
|
||||
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).
|
||||
# 食谱翻译工具
|
||||
|
||||
## Getting Started
|
||||
一款基于 AI 的食谱文档翻译工具,支持解析 Word 文档、智能翻译、批量导出。
|
||||
|
||||
First, run the development server:
|
||||
## 功能特性
|
||||
|
||||
```bash
|
||||
npm run dev
|
||||
# or
|
||||
yarn dev
|
||||
# or
|
||||
pnpm dev
|
||||
# or
|
||||
bun dev
|
||||
- **Word 文档解析** - 解析 `.docx` 格式的食谱文档,提取菜品信息
|
||||
- **AI 智能翻译** - 支持 OpenAI / GLM 等大模型 API,批量翻译菜品名称
|
||||
- **翻译词库管理** - 管理常用词组翻译对照表
|
||||
- **多格式导出** - 导出双语对照的 Word 文档
|
||||
- **导出设置** - 自定义未翻译文本颜色、页面方向、第二页表头等
|
||||
|
||||
## 技术栈
|
||||
|
||||
- **框架**: Next.js 16 (App Router)
|
||||
- **语言**: TypeScript
|
||||
- **样式**: Tailwind CSS + shadcn/ui
|
||||
- **文档**: docx (Word 生成)
|
||||
- **数据库**: MySQL 8.0
|
||||
- **AI**: OpenAI API / 智谱 GLM
|
||||
|
||||
## 项目结构
|
||||
|
||||
```
|
||||
├── app/ # Next.js App Router
|
||||
│ ├── api/ # API 路由
|
||||
│ │ ├── ai/ # AI 翻译接口
|
||||
│ │ ├── config/ # 配置管理接口
|
||||
│ │ ├── recipe/ # 食谱解析接口
|
||||
│ │ ├── translate/ # 翻译接口
|
||||
│ │ └── words/ # 词库管理接口
|
||||
│ ├── settings/ # 设置页面
|
||||
│ │ ├── ai/ # AI 配置
|
||||
│ │ ├── database/ # 数据库配置
|
||||
│ │ ├── export/ # 导出设置
|
||||
│ │ └── translation/ # 翻译词库
|
||||
│ └── page.tsx # 首页
|
||||
├── components/ # React 组件
|
||||
├── lib/ # 工具函数
|
||||
│ ├── config.ts # 配置管理
|
||||
│ ├── database.ts # 数据库连接
|
||||
│ └── ai-translate.ts # AI 翻译
|
||||
├── config.json # 配置文件
|
||||
├── Dockerfile # Docker 构建
|
||||
└── docker-compose.yml # Docker 编排
|
||||
```
|
||||
|
||||
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
|
||||
## 快速开始
|
||||
|
||||
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
|
||||
### 环境要求
|
||||
|
||||
This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
|
||||
- Node.js 20+
|
||||
- MySQL 8.0
|
||||
- pnpm
|
||||
|
||||
## Learn More
|
||||
### 本地开发
|
||||
|
||||
To learn more about Next.js, take a look at the following resources:
|
||||
```bash
|
||||
# 1. 安装依赖
|
||||
pnpm install
|
||||
|
||||
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
|
||||
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
|
||||
# 2. 配置环境变量
|
||||
cp .env.docker .env
|
||||
# 编辑 .env 填入数据库和 AI API 配置
|
||||
|
||||
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
|
||||
# 3. 启动开发服务器
|
||||
pnpm dev
|
||||
```
|
||||
|
||||
## Deploy on Vercel
|
||||
访问 http://localhost:3000
|
||||
|
||||
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
|
||||
### Docker 部署
|
||||
|
||||
Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
|
||||
```bash
|
||||
# 1. 配置环境变量
|
||||
cp .env.docker .env
|
||||
# 编辑 .env 填入配置
|
||||
|
||||
# 2. 构建并启动
|
||||
docker-compose up -d
|
||||
|
||||
# 3. 查看日志
|
||||
docker-compose logs -f app
|
||||
```
|
||||
|
||||
## 配置说明
|
||||
|
||||
### 配置文件
|
||||
|
||||
所有配置存储在 `config.json` 中,可通过设置页面修改:
|
||||
|
||||
| 配置项 | 说明 |
|
||||
|--------|------|
|
||||
| `db` | 数据库连接配置 |
|
||||
| `ai` | AI 翻译 API 配置 |
|
||||
| `export` | 导出文档格式配置 |
|
||||
|
||||
### 环境变量
|
||||
|
||||
首次启动时,环境变量会初始化 `config.json`。之后配置以 `config.json` 为准。
|
||||
|
||||
| 变量名 | 说明 | 默认值 |
|
||||
|--------|------|--------|
|
||||
| `DB_HOST` | 数据库地址 | 127.0.0.1 |
|
||||
| `DB_PORT` | 数据库端口 | 3306 |
|
||||
| `DB_USER` | 数据库用户名 | root |
|
||||
| `DB_PASSWORD` | 数据库密码 | - |
|
||||
| `DB_NAME` | 数据库名 | recipe_tools |
|
||||
| `AI_API_KEY` | AI API Key | - |
|
||||
| `AI_BASE_URL` | API 地址 | https://api.openai.com/v1 |
|
||||
| `AI_MODEL` | 模型名称 | gpt-3.5-turbo |
|
||||
|
||||
## API 接口
|
||||
|
||||
| 接口 | 方法 | 说明 |
|
||||
|------|------|------|
|
||||
| `/api/config` | GET/POST | 获取/保存配置 |
|
||||
| `/api/recipe` | POST | 解析食谱文档 |
|
||||
| `/api/translate` | POST | 批量翻译 |
|
||||
| `/api/ai/translate` | GET | 单词翻译测试 |
|
||||
| `/api/words` | GET/POST | 词库列表/添加 |
|
||||
| `/api/words/[id]` | PATCH/DELETE | 编辑/删除词条 |
|
||||
|
||||
## 导出设置
|
||||
|
||||
| 选项 | 说明 |
|
||||
|------|------|
|
||||
| 未翻译文本颜色 | 未翻译菜品在文档中的显示颜色 |
|
||||
| 页面方向 | 横向/纵向 |
|
||||
| 第二页表头 | 多页时后续页显示表头行 |
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
|
||||
Reference in New Issue
Block a user