feat: v2 版本 #206

Merged
huanghaosheng merged 201 commits from v2 into main 2026-06-22 16:01:28 +08:00
Showing only changes of commit 31c1720c00 - Show all commits

View File

@@ -472,35 +472,108 @@ CamTalk 采用 **JWT 双 token 轮转 + Refresh Token Rotation** 安全机制:
| [09-情景切换](docs/09-情景切换.md) | 情景模式设计与实现 |
| [12-自定义情景](docs/12-自定义情景.md) | 用户自定义情景功能(规划中) |
## 🤝 贡献指南
## 🛠️ 本地开发和远程部署指南
欢迎提交 Issue 和 Pull Request
### 本地开发环境配置
### 开发规范
- **提交信息**:遵循 [Conventional Commits](https://www.conventionalcommits.org/),中文描述(例:`feat: 添加 WebSocket 心跳`
- **Go 代码**:遵循标准 Go 规范,使用 `golangci-lint` 检查
- **TypeScript 代码**:严格模式,使用 ESLint + Prettier
- **文档优先**:开发前先读 `docs/` 设计文档,代码与文档不一致时优先更新文档
### 本地开发环境
#### 1. 代码检查工具
```bash
# 安装开发工具
# 安装 Go 代码检查工具
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
# 运行代码检查
cd backend
golangci-lint run
# 运行测试
# 前端代码检查
cd frontend
npm run lint
```
#### 2. 运行测试
```bash
# 后端单元测试
cd backend
go test ./...
# 后端集成测试(需要 PostgreSQL
go test -tags=integration ./...
# 前端测试
cd frontend
npm test
```
#### 3. 数据库迁移
```bash
# 运行迁移(自动创建/更新表结构)
cd backend
go run ./cmd/server migrate
# 回滚迁移
go run ./cmd/server migrate:rollback
```
### 远程服务器部署
#### 方式一Docker Compose
```bash
# 1. 克隆代码到服务器
git clone https://github.com/yourusername/CamTalk.git
cd CamTalk
# 2. 配置环境变量
cp backend/.env.example backend/.env
# 编辑 .env 文件,填入生产环境配置
# 3. 一键部署
./deploy.sh up
# 4. 查看日志
./deploy.sh logs
# 5. 停止服务
./deploy.sh down
```
#### 方式二:手动部署
```bash
# 1. 构建前端
cd frontend
npm install
npm run build # 输出到 dist/
# 2. 构建后端
cd backend
go build -o camtalk ./cmd/server
# 3. 配置 Nginx
# 参考 nginx.conf.example 配置反向代理
# 4. 启动服务
APP_ENV=prod ./camtalk
# 5. 使用 systemd 管理(可选)
sudo systemctl enable camtalk
sudo systemctl start camtalk
```
#### 环境变量检查清单
部署前确保已配置以下环境变量:
-`CAMTALK_AUTH_JWT_SECRET`(使用 `openssl rand -hex 32` 生成)
-`CAMTALK_STORAGE_DSN`PostgreSQL 连接字符串)
-`CAMTALK_AI_LLM_API_KEY`DashScope API Key
-`CAMTALK_AI_STT_API_KEY`STT 服务 API Key
-`CAMTALK_AI_TTS_API_KEY`TTS 服务 API Key
-`APP_ENV=prod`(启用生产环境配置)
## 🐛 问题反馈
遇到问题?请提交 [Issue](https://github.com/yourusername/CamTalk/issues),并提供以下信息: