Files
2026-04-02 23:40:04 +08:00

49 lines
1.1 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.
# 开发规则
## 环境配置
- 开发环境使用 `.env.development`
- 生产环境使用 `.env.production`
- 不提交 `.env` 文件到 Git
- 提供 `.env.example` 模板
**必需环境变量**
```bash
DATABASE_URL=postgresql://user:pass@host:5432/dbname
REDIS_URL=redis://host:6379/0
CASDOOR_ENDPOINT=https://casdoor.example.com
CASDOOR_CLIENT_ID=your_client_id
CASDOOR_CLIENT_SECRET=your_client_secret
SECRET_KEY=your-secret-key
```
## 测试要求
- 核心业务逻辑需要单元测试
- API 端点需要集成测试
- 测试覆盖率目标:≥80%
- 使用 pytest(后端)和 vitest(前端)
**测试示例**
```python
def test_device_status_check():
device = create_test_device()
result = check_device_status(device)
assert result.status in ["online", "offline"]
```
## 文档要求
- API 变更及时更新 Swagger 文档
- 复杂业务逻辑添加注释
- 重要配置添加说明
- 保持 README 和设计文档同步
## 开发流程
1. 创建功能分支:`git checkout -b feature/xxx`
2. 开发并提交代码
3. 运行测试:`pytest` / `npm run test`
4. 提交 PR 并等待审核
5. 合并到主分支