HtmlToPdf/CONTRIBUTING.md
2025-12-11 23:52:15 +08:00

179 lines
3.2 KiB
Markdown
Raw 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.

# 贡献指南
感谢您对 HtmlToPdf Service 的关注!我们欢迎任何形式的贡献。
## 如何贡献
### 报告 Bug
如果你发现了 Bug请通过 [GitHub Issues](https://github.com/your-username/html-to-pdf/issues) 报告。创建 Issue 时请包含:
- 问题的详细描述
- 复现步骤
- 预期行为 vs 实际行为
- 运行环境(操作系统、.NET 版本、Docker 版本等)
- 相关的日志或错误信息
### 功能建议
有新功能想法?请创建一个 Feature Request Issue描述
- 功能的详细说明
- 使用场景
- 可能的实现方案(可选)
### 提交代码
1. **Fork 仓库**
2. **克隆你的 Fork**
```bash
git clone https://github.com/your-username/html-to-pdf.git
cd html-to-pdf
```
3. **创建功能分支**
```bash
git checkout -b feature/your-feature-name
```
4. **进行开发**
- 遵循现有的代码风格
- 添加必要的测试
- 确保所有测试通过
5. **提交更改**
```bash
git add .
git commit -m "feat: 添加某某功能"
```
6. **推送到你的 Fork**
```bash
git push origin feature/your-feature-name
```
7. **创建 Pull Request**
- 描述你的更改
- 关联相关的 Issue如果有
## 开发环境设置
### 前置要求
- .NET 9.0 SDK
- Docker & Docker Compose
- Node.js 18+(用于管理后台开发)
- Redis或使用 Docker
### 本地开发
```bash
# 启动 Redis
docker run -d --name redis -p 6379:6379 redis:7-alpine
# 进入源码目录
cd src
# 还原依赖
dotnet restore
# 运行测试
dotnet test
# 启动服务
dotnet run --project HtmlToPdfService.Api
```
### 管理后台开发
```bash
cd src/HtmlToPdfService.Admin
npm install
npm run dev
```
## 代码规范
### C# 代码规范
- 使用 4 空格缩进
- 类名使用 PascalCase
- 私有字段使用 `_camelCase` 前缀
- 方法名使用 PascalCase
- 异步方法以 `Async` 结尾
- 添加 XML 文档注释
### 提交信息规范
使用 [Conventional Commits](https://www.conventionalcommits.org/) 格式:
```
<type>(<scope>): <description>
[optional body]
[optional footer]
```
**Type 类型:**
- `feat`: 新功能
- `fix`: Bug 修复
- `docs`: 文档更新
- `style`: 代码格式(不影响功能)
- `refactor`: 重构
- `test`: 测试相关
- `chore`: 构建/工具相关
**示例:**
```
feat(api): 添加批量任务提交接口
fix(pool): 修复浏览器池内存泄漏问题
docs: 更新 API 文档
```
## 测试
### 运行测试
```bash
cd src
dotnet test
```
### 测试覆盖率
```bash
dotnet test --collect:"XPlat Code Coverage"
```
## Pull Request 检查清单
提交 PR 前请确保:
- [ ] 代码可以正常编译
- [ ] 所有测试通过
- [ ] 添加了新功能的测试(如适用)
- [ ] 更新了相关文档
- [ ] 提交信息符合规范
- [ ] 代码已格式化
## 行为准则
参与本项目,请遵守以下准则:
- 尊重所有贡献者
- 保持友善和专业的交流
- 接受建设性的批评
- 关注项目和社区的最佳利益
## 问题?
如有任何问题,欢迎通过以下方式联系:
- [GitHub Discussions](https://github.com/your-username/html-to-pdf/discussions)
- [GitHub Issues](https://github.com/your-username/html-to-pdf/issues)
再次感谢您的贡献!🎉